/* Anwesend Admin — design system.
 *
 * Served straight from public/ (this app has no asset pipeline; the
 * marketing pages ship style.css the same way). The layout busts the
 * far-future cache header with an mtime fingerprint — see
 * AdminHelper#admin_stylesheet_url.
 *
 * Organised as: tokens, base, shell, page furniture, cards, tables, forms,
 * buttons, status, empty states, utilities, responsive, print. Component
 * class names from the previous inline stylesheet (.card, .btn, .badge,
 * .muted, .flash, .callout, .grid, .stat) all still resolve, so a view that
 * has not been touched still renders correctly.
 */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light;

  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --muted-soft: #94a3b8;

  --canvas: #f6f7f9;
  --surface: #ffffff;
  --surface-sunken: #f8fafc;
  --surface-hover: #f1f5f9;

  --line: #e5e7eb;
  --line-soft: #eef1f4;
  --line-strong: #d5dae1;

  --ok-bg: #dcfce7;   --ok-fg: #15803d;   --ok-line: #bbf7d0;
  --warn-bg: #fef9c3; --warn-fg: #a16207; --warn-line: #fde68a;
  --bad-bg: #fee2e2;  --bad-fg: #b91c1c;  --bad-line: #fecaca;
  --info-bg: #e0e7ff; --info-fg: #4338ca; --info-line: #c7d2fe;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.05);

  --sidebar-w: 244px;
  --topbar-h: 60px;

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

/* -------------------------------------------------------------------- base */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.011em; }

code {
  font-family: var(--font-mono);
  background: var(--surface-sunken);
  border: 1px solid var(--line-soft);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.82em;
  word-break: break-all;
}

hr { border: none; border-top: 1px solid var(--line-soft); margin: 1.5rem 0; }

:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------- shell */

.app { min-height: 100vh; }

/* Sidebar --------------------------------------------------------------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: var(--topbar-h);
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sidebar-brand:hover { text-decoration: none; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  box-shadow: var(--shadow-xs);
}
.brand-mark svg { width: 18px; height: 18px; display: block; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 650; font-size: 0.95rem; color: var(--ink); letter-spacing: -0.01em; }
.brand-sub {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted-soft);
  font-weight: 600;
}

.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.85rem 0.65rem 1.5rem;
}

.nav-section + .nav-section { margin-top: 1.1rem; }

.nav-section-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted-soft);
  font-weight: 650;
  padding: 0 0.6rem;
  margin-bottom: 0.3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.46rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.885rem;
  font-weight: 500;
  position: relative;
}
.nav-item:hover { background: var(--surface-hover); color: var(--ink); text-decoration: none; }
.nav-item svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--muted-soft); }
.nav-item:hover svg { color: var(--muted); }

.nav-item.current { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.nav-item.current svg { color: var(--brand-600); }
.nav-item.current::before {
  content: "";
  position: absolute;
  left: -0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-600);
}

.nav-count {
  margin-left: auto;
  background: var(--bad-bg);
  color: var(--bad-fg);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
}

.sidebar-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 0.75rem 0.9rem;
  font-size: 0.78rem;
  color: var(--muted-soft);
}

/* Topbar ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
}

.topbar-org {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  min-width: 0;
}
.topbar-org .org-dot {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  background: var(--brand-100);
  color: var(--brand-700);
  display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 700;
  flex: 0 0 auto;
}
.topbar-org span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-user { text-align: right; line-height: 1.2; min-width: 0; }
.topbar-user .name { font-size: 0.83rem; font-weight: 600; color: var(--ink-soft); }
.topbar-user .role { font-size: 0.72rem; color: var(--muted-soft); }

.content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

/* Off-canvas sidebar toggle. A checkbox rather than script so the nav still
   works if JavaScript is unavailable — this panel has none otherwise. */
#nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  flex: 0 0 auto;
}
.nav-burger svg { width: 18px; height: 18px; }
.nav-scrim { display: none; }

/* ----------------------------------------------------------- page furniture */

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
}

.page-head .page-heading { min-width: 0; flex: 1 1 320px; }

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.page-back:hover { color: var(--brand-700); }

h1, .page-title {
  font-size: 1.5rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 72ch;
}
.page-subtitle strong { color: var(--ink-soft); }

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.005em;
}

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.1rem;
}

.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.card h2 { font-size: 0.95rem; font-weight: 650; margin: 0 0 0.75rem; }

/* Flush variant: the card is a frame around a table or a header strip, and
   supplies its own padding per region instead of one outer box. */
.card.flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.card-head .card-head-actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.card-body { padding: 1.15rem 1.25rem; }
.card-foot {
  padding: 0.8rem 1.25rem;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-sunken);
  font-size: 0.83rem;
  color: var(--muted);
}
.card-foot > :first-child { margin-top: 0; }
.card-foot > :last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ tables */

