/* ── Busco Ops Centre — v2 styles ──────────────────────────────
   Top-nav, denser, more professional. Brand orange primary.
   ──────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --canvas:        #F6F7F9;
  --surface:       #FFFFFF;
  --surface-2:     #FAFBFC;
  --border:        #E5E7EB;
  --border-strong: #D1D5DB;
  --border-soft:   #EEF0F3;

  /* Text */
  --text:    #0B1220;
  --text-2:  #2B3445;
  --muted:   #5B6779;
  --muted-2: #8B95A7;
  --muted-3: #C2C9D5;

  /* Brand — Busco orange */
  --b50:  #FFF3EE;
  --b100: #FFE3D6;
  --b200: #FFC4AB;
  --b300: #FFA482;
  --b500: #E55A37;
  --b600: #D14A2A;
  --b700: #B23F26;
  --b800: #8C311E;

  /* Status */
  --good:       #10B981;
  --good-50:    #ECFDF5;
  --good-100:   #D1FAE5;
  --good-700:   #047857;

  --warn:       #F59E0B;
  --warn-50:    #FFFBEB;
  --warn-100:   #FEF3C7;
  --warn-700:   #B45309;

  --crit:       #EF4444;
  --crit-50:    #FEF2F2;
  --crit-100:   #FEE2E2;
  --crit-700:   #B91C1C;

  --info-50:    #EFF6FF;
  --info-100:   #DBEAFE;
  --info-600:   #2563EB;
  --info-700:   #1D4ED8;

  --slate-50:   #F1F5F9;
  --slate-100:  #E2E8F0;

  /* Radii (overridable via tweak) */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;

  /* Density (overridable via tweak) */
  --pad-cell:   10px 14px;
  --pad-card:   16px;
  --pad-card-h: 14px 16px;
  --row-h:      40px;
  --gap-grid:   16px;
  --content-py: 22px;

  /* Shadows */
  --sh-1: 0 1px 2px rgba(11, 18, 32, 0.04);
  --sh-2: 0 1px 3px rgba(11, 18, 32, 0.06), 0 1px 1px rgba(11, 18, 32, 0.03);
  --sh-pop: 0 12px 32px rgba(11, 18, 32, 0.14), 0 2px 6px rgba(11, 18, 32, 0.06);
}

[data-density="compact"] {
  --pad-cell:   7px 12px;
  --pad-card:   12px;
  --pad-card-h: 10px 14px;
  --row-h:      34px;
  --gap-grid:   12px;
  --content-py: 16px;
}
[data-density="comfortable"] {
  --pad-cell:   13px 16px;
  --pad-card:   20px;
  --pad-card-h: 16px 20px;
  --row-h:      46px;
  --gap-grid:   20px;
  --content-py: 28px;
}

[data-radius="sharp"] { --r-sm: 3px; --r-md: 4px; --r-lg: 6px; }
[data-radius="rounded"] { --r-sm: 8px; --r-md: 12px; --r-lg: 16px; }

/* Brand swaps */
[data-accent="indigo"] {
  --b50:#EEF2FF; --b100:#E0E7FF; --b200:#C7D2FE; --b300:#A5B4FC;
  --b500:#4F46E5; --b600:#4338CA; --b700:#3730A3; --b800:#312E81;
}
[data-accent="teal"] {
  --b50:#ECFEFF; --b100:#CFFAFE; --b200:#A5F3FC; --b300:#67E8F9;
  --b500:#0E9488; --b600:#0F766E; --b700:#115E59; --b800:#134E4A;
}
[data-accent="slate"] {
  --b50:#F1F5F9; --b100:#E2E8F0; --b200:#CBD5E1; --b300:#94A3B8;
  --b500:#334155; --b600:#1E293B; --b700:#0F172A; --b800:#020617;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono, .num {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 999px; border: 2px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
::-webkit-scrollbar-track { background: transparent; }

/* ─── Shell ─── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
}
.app::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("assets/busco-logo.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: min(48vw, 720px) auto;
  opacity: 0.05;
  pointer-events: none;
  /* Sits behind everything inside .app — `isolation: isolate` on .app
     contains this so it can't end up behind the page background. */
  z-index: -1;
}
/* NOTE: do NOT give .app's children an explicit z-index here.
   Doing so makes each one its own stacking context and traps popovers
   (e.g. the Export dropdown) below later siblings like .content. */

