/* kops_admin web — shared admin design language with kitchen_ops.
   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;

  --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;
  gap: 16px;
}
.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 { color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.topbar .who .name { color: var(--text); }
.topbar .sep { color: var(--text-faint); }

/* ---------- 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);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ---------- 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;
  gap: 12px;
  flex-wrap: wrap;
}
.surface-head .title {
  font-weight: 600;
  color: var(--text);
}
.surface-head .count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.surface-body { padding: 14px; }
.surface-body > :first-child { margin-top: 0; }
.surface-body > :last-child  { margin-bottom: 0; }

/* ---------- 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; }
input[type=checkbox], input[type=radio] {
  accent-color: var(--accent);
  transform: translateY(1px);
}
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); color: #fff; }

.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;
}
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; 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; }
tbody tr.is-disabled td { color: var(--text-muted); background: var(--surface-alt); }
tbody tr.is-disabled:hover td { background: var(--surface-alt); }
.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  { background: var(--status-pending-bg);  color: var(--status-pending-fg);  border-color: var(--status-pending-bd); }
.pill--approved { background: var(--status-approved-bg); color: var(--status-approved-fg); border-color: var(--status-approved-bd); }
.pill--applied  { background: var(--status-applied-bg);  color: var(--status-applied-fg);  border-color: var(--status-applied-bd); }
.pill--denied   { background: var(--status-denied-bg);   color: var(--status-denied-fg);   border-color: var(--status-denied-bd); }

.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);
}

.role-tag {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  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 (used for flash messages) ---------- */
.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--ok {
  background: var(--accent-tint);
  border-color: var(--border);
  border-left-color: var(--accent);
  color: var(--text);
}
.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;
}

/* ---------- form rows (label / input / hint) used in new-record forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 14px;
  align-items: center;
  font-size: 13px;
}
.form-grid > .label { color: var(--text-muted); }
.form-grid > .hint  { color: var(--text-muted); font-size: 12px; }
.form-grid input[type=text], .form-grid input[type=password],
.form-grid input[type=number], .form-grid select {
  width: 100%;
  max-width: 360px;
}
.form-grid .actions-row { grid-column: 2 / span 2; }

/* ---------- description block used in RAR list ---------- */
.description {
  white-space: pre-wrap;
  max-width: 480px;
  color: var(--text);
}

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

/* ---------- dark mode (auto-follows OS, screen-only — print stays light) ---------- */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --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;

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

    color-scheme: dark;
  }
  .btn--primary { color: #0a0a0b; }
  .btn--primary:hover { color: #0a0a0b; }
  .btn--danger { color: #fca5a5; border-color: #7f1d1d; }
  .btn--danger:hover { background: #450a0a; border-color: #ef4444; }
  .callout--error {
    background: #450a0a;
    border-color: #7f1d1d;
    border-left-color: #f87171;
    color: #fca5a5;
  }
}

@media print {
  body { background: #fff; }
  .topbar, .filter-bar, .actions { display: none; }
  .surface, .kpi-strip { border-color: #000; box-shadow: none; }
  tbody tr:hover td { background: transparent; }
}
