/* Entity Solutions portal — editorial-operational.
   Four faces, each with one job:
     Archivo          headings and page titles (engineered grotesque, tight)
     Inter            dense UI: tables, forms, metrics, controls
     (serif retired 2026-10-02 — one face everywhere, the invoices/credentials standard)
     JetBrains Mono   eyebrows, labels, and every figure that lines up in a column
   Ground stays slate; the accent is a quieter teal than the old neon, so colour
   marks meaning rather than decorating. Fonts are loaded per page via <link>;
   do not @import here (it blocks render). */

:root {
  --bg:           #1e2126;   /* deeper ground: cards now separate from it clearly */
  --bg-2:         #24272d;
  --surface:      #272b31;
  --surface-2:    #2f333a;
  --border:       rgba(255,255,255,0.05);
  --border-2:     rgba(255,255,255,0.09);
  --border-3:     rgba(255,255,255,0.15);

  --text:         #dadce0;
  --text-2:       #aaadb4;
  --muted:        #a7abb2;  /* AA: ~5:1 on --surface/--bg (was #82858e ~3.2:1) */
  --faint:        #a0a4ad;  /* AA-ish tertiary text (was #5d6068 ~1.9:1) */

  /* Quieter than the old #2dd4bf neon: the accent should read as considered,
     not as a highlighter. Same teal identity, lower energy. */
  --accent:       #4ec5b3;
  --accent-hi:    #7ad9cb;
  --accent-soft:  rgba(78,197,179,0.10);
  --accent-line:  rgba(78,197,179,0.24);

  --warn:         #fbbf24;
  --danger:       #f87171;
  --ok:           #34d399;
  --info:         #5ea0f2;  /* was self-referential var(--info) → unset in dark */

  /* Soft fills + hairline borders for status chips/tags — defined per-theme so
     they flip correctly in light mode (mirrors the --accent-soft/--accent-line pattern). */
  --ok-soft:      rgba(52,211,153,0.14);
  --warn-soft:    rgba(251,191,36,0.14);
  --danger-soft:  rgba(248,113,113,0.14);
  --info-soft:    rgba(96,165,250,0.14);
  --ok-line:      rgba(52,211,153,0.25);
  --warn-line:    rgba(251,191,36,0.25);
  --danger-line:  rgba(248,113,113,0.25);
  --info-line:    rgba(96,165,250,0.25);

  /* Type SCALE. Before this the sheet used twelve ad-hoc sizes and pages invented
     another fourteen, including near-duplicates (12 vs 12.5, 11 vs 11.5) that read
     as sloppiness rather than hierarchy. Six steps cover the whole product. */
  --fs-3xl:  31px;   /* page title */
  --fs-2xl:  27px;   /* metric value */
  --fs-xl:   17px;   /* card / section title */
  --fs-lg:   15px;   /* prose */
  --fs-md:   13px;   /* body, table cell, control */
  --fs-sm:   12px;   /* secondary, card meta */
  --fs-xs:   11px;   /* caption */
  --fs-2xs:  10px;   /* mono eyebrow, micro-label */

  /* type roles */
  --font-ui:      'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: 'Archivo', 'Inter', ui-sans-serif, system-ui, sans-serif;
  /* Owner decision 2026-10-02: ONE face everywhere (the credentials-page
     standard). The prose token now resolves to the UI stack so every
     .prose/.callout/empty-state consumer follows in lockstep; serif is
     retired from the portal. */
  --font-prose:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Row/list hover. NOT --surface: a card already paints --surface, so a hover
     of the same value is invisible. A translucent lift works on card and ground
     alike, in both themes. */
  --hover:        rgba(255,255,255,0.05);
  /* Selection needs a real fill; the 9% --accent-soft tuned for panels is far
     too weak to read as a highlight. */
  --select:       rgba(78,197,179,0.30);

  --radius:       12px;
  --radius-sm:    8px;
  --transition:      140ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 100ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Backward-compat for inline styles on existing pages */
  --es-primary:        var(--accent);
  --es-primary-hover:  var(--accent-hi);
  --es-primary-dim:    var(--accent-soft);
  --es-primary-border: var(--accent-line);
  --es-bg:             var(--bg);
  --es-surface:        var(--surface);
  --es-surface-2:      var(--surface-2);
  --es-border:         var(--border-2);
  --es-border-strong:  var(--border-3);
  --es-text:           var(--text);
  --es-text-muted:     var(--muted);
  --es-text-faint:     var(--faint);
  --es-success:        var(--ok);
  --es-warning:        var(--warn);
  --es-danger:         var(--danger);
  --es-info:           var(--info);
  --es-radius:         var(--radius-sm);
  --es-radius-lg:      var(--radius);
  --es-shadow:         none;
  --es-shadow-md:      none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
/* Guard against any one element punching past the viewport and forcing
   Safari to zoom-fit (which then leaves the user pinch-zooming back in).
   Anything that legitimately scrolls horizontally (a wide table, an SVG)
   should opt in with its own container, not the page root. */
html, body { max-width: 100%; overflow-x: hidden; }
html { color-scheme: dark; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

a { color: var(--text); text-decoration: none; }
::selection { background: var(--select); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.017em;
  color: var(--text);
  margin: 0;
  text-wrap: balance;
}

/* ---------------- Layout ---------------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 12px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg);
}

/* The nav scrolls inside the fixed-height sidebar. Without this, a long nav
   (the staff menu is ~27 rows: Overview + Customers + Billing + Operations)
   overflows past 100vh and the bottom items (Backups, Network backups,
   Tickets, Documents, Runbooks, API docs) are clipped and unreachable —
   especially in the fixed-height mobile drawer. flex:1 + min-height:0 lets it
   take the space between the brand row and the footer and scroll on its own. */
#sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
/* Desktop: keep the nav scrollable (a long menu must never clip) but HIDE the
   scrollbar chrome — a persistent scrollbar in the sidebar looks wrong on a
   desktop. Wheel/trackpad scrolling still works. The mobile drawer (≤768px)
   keeps its native (transient) scrollbar. */
@media (min-width: 769px) {
  #sidebar-nav { scrollbar-width: none; -ms-overflow-style: none; }
  #sidebar-nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 28px;
  font-weight: 600;
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
  color: var(--text);
  /* The brand row can hold an identity badge (Staff: Name + × signout). At the
     232px desktop sidebar width the badge has no room beside the wordmark, so
     allow wrap and force the badge onto its own line below. min-width: 0 keeps
     the wordmark truncating with ellipsis rather than line-breaking word-by-word. */
  flex-wrap: wrap;
  min-width: 0;
}
.sidebar .brand > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}
.sidebar .identity-badge-slot {
  /* Force onto its own row inside the wrapped flex container */
  flex: 1 0 100%;
  margin-left: 0 !important;
  margin-top: 6px;
  min-width: 0;
}
.sidebar .identity-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Hide the logged-in identity pill ("Staff: <name>" / customer name) in the
   sidebar brand row — it's clutter (and the Authentik default name reads oddly).
   Keep the anonymous "Sign in" affordance. :has() collapses the whole slot so
   there's no empty gap below the wordmark. */
.sidebar .identity-badge-slot:has(.identity-badge.staff),
.sidebar .identity-badge-slot:has(.identity-badge.customer) { display: none; }
.brand-mark {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: -0.02em;
}

/* Section header doubles as the collapse toggle. Kept visually identical to the
   old static label so the sidebar doesn't suddenly read as a row of buttons. */
.nav-section {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%;
  margin: 16px 0 4px;
  padding: 4px 8px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0.01em;
  background: none; border: 0; border-radius: 6px;
  font-family: inherit; text-align: left; cursor: pointer;
  /* Comfortable touch target on mobile without changing the desktop look. */
  min-height: 32px;
}
.nav-section:hover { color: var(--text-2); background: var(--surface); }
.nav-section:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-group:first-child > .nav-section { margin-top: 0; }

.nav-caret { display: inline-flex; width: 14px; height: 14px; flex-shrink: 0; transition: transform .15s ease; }
.nav-caret svg { width: 14px; height: 14px; }
.nav-caret { transition: transform .22s ease; }
.nav-group.open > .nav-section .nav-caret { transform: rotate(180deg); }

/* Collapsing hides links from the sidebar only — every page stays reachable by
   URL and through the ⌘K palette, which has its own index and never reads the
   sidebar DOM. */
/* Smooth expand/collapse: the 0fr -> 1fr grid transition animates to the
   content's real height with no JS measurement. The single inner wrapper is what
   makes 0fr collapse fully (it needs min-height:0 + overflow:hidden). display:none
   would kill the animation, so closed groups hide via the collapsed row instead. */
.nav-group-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; }
.nav-group.open > .nav-group-items { grid-template-rows: 1fr; }
.nav-group-inner { min-height: 0; overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .nav-group-items { transition: none; }
  .nav-caret { transition: none; }
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: var(--fs-md);
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.nav-icon svg { width: 16px; height: 16px; }
.nav-badge {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
}
.nav-badge.warn {
  color: var(--warn);
  background: var(--warn-soft);
  padding: 0 6px;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 6px 0;
  border-top: 1px solid var(--border);
}
.contact-card { padding: 4px 4px 0; }
.contact-card-name { font-size: var(--fs-sm); color: var(--text); font-weight: 500; }
.contact-card-role { font-size: var(--fs-xs); color: var(--muted); margin: 1px 0 8px; }
.contact-card-meta { font-size: var(--fs-xs); color: var(--muted); line-height: 1.7; }
.contact-card-meta a { color: var(--text-2); }
.contact-card-meta a:hover { color: var(--accent); }

/* ---------------- Main ---------------- */
.main {
  padding: 48px 56px 80px;
  max-width: 1100px;
  width: 100%;
}
.page-header {
  margin-bottom: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}
.page-title {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.12;
  color: var(--text);
  margin: 0;
  text-wrap: balance;
}
.page-subtitle {
  color: var(--muted);
  font-size: var(--fs-md);
  margin: 7px 0 0;
  max-width: 78ch;
}
.page-eyebrow, .eyebrow {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 400;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  margin: 0 0 9px;
}

.quick-actions .tile-card {
  display: block;
  text-decoration: none;
}
.quick-actions .tile-icon { margin-bottom: 10px; }

.advanced-link {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  color: var(--text-2);
  font-size: var(--fs-md);
  text-decoration: none;
  transition: 0.12s;
}
.advanced-link:hover { background: var(--surface); color: var(--text); border-color: var(--border-3); }
.advanced-icon {
  flex-shrink: 0;
  color: var(--muted);
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.advanced-icon svg { width: 14px; height: 14px; }
.advanced-link:hover .advanced-icon { color: var(--accent); }
.advanced-link strong { color: var(--text); font-weight: 500; }

/* Visually hidden but available to assistive tech */
.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-to-main-content — invisible until keyboard-focused */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg);   /* 7.7:1 dark, 5.6:1 Daylight — #0a0a0a failed on pine */
  font-weight: 600;
  border-radius: 0 0 8px 0;
  z-index: 9999;
  text-decoration: none;
}
.skip-link:focus { left: 0; outline: 2px solid var(--accent-hi); outline-offset: 2px; }
@keyframes live-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Stale data warning — orange chip, no pulse (deliberate: pulsing on stale
   feels like fresh activity; we want it to read as "needs attention"). */