/* Top header (orange brand band) */
.header {
  background: linear-gradient(180deg, var(--b500) 0%, var(--b600) 100%);
  border-bottom: 1px solid var(--b700);
  height: 120px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 18px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(178, 63, 38, 0.18);
}
.brand {
  display: flex; align-items: center;
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 18px;
  height: 96px;
  box-shadow: 0 3px 14px rgba(11, 18, 32, 0.12), 0 0 0 1px rgba(255,255,255,0.4);
  flex-shrink: 0;
}
.brand-logo {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-logo img {
  height: 100%;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  display: block;
}

.workspace-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.14);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.12s;
}
.workspace-chip:hover,
.workspace-chip.open { background: rgba(255, 255, 255, 0.24); }
.workspace-chip .ws-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
}

/* User chip — sits on orange band */
.user-chip-wrap { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 5px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  font: inherit;
  transition: background 0.12s, border-color 0.12s;
  backdrop-filter: blur(4px);
}
.user-chip:hover, .user-chip.open {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.45);
}
.user-chip .av {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--b700);
  font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}
.user-chip .um { line-height: 1.15; text-align: left; }
.user-chip .um .un { font-size: 12px; font-weight: 600; color: #fff; display: block; }
.user-chip .um .ur { font-size: 10px; color: rgba(255, 255, 255, 0.78); letter-spacing: 0.04em; display: block; }
.user-chip .uc-caret { color: rgba(255, 255, 255, 0.85); margin-right: 4px; transition: transform 0.15s; }
.user-chip.open .uc-caret { transform: rotate(180deg); }

/* User menu dropdown */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-pop);
  z-index: 80;
  padding: 6px;
  animation: pop 0.14s ease-out;
}
.user-menu .um-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 6px;
}
.user-menu .um-head .av {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: var(--b500);
  color: #fff;
  font-size: 12.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-menu .um-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu .um-email {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu .um-sec { display: flex; flex-direction: column; gap: 1px; }
.user-menu .um-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.user-menu .um-item:hover { background: var(--canvas); }
.user-menu .um-item .um-meta {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
}
.user-menu .um-item.danger { color: var(--crit-700); }
.user-menu .um-item.danger:hover { background: var(--crit-50); }
.user-menu .um-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 0;
}

/* ─── Dropdowns / Popovers ─── */
.dropdown-wrap { position: relative; display: inline-flex; }

.menu-pop {
  position: absolute;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-pop);
  z-index: 100;
  padding: 6px;
  animation: pop 0.14s ease-out;
}

.mp-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px 6px;
}
.mp-clear {
  border: 0;
  background: transparent;
  color: var(--b600);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  padding: 0;
}
.mp-clear:hover { color: var(--b700); }

.mp-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.mp-item:hover { background: var(--canvas); }
.mp-item.on { background: var(--b50); }
.mp-item.compact { padding: 7px 10px; gap: 8px; }

.mp-glyph {
  width: 36px; height: 28px;
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.mp-glyph-xls   { background: #DCFCE7; color: #15803D; }
.mp-glyph-csv   { background: var(--info-50); color: var(--info-700); }
.mp-glyph-pdf   { background: #FEE2E2; color: #B91C1C; }
.mp-glyph-brief { background: var(--b50); color: var(--b700); }

.mp-l { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.mp-t { font-size: 12.5px; font-weight: 600; color: var(--text); }
.mp-s { font-size: 10.5px; color: var(--muted); }

.mp-divider { height: 1px; background: var(--border-soft); margin: 5px 0; }

.mp-group { padding: 4px 4px 10px; }
.mp-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 6px 7px 5px;
}
.mp-checks { display: flex; flex-direction: column; gap: 1px; }
.mp-check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.mp-check:hover { background: var(--canvas); }
.mp-check input[type="checkbox"] { accent-color: var(--b500); cursor: pointer; }

.filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--b500);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  margin-left: 2px;
}
.btn.on { background: var(--canvas); border-color: var(--border-strong); }

/* ─── Trend chip (courier perf cards) ─── */
.trend-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}
.trend-chip.up   { background: var(--good-50); color: var(--good-700); }
.trend-chip.dn   { background: var(--crit-50); color: var(--crit-700); }
.trend-chip.flat { background: var(--canvas); color: var(--muted); }

