/* kops web — admin design language proposal.
   Function-first: flat, dense, scannable, no decoration that isn't load-bearing.
   System fonts, 1px borders, one accent color, status earns the only color. */

:root {
  --bg:            #fafafa;
  --surface:       #ffffff;
  --surface-alt:   #f5f5f5;
  --border:        #e4e4e7;
  --border-strong: #d4d4d8;
  --text:          #18181b;
  --text-muted:    #71717a;
  --text-faint:    #a1a1aa;
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-tint:   #eff6ff;
  --row-hover:     #f9fafb;
  --focus:         rgba(37, 99, 235, 0.35);

  --status-pending-bg:  #fef9c3;
  --status-pending-fg:  #854d0e;
  --status-pending-bd:  #fde68a;
  --status-approved-bg: #dcfce7;
  --status-approved-fg: #166534;
  --status-approved-bd: #86efac;
  --status-denied-bg:   #fee2e2;
  --status-denied-fg:   #991b1b;
  --status-denied-bd:   #fca5a5;
  --status-applied-bg:  #f4f4f5;
  --status-applied-fg:  #52525b;
  --status-applied-bd:  #d4d4d8;
  --status-info-bg:     #dbeafe;
  --status-info-fg:     #1e40af;
  --status-info-bd:     #93c5fd;

  --warn-bg:     #fffbeb;
  --warn-bd:     #fcd34d;
  --warn-fg:     #78350f;

  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar (thin, white, no chrome) ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 44px;
  font-size: 13px;
}
.topbar .brand {
  font-weight: 600;
  color: var(--text);
}
.topbar .brand a { color: inherit; text-decoration: none; }
.topbar nav { display: flex; gap: 16px; align-items: center; color: var(--text-muted); }
.topbar nav a { color: var(--text); }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }
.topbar .who {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
}
.topbar .who-ident { display: inline-flex; gap: 6px; align-items: baseline; }
.topbar .sep { color: var(--text-faint); }
.topbar-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  padding: 1px 8px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.topbar-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  text-decoration: none;
}

/* ---------- page layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-head .meta { color: var(--text-muted); font-size: 13px; }
.page-head .scope-tag {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 0;
}

/* Toolbar-only header — H1/scope live in the breadcrumb, so the page
   header is just a thin right-aligned action row. */