.stale-tag {
  display: inline-block;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-line);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
  text-transform: uppercase;
}

/* Mock data tag — only rendered when ?preview=1 is on the URL, so it's never
   shown to real customers. Muted on purpose. */
.mock-tag {
  display: inline-block;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-2);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
}

/* ---------------- Cards / metrics ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.card-meta {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Metric strip — flat row of numbers, no cards */
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 40px;
}
.metric {
  padding: 22px 24px;
  border-right: 1px solid var(--border-2);
}
.metric:last-child { border-right: 0; }
.metric-label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.metric-value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.08;
}
.metric-delta {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: 6px;
}
.metric-delta.up { color: var(--ok); }
.metric-delta.down { color: var(--danger); }

/* (.kpi-grid removed — no page uses it any more) */

/* ---------------- Status indicators ---------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--fs-xs);
  font-weight: 500;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-3);
}
.pill.ok      { color: var(--ok);      border-color: var(--ok-line);     background: var(--ok-soft); }
.pill.warn    { color: var(--warn);    border-color: var(--warn-line);   background: var(--warn-soft); }
.pill.danger  { color: var(--danger);  border-color: var(--danger-line); background: var(--danger-soft); }
.pill.info    { color: var(--info);    border-color: var(--info-line);   background: var(--info-soft); }
.pill.primary { color: var(--accent);  border-color: var(--accent-line); background: var(--accent-soft); }
.pill.sm      { font-size: var(--fs-2xs); }
.pill.primary { color: var(--accent);  border-color: var(--accent-line); }
.pill .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* status dot — tiny indicator next to status text, no border */
.status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 8px;
  vertical-align: middle;
}
.status-dot.warn { background: var(--warn); }
.status-dot.danger { background: var(--danger); }