/* ─── Brief report modal ─── */
.brief-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--sh-pop);
  width: 100%;
  max-width: 700px;
  display: flex; flex-direction: column;
  max-height: 88vh;
  animation: pop 0.18s ease-out;
}
.brief-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.brief-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brief-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.brief-body {
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
  flex: 1;
}
.brief-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.brief-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.brief-stat-v {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.brief-pre {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px 18px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow-y: auto;
}
.brief-empty {
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  padding: 28px 18px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}
.brief-foot {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* ─── Confirm modal ─── */
.confirm-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--sh-pop);
  width: 100%;
  max-width: 420px;
  padding: 22px 22px 18px;
  animation: pop 0.16s ease-out;
}
.confirm-title { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.confirm-body  { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.55; }
.confirm-foot  { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ─── Global search (used inline on Couriers screen) ─── */
.global-search {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--muted);
}
.global-search input {
  flex: 1; border: 0; background: transparent; outline: none; color: var(--text);
  font-size: 12.5px;
}
.global-search:focus-within {
  border-color: var(--b500);
  box-shadow: 0 0 0 3px var(--b100);
}
.search-clear {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; cursor: pointer; padding: 2px; border-radius: 4px;
  line-height: 0;
}
.search-clear:hover { background: var(--surface-2); }

/* Sign-in window */
.signin-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--sh-pop);
  width: 100%;
  max-width: 400px;
  padding: 28px 28px 24px;
  position: relative;
  animation: pop 0.18s ease-out;
}
.signin-x {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.signin-x:hover { background: var(--canvas); color: var(--text); }
.signin-brand {
  display: flex; justify-content: center;
  margin-bottom: 16px;
}
.signin-brand img { height: 56px; width: auto; object-fit: contain; }
.signin-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.01em;
}
.signin-sub {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}
.signin-form {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 20px;
}
.signin-form .field label {
  display: flex; justify-content: space-between; align-items: baseline;
  text-transform: none;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-2);
}
.signin-form .field input {
  padding: 9px 12px;
  font-size: 13px;
}
.signin-link {
  font-size: 11px;
  color: var(--b600);
  text-decoration: none;
  font-weight: 500;
}
.signin-link:hover { text-decoration: underline; }
.signin-remember {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  margin-top: 2px;
}
.signin-submit {
  justify-content: center;
  margin-top: 6px;
}
.signin-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.signin-sso-row {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0;
}
.signin-sso-line { flex: 1; height: 1px; background: var(--border); }
.signin-sso-lbl { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.1em; }
.signin-sso { justify-content: center; }
.signin-foot {
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}

/* Section nav */
.subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  position: sticky; top: 120px; z-index: 40;
  overflow-x: auto;
}
.subnav button {
  position: relative;
  border: 0; background: transparent;
  padding: 0 14px;
  height: 100%;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.subnav button:hover { color: var(--text); }
.subnav button.on {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--b500);
}
.subnav button .pin-tag {
  font-size: 9px;
  letter-spacing: 0.08em;
  background: var(--canvas);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  color: var(--muted);
}
.subnav button.on .pin-tag {
  background: var(--b50);
  border-color: var(--b100);
  color: var(--b700);
}

/* Subbar (page-level context: title + actions) */
.subbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--canvas);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.subbar .title-block { display: flex; flex-direction: column; gap: 3px; }
.subbar h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.015em;
  color: var(--text);
}
.subbar .crumbs {
  font-size: 11.5px;
  color: var(--muted);
  display: flex; gap: 6px; align-items: center;
  letter-spacing: 0.01em;
}
.subbar .crumbs .sep { color: var(--muted-3); }
.subbar .actions { display: flex; align-items: center; gap: 8px; }