.page-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* ---------- generic surface (replaces the beveled .window) ---------- */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
}
.surface-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.surface-head .title {
  font-weight: 600;
  color: var(--text);
}
.surface-head .count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- KPI strip (dense numeric summary, no card chrome) ---------- */
.kpi-strip {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.kpi-strip .kpi { display: flex; gap: 6px; align-items: baseline; }
.kpi-strip .kpi .label { color: var(--text-muted); }
.kpi-strip .kpi .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-strip .hint {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.filter-bar label { color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.filter-bar .spacer { flex: 1; }
.filter-bar .count { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- form controls ---------- */
input[type=text], input[type=password], input[type=search],
input[type=number], input[type=email], select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 4px 8px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
  border-color: var(--accent);
}
input[type=number] { font-variant-numeric: tabular-nums; }
select { padding-right: 24px; }

/* ---------- buttons (flat, intent-coloured only when needed) ---------- */
.btn {
  display: inline-block;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 4px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:focus { outline: 2px solid var(--focus); outline-offset: 1px; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--danger {
  background: var(--surface);
  color: #b91c1c;
  border-color: #fca5a5;
}
.btn--danger:hover { background: #fef2f2; border-color: #ef4444; }

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding: 4px 8px;
}
.btn--ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn--sm { padding: 2px 8px; font-size: 12px; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
form.inline { display: inline; }

/* ---------- tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}
thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th.num { text-align: right; }
tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
tbody td.num { text-align: right; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
tbody tr:hover td { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
.surface table { border-radius: 0 0 6px 6px; overflow: hidden; }

.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 12px; }

/* ---------- status pills (one of the few places colour is allowed) ---------- */
.pill {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 3px;
  border: 1px solid;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  font-variant: small-caps;
}
.pill--pending,
.pill--warn     { background: var(--status-pending-bg);  color: var(--status-pending-fg);  border-color: var(--status-pending-bd); }
.pill--approved,
.pill--ok       { background: var(--status-approved-bg); color: var(--status-approved-fg); border-color: var(--status-approved-bd); }
.pill--applied,
.pill--muted    { background: var(--status-applied-bg);  color: var(--status-applied-fg);  border-color: var(--status-applied-bd); }
.pill--denied,
.pill--danger   { background: var(--status-denied-bg);   color: var(--status-denied-fg);   border-color: var(--status-denied-bd); }
.pill--info     { background: var(--status-info-bg);     color: var(--status-info-fg);     border-color: var(--status-info-bd); }

/* Outline modifier — drops the fill, keeps tinted border + text. Pair
   with any semantic variant. Used for "additive" hints (PAR, OVR) where
   filled chips would feel like alerts. */
.pill--outline { background: transparent; }

.outlet-tag {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-family: var(--font-mono);
}

.attachment-chip {
  display: inline-block;
  padding: 1px 8px;
  margin-right: 4px;
  font-size: 11px;
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--text-muted);
}
.attachment-chip:hover { color: var(--accent); text-decoration: none; }

/* ---------- callouts ---------- */
.callout {
  background: var(--warn-bg);
  border: 1px solid var(--warn-bd);
  border-left: 3px solid var(--warn-bd);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--warn-fg);
}
.callout h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.callout p { margin: 0; }
.callout a { color: inherit; text-decoration: underline; }

.callout--info {
  background: var(--accent-tint);
  border-color: var(--border);
  border-left-color: var(--accent);
  color: var(--text);
}
.callout--error {
  background: #fee2e2;
  border-color: #fca5a5;
  border-left-color: #b91c1c;
  color: #991b1b;
}

/* ---------- sticky save toolbar (for long forms like par levels) ---------- */
.save-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}
.save-bar .hint { color: var(--text-muted); font-size: 12px; }

/* ---------- input-cell variants (par-levels-style inline editing) ---------- */
.input-cell {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
}
.input-cell input[type=number] { width: 64px; text-align: right; }
.input-cell input.narrow { width: 52px; }
.input-cell .uom {
  color: var(--text-muted);
  font-size: 11px;
  min-width: 20px;
  text-align: left;
  font-family: var(--font-mono);
}
td.has-value { background: #f0fdf4; }   /* subtle green wash for "value set" */
td.has-value input { background: transparent; }

/* ---------- minor utilities ---------- */
.row-spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col-stack { display: flex; flex-direction: column; gap: 2px; }

/* ---------- dark mode (driven by html.theme-dark — set in base.html
   from localStorage 'kops.theme', defaults to OS preference; print stays light) ---------- */
html.theme-dark {
  --bg:            #0a0a0b;
  --surface:       #18181b;
  --surface-alt:   #27272a;
  --border:        #27272a;
  --border-strong: #3f3f46;
  --text:          #fafafa;
  --text-muted:    #a1a1aa;
  --text-faint:    #71717a;
  --accent:        #60a5fa;
  --accent-hover:  #93c5fd;
  --accent-tint:   #172554;
  --row-hover:     #1f1f23;
  --focus:         rgba(96, 165, 250, 0.45);

  --status-pending-bg:  #422006;
  --status-pending-fg:  #fde68a;
  --status-pending-bd:  #78350f;
  --status-approved-bg: #052e16;
  --status-approved-fg: #86efac;
  --status-approved-bd: #14532d;
  --status-denied-bg:   #450a0a;
  --status-denied-fg:   #fca5a5;
  --status-denied-bd:   #7f1d1d;
  --status-applied-bg:  #27272a;
  --status-applied-fg:  #a1a1aa;
  --status-applied-bd:  #3f3f46;
  --status-info-bg:     #172554;
  --status-info-fg:     #93c5fd;
  --status-info-bd:     #1e3a8a;

  --warn-bg:     #422006;
  --warn-bd:     #b45309;
  --warn-fg:     #fcd34d;

  color-scheme: dark;
}
html.theme-dark .btn--primary { color: #0a0a0b; }
html.theme-dark .btn--primary:hover { color: #0a0a0b; }
html.theme-dark .btn--danger { color: #fca5a5; border-color: #7f1d1d; }
html.theme-dark .btn--danger:hover { background: #450a0a; border-color: #ef4444; }
html.theme-dark .callout--error {
  background: #450a0a;
  border-color: #7f1d1d;
  border-left-color: #f87171;
  color: #fca5a5;
}
/* par-levels "value set" wash — dim green for dark */
html.theme-dark td.has-value { background: #052e16; }
@media print {
  body { background: #fff; }
  .topbar, .save-bar, .filter-bar, .actions { display: none; }
  .surface, .kpi-strip { border-color: #000; box-shadow: none; }
  tbody tr:hover td { background: transparent; }
}