.table-wrap { width: 100%; overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

/* Deliberately not sticky: every table here sits inside .table-wrap, whose
   overflow-x makes it the sticky scrollport, and a sticky header in it is
   offset down over the first row instead of pinned to the viewport. */
thead th {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.card.flush thead th:first-child, .card.flush tbody td:first-child { padding-left: 1.25rem; }
.card.flush thead th:last-child, .card.flush tbody td:last-child { padding-right: 1.25rem; }

tbody tr:last-child td { border-bottom: none; }

/* Totals row (the network usage page's daily table). */
tfoot th {
  font-weight: 650;
  border-top: 1px solid var(--line);
  border-bottom: none;
  background: var(--surface-sunken);
  white-space: nowrap;
}
.card.flush tfoot th:first-child { padding-left: 1.25rem; }
.card.flush tfoot th:last-child { padding-right: 1.25rem; }
tbody tr:hover td { background: var(--surface-sunken); }

td .muted, td small { display: block; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }

/* Key/value table: label column on the left, no sticky header, no zebra. */
.table-kv th {
  width: 210px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.8rem;
  color: var(--muted);
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
  vertical-align: top;
}
.table-kv td { font-size: 0.885rem; }
.table-kv tr:hover td { background: transparent; }

/* ------------------------------------------------------------------- forms */

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 0.3rem;
}

.field { margin-bottom: 0.95rem; }
.field:last-child { margin-bottom: 0; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=file], select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) {
  border-color: var(--muted-soft);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}

input::placeholder, textarea::placeholder { color: var(--muted-soft); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.9rem;
}

input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand-600); }

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 68ch;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.87rem;
  color: var(--ink-soft);
  margin: 0;
}

/* A row of controls that wraps as a unit — filters, inline create forms. */
.form-row {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-row > * { flex: 0 1 auto; }
/* Fields carrying hints of different lengths: align their labels, not their
   bottom edges, or the two columns of a settings form start at different
   heights. */
.form-row.top { align-items: flex-start; }
.form-row .grow { flex: 1 1 200px; min-width: 160px; }
.form-row .field { margin-bottom: 0; }

/* Filter bar: a toolbar strip rather than a full card, so filters read as
   controls attached to the table beneath rather than as content. */
.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.1rem;
}
.filters .form-row { gap: 0.75rem 0.9rem; }
.filters label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.filters select, .filters input { min-width: 130px; }
.filters .filter-actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: flex-end; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--brand-600);
  color: #fff;
  border: 1px solid var(--brand-600);
  padding: 0.44rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.855rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 15px; height: 15px; }

.btn.secondary {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--line-strong);
}
.btn.secondary:hover { background: var(--surface-hover); color: var(--ink); border-color: var(--muted-soft); }

.btn.quiet {
  background: var(--surface);
  color: var(--brand-700);
  border-color: var(--line-strong);
}
.btn.quiet:hover { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }

.btn.danger { background: #dc2626; border-color: #dc2626; }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
  padding: 0.3rem 0.5rem;
}
.btn.ghost:hover { background: var(--surface-hover); color: var(--ink); }

.btn.sm { padding: 0.28rem 0.6rem; font-size: 0.79rem; }

.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-group { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

/* Segmented filter (the amendment status switcher). */
.segmented {
  display: inline-flex;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}
.segmented a {
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
}
.segmented a:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.segmented a.current { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-xs); }

form.inline { display: inline; }

/* ------------------------------------------------------------------ status */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.73rem;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  flex: 0 0 auto;
}
.badge.plain::before { display: none; }

.badge.high, .badge.approved, .badge.ok, .badge.active {
  background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line);
}
.badge.medium, .badge.pending, .badge.submitted, .badge.under_review, .badge.warn {
  background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line);
}
.badge.low, .badge.rejected, .badge.bad {
  background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-line);
}
.badge.inferred, .badge.amended, .badge.info {
  background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line);
}
.badge.neutral {
  background: var(--surface-sunken); color: var(--muted); border-color: var(--line);
}

/* Flash + callouts ------------------------------------------------------- */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.885rem;
  border: 1px solid transparent;
  box-shadow: var(--shadow-xs);
}
.flash svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.flash .flash-body { min-width: 0; word-break: break-word; }
.flash .flash-body code { background: rgba(255, 255, 255, 0.6); border-color: rgba(0, 0, 0, 0.06); }
.flash.notice { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line); }
.flash.alert { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-line); }
.flash a { color: inherit; text-decoration: underline; }