/* Content shell */
.content {
  padding: var(--content-py) 28px 64px;
  flex: 1;
  max-width: 1640px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  transition: background 0.12s, border-color 0.12s;
  box-shadow: var(--sh-1);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary {
  background: var(--b500);
  color: white;
  border-color: var(--b500);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(229, 90, 55, 0.15);
}
.btn.primary:hover { background: var(--b600); border-color: var(--b600); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: var(--canvas); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 11.5px; }
.btn.lg { padding: 9px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.danger { background: var(--crit); color: white; border-color: var(--crit); }

/* ─── Surfaces ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
}
.card-head {
  padding: var(--pad-card-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head .ch-l { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-head h3 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: -0.005em; color: var(--text); }
.card-head .ch-sub { font-size: 11.5px; color: var(--muted); }
.card-body { padding: var(--pad-card); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ─── KPI ─── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-grid);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--sh-2);
  position: relative;
}
.kpi .lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.kpi .val {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-top: 10px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.kpi .val.good { color: var(--good-700); }
.kpi .val.bad  { color: var(--crit-700); }
.kpi .sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}
.kpi .delta {
  font-size: 11px;
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
}
.kpi .delta.up { color: var(--good-700); }
.kpi .delta.dn { color: var(--crit-700); }
.kpi .icon-spot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
}

/* ─── Section heading ─── */
.sec {
  display: flex; align-items: center; justify-content: space-between;
  margin: 24px 0 12px;
  gap: 12px;
}
.sec h2 {
  font-size: 12px;
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex; align-items: baseline; gap: 8px;
}
.sec h2 .ct {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-2);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.sec .sec-right { display: flex; align-items: center; gap: 8px; }
.sec.no-pad { margin-top: 0; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.45;
}
.badge.pill { border-radius: 999px; padding: 2px 9px; }
.badge.lg { padding: 4px 12px; font-size: 12px; }

.rate-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.rate-good { background: var(--good-50); color: var(--good-700); border-color: var(--good-100); }
.rate-warn { background: var(--warn-50); color: var(--warn-700); border-color: var(--warn-100); }
.rate-bad  { background: var(--crit-50); color: var(--crit-700); border-color: var(--crit-100); }

.badge-slate  { background: var(--canvas); color: var(--text-2); border-color: var(--border); }
.badge-brand  { background: var(--b50); color: var(--b700); border-color: var(--b100); }
.badge-info   { background: var(--info-50); color: var(--info-700); border-color: var(--info-100); }
.badge-warn   { background: var(--warn-50); color: var(--warn-700); border-color: var(--warn-100); }
.badge-crit   { background: var(--crit-50); color: var(--crit-700); border-color: var(--crit-100); }
.badge-good   { background: var(--good-50); color: var(--good-700); border-color: var(--good-100); }

.dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; flex-shrink: 0; }

/* Source chip: small letter token */
.src {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
.src.s-manual { background: var(--info-50); color: var(--info-700); border: 1px solid var(--info-100); }
.src.s-upload { background: var(--b50); color: var(--b700); border: 1px solid var(--b100); }
.src.s-gmail  { background: var(--good-50); color: var(--good-700); border: 1px solid var(--good-100); }

/* Tier chips (no emoji) */
.tier {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tier .tdot { width: 6px; height: 6px; border-radius: 999px; }
.tier-elite { background: #FEF3C7; color: #854D0E; }
.tier-elite .tdot { background: #EAB308; }
.tier-star  { background: #F1F5F9; color: #334155; }
.tier-star  .tdot { background: #94A3B8; }
.tier-pro   { background: #FFEDD5; color: #9A3412; }
.tier-pro   .tdot { background: #C2410C; }
.tier-track { background: var(--good-50); color: var(--good-700); }
.tier-track .tdot { background: var(--good); }
.tier-needs { background: var(--crit-50); color: var(--crit-700); }
.tier-needs .tdot { background: var(--crit); }
.tier-nodata { background: var(--canvas); color: var(--muted); }
.tier-nodata .tdot { background: var(--muted-2); }

/* Contract chip */
.ctype {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
}
.ctype.salary     { background: var(--info-50); color: var(--info-700); border-color: var(--info-100); }
.ctype.freelancer { background: var(--warn-50); color: var(--warn-700); border-color: var(--warn-100); }

/* Status pill */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid;
}
.status.pending { background: var(--canvas); color: var(--muted); border-color: var(--border); }
.status.overdue { background: var(--crit-50); color: var(--crit-700); border-color: var(--crit-100); }
.status.paid    { background: var(--good-50); color: var(--good-700); border-color: var(--good-100); }

/* ─── Segmented ─── */
.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 1px;
  box-shadow: var(--sh-1);
}
.segmented button {
  border: 0; background: transparent;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.005em;
  transition: all 0.1s;
}
.segmented button.on {
  background: var(--text);
  color: var(--surface);
  font-weight: 600;
}
.segmented button:not(.on):hover { color: var(--text); background: var(--canvas); }

/* ─── Tables ─── */
.tbl-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  /* `overflow: visible` lets popovers anchored inside .tbl-head (e.g. the
     Export menu on Finance screens) escape; we round the actual cell
     corners below so the table edges still look clipped. */
  overflow: visible;
  position: relative;
  box-shadow: var(--sh-2);
}
/* Round the visible cell corners since the wrap no longer clips them. */
.tbl-wrap > table.data:first-child > thead tr:first-child th:first-child {
  border-top-left-radius: var(--r-md);
}
.tbl-wrap > table.data:first-child > thead tr:first-child th:last-child {
  border-top-right-radius: var(--r-md);
}
table.data tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--r-md);
}
table.data tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--r-md);
}
.tbl-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.tbl-head h3 { font-size: 13px; font-weight: 600; margin: 0; }
.tbl-head .sub { font-size: 11.5px; color: var(--muted); }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: var(--pad-cell);
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text-2);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
}
table.data td.strong { color: var(--text); font-weight: 600; }
table.data tr.row-bad td { background: rgba(239, 68, 68, 0.045) !important; }
table.data tr.row-bad td.strong { color: var(--crit-700); }
[data-striping="on"] table.data tbody tr:nth-child(even) td { background: var(--surface-2); }