/* ---------------- Tables ---------------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 14px 16px;
  font-size: var(--fs-md);
  color: var(--text-2);
}
.table th {
  font-family: var(--font-mono);
  color: var(--muted);
  font-weight: 400;
  font-size: var(--fs-2xs);
  border-bottom: 1px solid var(--border-2);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* Figures that sit in a column line up; the mono face makes the alignment
   deliberate rather than accidental. */
.table td { font-variant-numeric: tabular-nums; }
.table td { border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--hover); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 7px;
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: 0.12s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover { background: #fff; border-color: #fff; }
.btn-secondary {
  background: transparent;
  border-color: var(--border-3);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface); border-color: var(--border-3); }
.btn-ghost { background: transparent; color: var(--muted); border: 0; padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: var(--fs-sm); }
/* Disabled buttons are inert — dimmed, no hover state, no pointer cursor. Covers
   terminal states like "Sent"/"Saved" and mid-request "Sending…" spinners. */
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: default; pointer-events: none; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 8px 11px;
  font: inherit;
  color: var(--text);
  outline: none;
  transition: 0.12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input:disabled, .field select:disabled, .field textarea:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

/* ---------------- Section headers ---------------- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 56px 0 16px;
}
.section-header:first-of-type { margin-top: 0; }
.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.012em;
  text-transform: none;
}
.section-link {
  font-size: var(--fs-md);
  color: var(--muted);
  font-weight: 500;
}
.section-link:hover { color: var(--text); }

/* ---------------- Alert / banner ---------------- */
.alert {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  border: 1px solid var(--border-2);
  background: var(--surface);
}
.alert-icon {
  flex-shrink: 0;
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--accent);
}
.alert.warn .alert-icon { background: var(--warn); }
.alert.danger .alert-icon { background: var(--danger); }
.alert.success .alert-icon { background: var(--ok); }
.alert-title { font-weight: 500; font-size: var(--fs-md); margin: 0 0 4px; color: var(--text); }
.alert-body { font-size: var(--fs-sm); color: var(--muted); margin: 0; line-height: 1.55; }
.alert-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ---------------- Activity list ---------------- */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex; gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.activity-item:first-child { padding-top: 0; }
.activity-item:last-child { border-bottom: 0; padding-bottom: 0; }
.activity-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.activity-icon svg { width: 14px; height: 14px; }
.activity-icon.ok   { color: var(--ok); }
.activity-icon.warn { color: var(--warn); }
.activity-icon.info { color: var(--info); }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: var(--fs-md); font-weight: 400; margin: 0; color: var(--text-2); line-height: 1.5; }
.activity-title strong { font-weight: 500; color: var(--text); }
.activity-meta { font-size: var(--fs-sm); color: var(--muted); margin: 2px 0 0; }
.activity-meta a { color: var(--text-2); }

/* ---------------- Tile (catalog) ---------------- */
.tile-card {
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.tile-card:hover { border-color: var(--border-3); background: var(--surface); }
.tile-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-md);
  margin-bottom: 14px;
}
.tile-icon svg { width: 16px; height: 16px; }
.tile-card:hover .tile-icon { color: var(--accent); }
.tile-title { font-weight: 500; font-size: var(--fs-md); margin: 0 0 4px; color: var(--text); }
.tile-desc { font-size: var(--fs-sm); color: var(--muted); margin: 0; line-height: 1.5; }