.callout {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: #fffbeb;
  border: 1px solid var(--warn-line);
  color: #854d0e;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1.1rem;
}
.callout svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; color: #b45309; }
.callout > div > :first-child { margin-top: 0; }
.callout > div > :last-child { margin-bottom: 0; }
.callout a { color: #7c2d12; }

/* An explanatory aside — the "why this number means what it means" prose
   this panel leans on. Quieter than a callout, still visibly set apart. */
.note {
  background: var(--surface-sunken);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.1rem;
}
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.note strong { color: var(--ink-soft); }

/* ------------------------------------------------------------------- stats */

.grid, .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

/* Legacy .grid > .card pairing keeps working; .stat-card is the new one. */
.stat { font-size: 1.75rem; font-weight: 680; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.83rem; margin-top: 0.2rem; }

.stat-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 0.95rem 1.05rem;
  color: inherit;
  position: relative;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
a.stat-card:hover {
  text-decoration: none;
  border-color: var(--brand-200);
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-key {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.045em;
}
.stat-card .stat-key svg { width: 14px; height: 14px; color: var(--muted-soft); }
.stat-card .stat-value {
  font-size: 1.7rem;
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-foot { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

.stat-card.is-ok .stat-value { color: var(--ok-fg); }
.stat-card.is-warn .stat-value { color: var(--warn-fg); }
.stat-card.is-bad .stat-value { color: var(--bad-fg); }
.stat-card.is-idle .stat-value { color: var(--muted-soft); }

a.stat-card .stat-key::after {
  content: "→";
  margin-left: auto;
  color: var(--muted-soft);
  font-size: 0.85rem;
  transition: transform 0.12s ease, color 0.12s ease;
}
a.stat-card:hover .stat-key::after { color: var(--brand-600); transform: translateX(2px); }

/* Attention list — the dashboard's "what needs a human today" rail. */
.attention { display: grid; gap: 0.6rem; }
.attention-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
}
.attention-item:hover { text-decoration: none; border-color: var(--brand-200); background: var(--brand-50); }
.attention-item .att-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.attention-item .att-icon svg { width: 16px; height: 16px; }
.attention-item .att-icon.bad { background: var(--bad-bg); color: var(--bad-fg); }
.attention-item .att-icon.warn { background: var(--warn-bg); color: var(--warn-fg); }
.attention-item .att-icon.info { background: var(--info-bg); color: var(--info-fg); }
.attention-item .att-text { min-width: 0; }
.attention-item .att-title { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.attention-item .att-sub { font-size: 0.79rem; color: var(--muted); }
.attention-item .att-count {
  margin-left: auto;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Horizontal bar used in the deviation breakdown. */
.bar-track {
  height: 6px;
  background: var(--surface-hover);
  border-radius: var(--radius-pill);
  overflow: hidden;
  min-width: 90px;
}
.bar-fill { height: 100%; background: var(--brand-500); border-radius: var(--radius-pill); }

/* ------------------------------------------------------------ empty states */

.empty {
  text-align: center;
  padding: 2.25rem 1.25rem;
  color: var(--muted);
}
.empty .empty-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--muted-soft);
  display: grid; place-items: center;
  margin: 0 auto 0.7rem;
}
.empty .empty-icon svg { width: 20px; height: 20px; }
.empty .empty-title { font-weight: 600; color: var(--ink-soft); font-size: 0.92rem; }
.empty .empty-body { font-size: 0.85rem; margin-top: 0.25rem; max-width: 46ch; margin-inline: auto; }
.empty .empty-actions { margin-top: 0.9rem; }
td .empty { padding: 1.9rem 1rem; }

/* --------------------------------------------------------------- utilities */

.muted { color: var(--muted); font-size: 0.85rem; }
.muted a { color: var(--muted); text-decoration: underline; }
.small { font-size: 0.8rem; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }

/* Sign-in — the one page rendered outside the shell. */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(1100px 480px at 50% -10%, var(--brand-50), transparent 70%),
    var(--canvas);
}
.auth-box { width: 100%; max-width: 380px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; margin-bottom: 1.35rem; }
.auth-brand .brand-mark { width: 42px; height: 42px; border-radius: 11px; }
.auth-brand .brand-mark svg { width: 24px; height: 24px; }
.auth-brand .auth-title { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.015em; }
.auth-brand .auth-sub { font-size: 0.85rem; color: var(--muted); }
.auth .card { padding: 1.4rem 1.4rem 1.5rem; box-shadow: var(--shadow-md); }
.auth .btn { width: 100%; margin-top: 0.35rem; }
.auth-foot { text-align: center; margin-top: 1rem; font-size: 0.8rem; color: var(--muted-soft); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  #nav-toggle:checked ~ .sidebar { transform: translateX(0); }
  #nav-toggle:checked ~ .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 35;
  }
  .content { margin-left: 0; }
  .nav-burger { display: inline-flex; }
  main { padding: 1.25rem 1rem 3rem; }
  .topbar { padding: 0 1rem; }
  .topbar-user { display: none; }
  .filters .filter-actions { margin-left: 0; width: 100%; }
}

@media (max-width: 560px) {
  .page-head { gap: 0.75rem; }
  h1, .page-title { font-size: 1.28rem; }
  .grid, .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; }
  .card { padding: 1rem; }
  .card-head, .card-body { padding: 0.9rem 1rem; }
  .card.flush thead th:first-child, .card.flush tbody td:first-child { padding-left: 1rem; }
  .card.flush thead th:last-child, .card.flush tbody td:last-child { padding-right: 1rem; }
}

/* ------------------------------------------------------------------- print */

@media print {
  .sidebar, .topbar, .nav-burger, .nav-scrim, .filters, .page-actions, .btn { display: none !important; }
  .content { margin-left: 0; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; border-color: #cbd5e1; }
  thead th { background: #fff; }
  a { color: inherit; text-decoration: none; }
}