/* Totals row (table footer) */
table.data tfoot tr.row-total td { background: var(--surface-2); border-top: 2px solid var(--border); border-bottom: 0; font-weight: 700; }

/* Inline rate cell */
.rate-cell {
  display: flex; align-items: center; gap: 8px;
}
.rate-bar {
  flex: 1;
  height: 4px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
  max-width: 80px;
}
.rate-bar > i {
  display: block; height: 100%;
  border-radius: 999px;
}

/* ─── Form ─── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.field input, .field select, .field textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 7px 11px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--b500);
  box-shadow: 0 0 0 3px var(--b100);
}
.field input.mono { font-family: 'IBM Plex Mono', monospace; }
.field .hint { font-size: 11px; color: var(--muted); }
.field-row { display: grid; gap: 12px; }
.field-row.c2 { grid-template-columns: repeat(2, 1fr); }
.field-row.c3 { grid-template-columns: repeat(3, 1fr); }
.field-row.c4 { grid-template-columns: repeat(4, 1fr); }

/* ─── Banner ─── */
.banner {
  display: flex; align-items: center; gap: 12px;
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 12.5px;
  border: 1px solid;
}
.banner.warn {
  background: var(--warn-50);
  border-color: var(--warn-100);
  color: var(--warn-700);
}
.banner.warn b { color: var(--warn-700); }
.banner.crit {
  background: var(--crit-50);
  border-color: var(--crit-100);
  color: var(--crit-700);
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.5);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade 0.15s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-pop);
  max-width: 1140px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  animation: pop 0.18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-body { padding: 20px; }
.close-x {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.close-x:hover { background: var(--canvas); }

/* ─── Slide-in ─── */
.slide-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 440px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--sh-pop);
  z-index: 220;
  display: flex; flex-direction: column;
  animation: slidein 0.2s ease-out;
}
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Sparkline ─── */
.spark {
  display: flex; align-items: flex-end; gap: 2px;
  height: 28px;
}
.spark > i {
  flex: 1;
  background: var(--b200);
  border-radius: 1px;
  min-height: 3px;
}
.spark > i.lo { background: #FCA5A5; }
.spark > i.ok { background: #6EE7B7; }
.spark > i.hi { background: var(--b500); }

/* ─── Misc ─── */
.muted   { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.tile .tl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.tile .tv { font-size: 18px; font-weight: 600; margin-top: 4px; line-height: 1; font-family: 'IBM Plex Mono', monospace; }

/* Drop zone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 22px 16px;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.12s;
}
.dropzone:hover { border-color: var(--b500); background: var(--b50); }
.dropzone .dz-ic {
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px;
  color: var(--b600);
}

/* Client cards (used in clients screen) */
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--sh-2);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.client-card:hover { border-color: var(--b300); box-shadow: var(--sh-pop); }
.client-card.bad { border-color: var(--crit-100); box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.05), var(--sh-2); }

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.kan-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; flex-direction: column;
  min-height: 180px;
}
.kan-col-h {
  padding: 11px 13px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
}
.kan-col-h .ct {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--text);
  letter-spacing: 0;
}
.kan-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.12s;
  box-shadow: var(--sh-1);
}
.kan-card:hover { border-color: var(--b300); }
.kan-card.selected {
  border-color: var(--b500);
  box-shadow: 0 0 0 2px var(--b100);
}