/* ---------------- Mobile ---------------- */
.hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--border-3);
  width: 36px; height: 36px;
  border-radius: 7px;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  align-items: center;
  justify-content: center;
}
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  /* Use safe-area insets so the topbar can extend into the iPhone's edge
     padding without leaving an unstyled strip on rounded-corner devices. */
  padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  align-items: center;
  gap: 10px;
  /* Without min-width: 0, flex children refuse to shrink past their
     intrinsic content width, which makes a long staff identity badge push
     the brand text into a two-line wrap. */
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.mobile-topbar .brand {
  padding: 0;
  font-size: var(--fs-md);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.mobile-topbar .brand > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-topbar .topbar-id-slot {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}
.mobile-topbar .identity-badge {
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) {
  .mobile-topbar .identity-badge .identity-prefix { display: none; }
  .mobile-topbar .identity-badge { max-width: 30vw; }
  .mobile-topbar .brand > span { display: none; }
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 1024px) {
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(1), .metric:nth-child(2) { border-bottom: 1px solid var(--border-2); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .mobile-topbar { display: flex; }
  .hamburger { display: inline-flex; min-width: 40px; min-height: 40px; }
  /* Touch targets: 40px is the threshold, and these were under it — 36px for
     small buttons, 30px for filter chips. The base .btn had no mobile rule at
     all (~36px), which covers every primary action in the portal: Pay now,
     Accept quote, Submit request, Order now, Restart server. */
  .btn { min-height: 40px; }
  .btn-sm, .btn-ghost { min-height: 40px; padding-top: 9px; padding-bottom: 9px; }
  .nav-item { padding: 10px 8px; min-height: 40px; }
  .chip { padding: 8px 12px; min-height: 40px; }
  /* Bare checkboxes are ~16px and are the primary interaction on the onboarding
     checklist, the agreement sign-off and the notification matrix. */
  input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }
  /* iOS Safari auto-zooms on focus for any input under 16px, leaving the user
     zoomed in and scrolled sideways with no way back. !important is load-bearing:
     27 page-local `.field input` rules (0,2,1) out-specify this bare selector,
     including every login and auth form, so without it the zoom still fires. */
  input, select, textarea { font-size: 16px !important; }
  .activity-item { padding: 16px 0; }
  .table th, .table td { padding: 12px 14px; }

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    /* Wider so brand + nav labels never crowd, but capped so the backdrop
       strip on the right is still tap-able to close the drawer. */
    width: min(86vw, 320px);
    z-index: 50;
    transform: translateX(-100%);
    /* visibility (not just transform) so the CLOSED drawer leaves the tab order.
       Translated off-screen alone, Tab from the hamburger walked all ~50 nav
       links, the theme toggle and sign-out with no visible focus ring anywhere
       on screen. `visibility` is transitionable, so the slide still animates. */
    visibility: hidden;
    transition: transform 0.18s ease, visibility 0.18s;
    box-shadow: 8px 0 32px rgba(0,0,0,0.6);
  }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  /* The identity badge lives in the mobile topbar on phones — the sidebar
     brand row would duplicate it and push the "Entity Solutions" wordmark
     into a two-line wrap. Hide here. */
  .sidebar .identity-badge-slot { display: none !important; }
  .sidebar .brand { padding-bottom: 18px; }
  .sidebar .brand > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .main { padding: 24px 14px 60px; max-width: 100%; min-width: 0; overflow-x: hidden; }
  /* iPhone safe areas: respect the home-indicator and edge insets so content
     isn't tucked under the rounded corners or the bottom bar. */
  .main { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: max(60px, env(safe-area-inset-bottom)); }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 28px;
  }
  .page-header > div:last-child { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
  .page-header .btn { flex: 1; justify-content: center; }
  .page-title { font-size: var(--fs-2xl); }

  .metric-strip {
    grid-template-columns: 1fr;
  }
  .metric { border-right: 0; border-bottom: 1px solid var(--border-2); }
  .metric:last-child { border-bottom: 0; }

  .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 10px; }

  .card { padding: 18px; overflow-x: auto; }
  .table { min-width: 480px; }

  .alert { flex-direction: row; }
  .alert-actions { flex-wrap: wrap; }
  .alert-actions .btn { flex: 1; }

  .field-row { grid-template-columns: 1fr; }
  .section-header { margin: 40px 0 14px; }
}

/* Demo banner (kept small + unobtrusive) */
.demo-banner {
  background: var(--bg);
  color: var(--muted);
  padding: 8px 16px;
  font-size: var(--fs-xs);
  font-weight: 400;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.demo-banner a { color: var(--text-2); }

/* (legacy glow-bg / text-eyebrow / text-gradient classes removed — no page uses them) */

/* ============================================================
   Portal.js shell — toasts, modals, drawers, search, theme
   ============================================================ */

/* Theme: light mode override via :root[data-theme="light"] */
:root[data-theme="light"] {
  color-scheme: light;
  /* "Daylight" — the light mode is DESIGNED, not an inversion of the dark one.
     Cool paper ground with white cards, so a card lifts off the page the same
     way it separates from the deep ground in dark mode. Every pair below was
     contrast-checked against its real background: the lowest is muted-on-paper
     at 4.71:1, so all body and label text clears WCAG AA. */
  --bg:           #eef1f3;   /* cool paper */
  --bg-2:         #e7ebee;   /* strips and inset rows */
  --surface:      #ffffff;   /* cards lift */
  --surface-2:    #f6f8f9;
  --border:       rgba(22,26,31,0.08);
  --border-2:     rgba(22,26,31,0.12);
  --border-3:     rgba(22,26,31,0.20);
  --text:         #161a1f;   /* 15.4:1 on paper */
  --text-2:       #3d454e;   /* 8.6:1 */
  --muted:        #626c77;   /* 4.7:1 on paper, 5.3:1 on card */
  --faint:        #5f6873;   /* 4.98:1 on PAPER, 5.65:1 on card — .unit and
                                .nav-section sit on the ground, not on a card */
  --hover:        rgba(22,26,31,0.05);
  --select:       rgba(31,107,98,0.22);
  /* Deep pine: the dark mode's teal identity, dropped in value and saturation
     until it holds AA on white without shouting. */
  --accent:       #1f6b62;
  --accent-hi:    #17534c;
  --accent-soft:  rgba(31,107,98,0.09);
  --accent-line:  rgba(31,107,98,0.26);
  --warn:         #8a5a12;
  --danger:       #a33a32;
  --ok:           #1d7a53;
  --info:         #1d4ed8;
  --ok-soft:      rgba(29,122,83,0.10);
  --warn-soft:    rgba(138,90,18,0.10);
  --danger-soft:  rgba(163,58,50,0.10);
  --info-soft:    rgba(29,78,216,0.09);
  --ok-line:      rgba(29,122,83,0.28);
  --warn-line:    rgba(138,90,18,0.28);
  --danger-line:  rgba(163,58,50,0.28);
  --info-line:    rgba(29,78,216,0.26);
}
/* Daylight's primary action is the pine accent, not the old near-black slab:
   a black button on cool paper reads as a different product's control. */
:root[data-theme="light"] .btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
:root[data-theme="light"] .btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }

/* Sidebar actions (search trigger + notifications). Visually matches
   .nav-item so the sidebar reads as one consistent column instead of a
   stack of inset boxes followed by nav rows. */
.sidebar-actions {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.sidebar-action:hover { background: var(--surface); color: var(--text); }
.sidebar-action-icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.sidebar-action-icon svg { width: 14px; height: 14px; }
.sidebar-action:hover .sidebar-action-icon { color: var(--text); }
.sidebar-action .kbd-hint {
  margin-left: auto;
  font-size: var(--fs-2xs);
  color: var(--muted);
  letter-spacing: 0.04em;
  opacity: 0.7;
}

/* Mobile topbar search button */
.topbar-search {
  background: transparent;
  border: 1px solid var(--border-3);
  width: 36px; height: 36px;
  border-radius: 7px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.topbar-search svg { width: 16px; height: 16px; }

/* Theme toggle + sign-out (sidebar footer cluster). Visually paired so the
   two account/session controls read as one group instead of competing. */
.theme-toggle,
.footer-signout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  text-align: left;
  margin-bottom: 6px;
}
.theme-toggle:hover,
.footer-signout:hover { background: var(--surface); color: var(--text); }
.theme-toggle:focus-visible,
.footer-signout:focus-visible {
  /* Was `outline: none` + a --accent-line ring, which composites to ~1.6:1 in
     dark and ~1.4:1 in light — an invisible focus indicator. The global
     :focus-visible outline is already correct, so just don't suppress it. */
  box-shadow: 0 0 0 2px var(--accent-line);
}
.theme-toggle-icon svg,
.footer-signout-icon svg { width: 14px; height: 14px; }
.footer-signout-icon { display: inline-flex; }


/* Toasts */
.toast-host {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.3);
  font-size: var(--fs-md);
  color: var(--text);
  min-width: 240px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
}
.toast.toast-in  { opacity: 1; transform: translateY(0); }
.toast.toast-out { opacity: 0; transform: translateY(8px); }
.toast-icon { color: var(--muted); flex-shrink: 0; padding-top: 1px; }
.toast-icon svg { width: 16px; height: 16px; }
.toast-ok      .toast-icon { color: var(--ok); }
.toast-warn    .toast-icon { color: var(--warn); }
.toast-danger  .toast-icon { color: var(--danger); }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--faint);
  padding: 0;
  margin-left: 8px;
}
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 14px; height: 14px; }
@media (max-width: 640px) {
  .toast-host { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}

/* Overlay (used by modal, drawer, search) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s;
}
.overlay.overlay-in { opacity: 1; }
.overlay-drawer { justify-content: flex-end; }
.overlay-search { align-items: flex-start; padding-top: 12vh; }

/* Modal */
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}
.modal-header, .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}
.modal-header h3, .drawer-header h3 {
  font-size: var(--fs-lg);
  margin: 0;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body, .drawer-body {
  padding: 14px 20px 20px;
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: 1.55;
}
.modal-footer, .drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-2);
  background: var(--bg-2);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
/* Token-driven so Daylight does not jump to a 2.9:1 salmon on the one
   button where the user most needs to read the label. */
.btn-danger:hover { filter: brightness(1.12); }