/* Podium */
.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 12px;
  align-items: end;
}
.podium-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  text-align: left;
  position: relative;
  box-shadow: var(--sh-2);
}
.podium-card .rk {
  position: absolute;
  top: 14px;
  right: 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted-3);
  letter-spacing: -0.04em;
}
.podium-card.p1 { padding-top: 26px; padding-bottom: 22px; border-color: #EAB308; box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.08), var(--sh-2); }
.podium-card.p1 .rk { color: #EAB308; }
.podium-card.p2 .rk { color: #94A3B8; }
.podium-card.p3 .rk { color: #C2410C; }

/* Tabs (in-page) */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tabs .tab {
  padding: 10px 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.005em;
}
.tabs .tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--b500); }
.tabs .tab:hover:not(.on) { color: var(--text); }

/* PIN gate */
.pin-screen {
  display: flex; align-items: center; justify-content: center;
  padding: 64px 24px;
}
.pin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-pop);
  padding: 36px;
  max-width: 380px;
  width: 100%;
}
.pin-lock {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  background: var(--b50);
  color: var(--b600);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
}
.pin-inputs { display: flex; gap: 8px; margin: 20px 0 12px; }
.pin-inputs input {
  width: 52px; height: 60px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-align: center;
  font-size: 24px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
  outline: none;
  -webkit-text-security: disc;
  transition: all 0.12s;
}
.pin-inputs input:focus { border-color: var(--b500); box-shadow: 0 0 0 3px var(--b100); }
.pin-inputs.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--text);
  color: white;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--sh-pop);
  display: flex; align-items: center; gap: 10px;
  z-index: 400;
  animation: pop 0.18s ease-out;
}
.toast.success { background: #064E3B; }
.toast.danger  { background: #7F1D1D; }

/* Floating "back to top" — bottom-left so it never collides with toasts */
.back-to-top {
  position: fixed; left: 20px; bottom: 20px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--b600); color: #fff;
  border: none; border-radius: 50%;
  box-shadow: var(--sh-pop);
  cursor: pointer; z-index: 390;
  opacity: 0.9; transition: opacity 0.15s ease, transform 0.15s ease;
  animation: pop 0.18s ease-out;
}
.back-to-top:hover { opacity: 1; transform: translateY(-2px); }
@media (max-width: 720px) { .back-to-top { left: 14px; bottom: 14px; width: 38px; height: 38px; } }

/* Spinner */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--b100);
  border-top-color: var(--b500);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Misc helpers */
.row-gap   { display: flex; gap: 10px; align-items: center; }
.col-gap   { display: flex; flex-direction: column; gap: 10px; }
.grow      { flex: 1; }
.right-align { text-align: right; }

/* Label tiny */
.label-tiny {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Pill row for filter chips */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.1s;
}
.pill:hover { border-color: var(--b300); }
.pill.on {
  background: var(--b50);
  color: var(--b700);
  border-color: var(--b200);
  font-weight: 600;
}

/* Stepper */
.stepper {
  display: flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  overflow: hidden;
  width: fit-content;
}
.stepper button {
  border: 0; background: transparent;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.stepper button:hover { background: var(--canvas); color: var(--text); }
.stepper .val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  padding: 0 14px;
  min-width: 50px;
  text-align: center;
}

/* ───────────────────────────────────────────────────────────────
   ACCOUNT · PREFERENCES · WORKSPACE
   ─────────────────────────────────────────────────────────────── */
.pref-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 8px;
}
.pref-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  text-align: left;
  transition: background 0.12s;
}
.pref-row:last-child { border-bottom: 0; }
.pref-row:hover { background: var(--canvas); }
.pref-switch {
  flex-shrink: 0;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background 0.16s;
}
.pref-switch .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(11, 23, 32, 0.28);
  transition: transform 0.16s;
}
.pref-switch.on { background: var(--b500); }
.pref-switch.on .knob { transform: translateX(16px); }

.ws-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.ws-row:hover { background: var(--canvas); }
.ws-row.on { border-color: var(--b300); background: var(--b50); }
.ws-row-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--muted-2);
  flex-shrink: 0;
}
.ws-row.on .ws-row-dot {
  background: var(--b500);
  box-shadow: 0 0 0 3px var(--b100);
}

/* ───────────────────────────────────────────────────────────────
   RESPONSIVE / MOBILE
   ─────────────────────────────────────────────────────────────── */