/* Drawer (right-side panel) */
.drawer {
  background: var(--surface);
  border-left: 1px solid var(--border-2);
  width: min(520px, 100vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 40px rgba(0,0,0,0.4);
  transform: translateX(16px);
  transition: transform 0.22s ease;
}
.overlay-in .drawer { transform: translateX(0); }
.drawer-header { padding: 22px 24px 16px; border-bottom: 1px solid var(--border-2); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 24px 24px; }
.drawer-footer { border-top: 1px solid var(--border-2); padding: 14px 24px; background: var(--bg-2); }

/* Search modal */
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  width: min(580px, calc(100vw - 32px));
  box-shadow: 0 32px 80px rgba(0,0,0,0.55);
  overflow: hidden;
  transform: translateY(-10px);
  transition: transform 0.18s;
}
.overlay-in .search-panel { transform: translateY(0); }
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-2);
}
.search-icon { color: var(--muted); display: flex; }
.search-icon svg { width: 16px; height: 16px; }
.search-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-lg);
}
.search-input::placeholder { color: var(--faint); }
.search-kbd {
  font-size: var(--fs-2xs);
  color: var(--faint);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-2);
  font-family: var(--font-mono);
}
.search-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 360px;
  overflow-y: auto;
}
.search-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 18px;
  cursor: pointer;
  color: var(--text-2);
}
.search-item.active { background: var(--surface-2); color: var(--text); }
.search-item-icon { color: var(--muted); display: flex; }
.search-item-icon svg { width: 14px; height: 14px; }
.search-item.active .search-item-icon { color: var(--accent); }
.search-item-title { font-size: var(--fs-md); font-weight: 500; }
.search-item-desc { font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.search-empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: var(--fs-md); list-style: none; }
.search-foot {
  border-top: 1px solid var(--border-2);
  padding: 8px 18px;
  font-size: var(--fs-xs);
  color: var(--faint);
  display: flex;
  gap: 18px;
}
.search-foot kbd {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-2);
  margin-right: 4px;
}
@media (max-width: 640px) {
  .search-item-desc { display: none; }
  .overlay-search { padding-top: 6vh; }
}

/* Form helpers reused by many features */
.muted-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s linear infinite;
  border-radius: 6px;
  height: 14px;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Empty state */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-icon { color: var(--faint); margin-bottom: 12px; display: inline-flex; }
.empty-icon svg { width: 28px; height: 28px; }
.empty-title { color: var(--text); font-size: var(--fs-lg); font-weight: 500; margin: 0 0 4px; }
.empty-body { font-size: var(--fs-md); margin: 0; }
/* Bounded empty-state panel (vs the bare centered .empty) — for in-section states. */
.empty-card { border: 1px solid var(--border-2); border-radius: var(--radius); background: transparent; }

/* ---------------- Shared utilities (promoted from per-page inline styles) ---------------- */
/* Card header row: title + optional action. */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.card-head h2 { font-size: var(--fs-lg); margin: 0; }
/* One muted caption size across the portal (was 11/12/12.5/13px inline). */
.note { font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; margin-top: 10px; }
.amount  { text-align: right; font-variant-numeric: tabular-nums; }
/* Inline staff context banner (was inline rgba(56,189,248,…) hex across staff pages). */
.staff-banner { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text-2); border-radius: var(--radius-sm); padding: 8px 14px; font-size: var(--fs-sm); margin-bottom: 16px; }

/* a11y focus rings */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:focus-visible { outline-offset: 1px; }
.nav-item:focus-visible { outline-offset: -2px; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* Table row hover on tickets — feels clickable */
.table tr[role="button"], .table tr.clickable { cursor: pointer; }
.table tr[role="button"]:hover td, .table tr.clickable:hover td { background: var(--hover); }

/* Mobile drawer takes full width */
@media (max-width: 640px) {
  .drawer { width: 100vw; border-left: 0; }
  .modal { width: calc(100vw - 24px); }
  .modal-header, .drawer-header { padding: 16px; }
  .modal-body, .drawer-body { padding: 12px 16px 18px; }
  .modal-footer, .drawer-footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal-footer .btn, .drawer-footer .btn { flex: 1; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .overlay, .toast, .search-panel, .drawer, .sidebar { transition: none !important; }
  .skeleton { animation: none; background: var(--surface-2); }
}

/* ============================================================
   Round 2 additions
   ============================================================ */

/* Notifications. Compact pill — small enough to feel like a count, not a
   screaming alert. Red is fine for "unread" semantics but the badge stays
   subordinate to the nav text. */
.notif-badge {
  margin-left: auto;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--fs-2xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  letter-spacing: 0;
}
/* The class above has higher specificity than the UA stylesheet's
   `[hidden] { display: none }`, so the hidden attribute was ignored and an
   empty pill was rendering as a tiny red dot even with 0 unread. Re-honor it. */
.notif-badge[hidden] { display: none; }

/* GLOBAL [hidden] guard. Any class that sets `display:` (e.g. .btn's inline-flex,
   .source-tag, .imp-tag, .overall-banner, .forbidden-badge) out-specifies the UA
   `[hidden]{display:none}` rule, so elements meant to be hidden were rendering
   anyway (hidden buttons/badges/banners showing). This enforces the hidden
   attribute globally. Safe: audited — no element in the portal shows via inline
   style.display while carrying `hidden`, so !important never fights a real show
   (JS reveals with `el.hidden = false`, which removes the attribute). */
[hidden] { display: none !important; }

/* ES.searchableSelect — typeahead combobox that replaces a plain <select> so a
   staffer can filter 100+ clients by typing instead of scrolling. Palette-safe. */
.ss-wrap { position: relative; display: inline-block; vertical-align: middle; }
.ss-input {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font: inherit; font-size: var(--fs-md);
  min-width: 160px; outline: none;
}
.ss-input:focus { border-color: var(--accent); }
.ss-input:disabled { opacity: .55; cursor: not-allowed; }
.ss-list {
  /* z-index 60 floats the open menu above sticky page chrome (the staff
     banner is position:sticky z-index 50) and stays below modals (overlay
     z-index 100). At 40 the translucent sticky banner painted OVER the menu
     and bled through it, which read as a see-through dropdown. */
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
  background: var(--surface-2); border: 1px solid var(--accent-line); border-radius: 8px;
  max-height: 280px; overflow-y: auto; padding: 4px;
}
.ss-item {
  padding: 7px 10px; font-size: var(--fs-md); color: var(--text); border-radius: 6px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ss-item:hover, .ss-item.ss-active { background: var(--surface); }
.ss-item.ss-sel { font-weight: 600; }
.ss-item.ss-sel::before { content: '\2713\00a0'; color: var(--accent); }
.ss-empty { padding: 8px 10px; font-size: var(--fs-md); color: var(--muted); }
.notif-list {
  display: flex;
  flex-direction: column;
}
.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: flex-start;
}
.notif-item:hover { background: var(--surface-2); margin: 0 -16px; padding: 12px 16px; border-bottom-color: var(--border); }
.notif-item.unread .notif-title { color: var(--text); font-weight: 500; }
.notif-item.unread::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-top: 6px; flex-shrink: 0;
}
.notif-item:not(.unread)::before {
  content: ""; width: 6px; height: 6px; margin-top: 6px; flex-shrink: 0;
}
.notif-icon { color: var(--muted); flex-shrink: 0; padding-top: 1px; }
.notif-icon svg { width: 16px; height: 16px; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: var(--fs-md); color: var(--text-2); margin: 0 0 2px; line-height: 1.45; }
.notif-meta { font-size: var(--fs-xs); color: var(--muted); margin: 0; }

/* NProgress bar */
.nprogress {
  position: fixed; top: 0; left: 0;
  height: 2px;
  background: var(--accent);
  width: 0;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: width 0.18s ease-out, opacity 0.2s;
  box-shadow: 0 0 8px var(--accent-line);
}
.nprogress.on { opacity: 1; }

/* kbd chips for help modal etc */
.kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text-2);
  min-width: 18px;
  text-align: center;
}

/* Sparkline cell */
.spark { color: var(--accent); display: inline-flex; align-items: center; }

/* Calendar grid (F29) */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-head {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-align: center;
  padding: 4px 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cal-cell {
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: var(--bg-2);
  min-height: 76px;
  padding: 6px 8px;
  font-size: var(--fs-sm);
  position: relative;
}
.cal-cell.muted {
  /* Out-of-month placeholders keep the grid aligned but draw nothing: a row of
     empty outlined boxes above the schedule read as a broken component. */
  background: transparent;
  border-color: transparent;
}
.cal-cell.today { border-color: var(--accent); }
.cal-day { font-weight: 500; color: var(--text-2); }
.cal-cell.today .cal-day { color: var(--accent); }
.cal-event {
  font-size: var(--fs-2xs);
  background: var(--accent-soft);
  color: var(--accent-hi);
  border-radius: 4px;
  padding: 2px 5px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.warn { background: var(--warn-soft); color: var(--warn); }
.cal-event.danger { background: var(--danger-soft); color: var(--danger); }
.cal-event.info { background: var(--info-soft); color: var(--info); }

/* Saved searches chips (F40) */
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.chip {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: var(--fs-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip:hover { border-color: var(--border-3); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-hi); }
.chip-close { background: transparent; border: 0; color: inherit; cursor: pointer; font-size: var(--fs-md); line-height: 1; padding: 0 2px; }

/* SLA timer (F34) */
.sla {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
}
.sla.warn { color: var(--warn); }
.sla.danger { color: var(--danger); }
.sla-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.sla.warn .sla-dot { background: var(--warn); }
.sla.danger .sla-dot { background: var(--danger); }
@media (max-width: 640px) {
  .cal-cell { min-height: 56px; padding: 4px 5px; font-size: var(--fs-xs); }
  .cal-event { font-size: var(--fs-2xs); padding: 1px 3px; }
}

/* Print-friendly invoice (F37) */
@media print {
  /* The editorial layer sets its own colours on the element, so body{color:black}
     does not reach it: printed prose came out #aaadb4 on white (2.5:1) and
     callout labels #4ec5b3 (2.1:1). Invoices are a real print target. */
  .prose, .callout, .callout p { color: #111 !important; }
  .callout > .callout-label { color: #555 !important; }
  .callout { background: none !important; border-left-color: #999 !important; }
  .eyebrow, .page-eyebrow, .metric-label, .table th { color: #444 !important; }
  body { background: white !important; color: black !important; }
  .demo-banner, .sidebar, .mobile-topbar, .sidebar-actions, .nprogress, .toast-host, .overlay, .theme-toggle, .page-header .btn { display: none !important; }
  .app { display: block !important; }
  .main { padding: 0 !important; max-width: 100% !important; }
  .card { border: 1px solid #ddd !important; background: white !important; box-shadow: none !important; page-break-inside: avoid; }
  .pill { border: 1px solid #999 !important; color: #333 !important; }
  .table th, .table td { color: black !important; border-color: #ddd !important; }
  .table th { color: #555 !important; }
}

/* ============================================================
   Role-aware nav (added 2026-06-12)
   Hide staff-only elements by default; nav.js un-hides after
   /api/v1/me confirms is_staff. Prevents flash of staff links.
   ============================================================ */
.staff-only { display: none !important; }
.staff-only.staff-revealed { display: flex !important; }
.nav-section.staff-only.staff-revealed { display: block !important; }

/* Identity badge in sidebar / mobile topbar brand row */
.identity-badge-slot { display: inline-flex; align-items: center; gap: 4px; }
.identity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid transparent;
}
.identity-badge.staff {
  background: var(--accent);
  color: var(--bg);   /* #fff on the accent was 2.1:1; the ground reads on both themes */
}
.identity-badge.customer {
  background: var(--surface-2, rgba(255,255,255,0.06));
  color: var(--text, #e6e6e6);
  border-color: var(--border, rgba(255,255,255,0.10));
}
.identity-badge.anon {
  background: transparent;
  color: var(--muted, #9aa);
  border-color: var(--border, rgba(255,255,255,0.10));
}
.identity-badge.anon:hover { color: var(--text, #fff); }
/* Sign-out chip — sits next to the identity badge. Pill-rounded to match,
   transparent ghost styling so it doesn't compete with the badge's color.
   Icon + "Sign out" label so the action is unambiguous (a lone "×" was
   indistinguishable from a dismiss/close affordance). */
.identity-signout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #9aa);
  border: 1px solid var(--border, rgba(255,255,255,0.10));
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}
.identity-signout svg {
  flex: 0 0 auto;
  display: block;
}
.identity-signout:hover,
.identity-signout:focus-visible {
  background: var(--surface-2, rgba(255,255,255,0.06));
  color: var(--text, #fff);
  border-color: var(--accent-line, rgba(255,255,255,0.18));
}
.identity-signout:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-line);
}
/* Mobile topbar: a clear, tappable "Log out" button. On phones the sidebar
   (and its footer sign-out) is hidden behind the hamburger, so this is the
   primary logout. Show the label + a proper ~40px tap target. The logged-in
   identity name is redundant clutter here (and "Default Admin" is just the
   Authentik bootstrap account), so hide the staff/customer badge on the topbar
   — it still shows in the desktop sidebar. The anonymous "Sign in" link stays. */
.mobile-topbar .identity-badge.staff,
.mobile-topbar .identity-badge.customer { display: none; }
.mobile-topbar .identity-signout-label { display: inline; }
.mobile-topbar .identity-signout {
  padding: 8px 12px;
  min-height: 40px;
  font-size: var(--fs-sm);
  gap: 7px;
}
.mobile-topbar .identity-signout svg { width: 22px; height: 22px; }


/* ---- Staff customer-context bar ----
   First row of <main> on staff pages: pick a customer once and supporting
   pages stay scoped as you navigate. .active marks a live filter with an
   accent ring so it cannot be forgotten; .ctx-note is the honest "this page
   doesn't filter" state on pages that never opted in. */
.ctx-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: -16px 0 26px;
}
.ctx-bar .ctx-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ctx-bar .ss-wrap { width: 250px; max-width: 100%; }
.ctx-bar .ss-input { width: 100%; font-size: var(--fs-md); }
.ctx-bar.active .ss-input {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ctx-clear {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  line-height: 1;
  font-size: var(--fs-lg);
  cursor: pointer;
  flex: none;
}
.ctx-clear:hover { color: var(--text); border-color: var(--es-border-strong); }
.ctx-note { font-size: var(--fs-xs); color: var(--muted); }
@media (max-width: 768px) {
  .ctx-bar { margin: 0 0 18px; }
  .ctx-bar .ss-wrap { flex: 1; width: auto; min-width: 180px; }
}

/* ---- Notification / activity value pass ----
   Tone colors mark urgency on the icon; rows that navigate get a pointer,
   hover, and a trailing chevron so "clickable" is visible, not guesswork. */
.notif-icon.tone-ok, .activity-icon.tone-ok { color: var(--ok); }
.notif-icon.tone-warn, .activity-icon.tone-warn { color: var(--warn); }
.notif-icon.tone-danger, .activity-icon.tone-danger { color: var(--danger); }
.notif-item.notif-link, .activity-item.activity-link { cursor: pointer; }
.notif-item.notif-link:hover, .activity-item.activity-link:hover { background: var(--hover); }
.notif-go {
  flex: none;
  align-self: center;
  margin-left: auto;
  color: var(--muted);
  transform: rotate(-90deg); /* the shared chevron icon points down by default */
}
.notif-item.notif-link:hover .notif-go { color: var(--text); }

/* Inline toast action (undo). Sits between the message and the dismiss X. */
.toast-action {
  flex: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 10px;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.toast-action:hover { border-color: var(--accent); color: var(--accent); }

/* Text field inside a modal (ES.modal.prompt) — matches the form controls
   used elsewhere so a prompt looks like the app, not like the browser. */
.modal-label {
  display: block;
  margin: 14px 0 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}
.modal-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  outline: none;
}
.modal-input:focus { border-color: var(--accent); }
textarea.modal-input { resize: vertical; min-height: 68px; }


/* ============================================================
   Editorial layer — the devices that carry the tone
   ============================================================ */

/* Prose. The ONLY place the serif appears: narrative a person reads in
   sentences (a statement to a board, an explanation of why a figure is
   missing). Never tables, never controls — dense data stays in the UI sans. */
.prose {
  font-family: var(--font-prose);
  font-size: var(--fs-lg);
  line-height: 1.62;
  color: var(--text-2);
  max-width: 66ch;
}
.prose p { margin: 0 0 12px; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 600; }

/* Callout — a left-ruled note that explains something the numbers cannot:
   why a value is unknown, what a state actually means, what we will not claim.
   Used where the honest answer needs a sentence. */
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 13px 16px;
  margin: 16px 0;
}
.callout > .callout-label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 5px;
}
.callout .prose, .callout p { margin: 0; font-size: var(--fs-md); }
.callout.warn   { border-left-color: var(--warn);   background: var(--warn-soft); }
.callout.warn   > .callout-label { color: var(--warn); }
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.danger > .callout-label { color: var(--danger); }
.callout.mute   { border-left-color: var(--border-3); background: var(--hover); }
.callout.mute   > .callout-label { color: var(--muted); }

/* Figures that must line up — metrics, money, counts, dates in columns. */
.tnum, .metric-value, .money { font-variant-numeric: tabular-nums; }

/* A mono micro-label for a value's unit or qualifier ("of 4 checking in"). */
.unit {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  color: var(--faint);
}