/* Tablets — ≤ 1024px */
@media (max-width: 1024px) {
  .content { padding-left: 20px; padding-right: 20px; }
  .header { padding: 0 16px; gap: 12px; }
  .subnav { padding: 0 16px; }
  .subbar { padding: 14px 16px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .podium { grid-template-columns: 1fr; gap: 10px; }
  .field-row.c4 { grid-template-columns: repeat(2, 1fr); }
  .brief-stats { grid-template-columns: repeat(2, 1fr); }

  /* Two-column inline-style grids on dashboards → stacked */
  .content [style*="grid-template-columns: 2fr 1fr"],
  .content [style*="grid-template-columns: 1fr 1fr"],
  .content [style*="grid-template-columns: 440px 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* min-width:auto on grid/flex items lets a wide child (data table, etc.)
     blow the collapsed 1fr track past the viewport → clipped. Let it shrink. */
  .content [style*="grid-template-columns: 2fr 1fr"] > *,
  .content [style*="grid-template-columns: 1fr 1fr"] > *,
  .content [style*="grid-template-columns: 440px 1fr"] > * { min-width: 0; }
}

/* Phones — ≤ 720px */
@media (max-width: 720px) {

  body { font-size: 13px; }

  /* ── Header: shrink the orange band so the brand + actions fit ── */
  .header {
    height: auto;
    min-height: 64px;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .brand {
    height: 48px;
    padding: 6px 10px;
    border-radius: 10px;
  }
  .brand-logo img { max-width: 120px; }
  .workspace-chip { display: none; }
  .user-chip { padding: 3px 8px 3px 3px; }
  .user-chip .av { width: 26px; height: 26px; font-size: 10.5px; }
  .user-chip .um .un { font-size: 11px; }
  .user-chip .um .ur { display: none; }

  /* Anything in the header marked .header-grow becomes a line break helper.
     We also let the search/actions row wrap below the brand. */
  .header > *:not(.brand):not(.user-chip-wrap) { font-size: 12px; }

  /* User menu dropdown — pin to right edge with viewport-aware width */
  .user-menu {
    width: calc(100vw - 24px);
    max-width: 280px;
    right: -4px;
  }

  /* ── Sub-nav: still horizontally scrollable, sticky below shorter header ── */
  .subnav {
    top: 64px;
    height: 42px;
    padding: 0 12px;
    -webkit-overflow-scrolling: touch;
  }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav { scrollbar-width: none; }
  .subnav button { padding: 0 12px; font-size: 12px; }
  .subnav button .pin-tag { display: none; }

  /* ── Sub-bar: title above actions ── */
  .subbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }
  .subbar h1 { font-size: 17px; }
  .subbar .actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .subbar .actions .btn { font-size: 12px; padding: 6px 10px; }

  /* ── Content shell ── */
  .content {
    padding: 14px 12px 48px;
  }

  /* ── Background watermark logo: smaller so it isn't overwhelming ── */
  .app::before {
    background-size: min(70vw, 320px) auto;
    opacity: 0.04;
  }

  /* ── KPI row: 2-up, smaller numbers ── */
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 12px 12px; }
  .kpi .val { font-size: 22px; margin-top: 8px; }
  .kpi .icon-spot { top: 10px; right: 10px; width: 22px; height: 22px; }

  /* ── Cards / sections ── */
  .card-head { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .sec { margin: 20px 0 10px; }

  /* ── Sections that were grids on desktop → single column on mobile ── */
  .kanban { grid-template-columns: 1fr; gap: 10px; }
  .kan-col { min-height: 0; }
  .field-row.c2,
  .field-row.c3,
  .field-row.c4 { grid-template-columns: 1fr; }
  .brief-stats { grid-template-columns: repeat(2, 1fr); }

  /* Catch-all for inline gridTemplateColumns in screen JSX */
  .content [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* Allow the collapsed track to shrink to the viewport (see note above). */
  .content [style*="grid-template-columns"] > * { min-width: 0 !important; }

  /* Section headers (title + controls): stack instead of overflowing when the
     controls (segmented + filter + export) can't fit beside the title. */
  .sec { flex-wrap: wrap; }
  .sec .sec-right { flex-wrap: wrap; }

  /* ── Tables: allow horizontal scroll inside their wrapper ── */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-head { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  table.data { min-width: 640px; }
  table.data th { padding: 7px 10px; font-size: 9.5px; }
  table.data td { font-size: 12px; }

  /* Tabs row: allow scroll */
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs { scrollbar-width: none; }
  .tabs .tab { white-space: nowrap; padding: 9px 12px; }

  /* ── Slide-in panel: full-screen on mobile ── */
  .slide-panel {
    width: 100vw;
    border-left: 0;
  }

  /* ── Modals: take more of the viewport ── */
  .modal-overlay { padding: 8px; }
  .modal { max-height: 96vh; }
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 14px; }

  .brief-card { max-height: 94vh; }
  .brief-head { padding: 14px 16px 12px; }
  .brief-body { padding: 14px 16px; gap: 12px; }
  .brief-foot { padding: 12px 16px 14px; flex-direction: column; align-items: stretch; gap: 8px; }
  .brief-foot .btn { justify-content: center; }
  .brief-stat-v { font-size: 17px; }

  /* ── PIN gate ── */
  .pin-screen { padding: 28px 12px; }
  .pin-card { padding: 24px 18px; }
  .pin-inputs input { width: 44px; height: 52px; font-size: 22px; }

  /* ── Sign-in ── */
  .signin-card { padding: 22px 18px 18px; }
  .signin-brand img { height: 44px; }

  /* ── Confirm modal ── */
  .confirm-card { padding: 18px 18px 14px; }

  /* ── Menus / popovers: keep them on screen ── */
  .menu-pop {
    max-width: calc(100vw - 24px);
  }

  /* ── Toast ── */
  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: center;
  }

  /* ── Podium ── */
  .podium { grid-template-columns: 1fr; gap: 10px; }
  .podium-card.p1 { padding-top: 22px; }

  /* ── Segmented control: don't overflow the row ── */
  .segmented { flex-wrap: wrap; }

  /* ── Pill rows wrap freely (already do, but tighten) ── */
  .pill-row { gap: 5px; }

  /* ── Banners stack vertically ── */
  .banner { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* iOS form input zoom prevention — 16px minimum for inputs */
  .field input, .field select, .field textarea,
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="search"], textarea, select {
    font-size: 16px;
  }
}

/* Very narrow — ≤ 380px */
@media (max-width: 380px) {
  .kpi-row { grid-template-columns: 1fr; }
  .brief-stats { grid-template-columns: 1fr; }
  .brand-logo img { max-width: 96px; }
  .user-chip .um { display: none; }
}

/* Reduce motion — set from Preferences. Kills CSS transitions/animations. */
[data-reduce-motion="on"] *,
[data-reduce-motion="on"] *::before,
[data-reduce-motion="on"] *::after {
  animation-duration: 0.001s !important;
  animation-delay: 0s !important;
  transition-duration: 0.001s !important;
  scroll-behavior: auto !important;
}

/* ── Guided tour ─────────────────────────────────────────────── */
.tour-root { position: fixed; inset: 0; z-index: 2000; pointer-events: auto; }
.tour-dim  { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); }
.tour-spot {
  position: fixed;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55), 0 0 0 2px var(--b500);
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
  pointer-events: none;
}
.tour-card {
  position: fixed;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  box-shadow: 0 18px 50px rgba(11, 23, 32, 0.28);
  padding: 14px 16px;
  animation: pop 0.16s ease-out;
}
.tour-step-n { font-size: 10px; color: var(--muted-2); letter-spacing: 0.06em; }
.tour-title  { font-size: 14px; font-weight: 700; margin-top: 4px; }
.tour-body   { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 6px; }
.tour-actions { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.tour-prompt {
  position: fixed;
  bottom: 18px;
  inset-inline-end: 18px;
  z-index: 1500;
  width: min(320px, calc(100vw - 24px));
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  box-shadow: 0 14px 40px rgba(11, 23, 32, 0.18);
  padding: 14px;
  animation: pop 0.18s ease-out;
}
.tour-prompt-ic {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: var(--b50); border: 1px solid var(--b100);
  display: flex; align-items: center; justify-content: center;
}
@media (max-width: 720px) {
  /* clear the bottom tab bar */
  .tour-prompt { bottom: 92px; }
}

/* Tour bullet points + overflow safety for taller cards */
.tour-points {
  margin: 8px 0 0;
  padding-inline-start: 18px;
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--text-2, #334155); line-height: 1.45;
}
.tour-points li::marker { color: var(--b500); }
.tour-card { max-height: calc(100vh - 24px); overflow-y: auto; }
