/* ==========================================================================
   CSP Portal — NEW SKIN — THE canonical token source
   One token set · one component layer · one set of rules.
   Resolves the audit's structural contradictions:
     - ONE blue hierarchy (CSP brand navy→blue); the old Tailwind "ops blue"
       is retired tree-wide (2026-10-08) — static/shared.css now resolves
       its --csp-* tokens from this file's :root block
     - ONE status-pill set (color + dot + text, never color alone)
     - ONE table style (right-aligned tabular numerics, totals, () negatives)
     - ONE button system, ONE drawer, ONE page scaffold
     - Visible focus on every interactive element
   Brand fonts kept: Barlow Condensed (display) + Lato (body).
   ========================================================================== */

/* ---- 1. Design tokens ---------------------------------------------------- */
:root {
  /* Brand blues — a single ramp. Brand blue (#0B5EAE) is THE primary,
     on UI *and* report surfaces, killing the old 3-blue split. */
  --navy:        #0a2350;   /* deepest — brand mark, hero gradient top */
  --navy-2:      #0c2b6a;
  --brand:       #0b5eae;   /* PRIMARY — buttons, links, active, accents */
  --brand-2:     #1a6ec0;   /* secondary / hover-light */
  --brand-ink:   #08487f;   /* pressed / strong text-on-light accent */
  --brand-wash:  #eef4fb;   /* tint fill for active/subtotal/selected */
  --brand-wash-2:#e3eefaff;

  /* Neutrals — text + surfaces */
  --ink:         #161a23;   /* primary text (charcoal) */
  --ink-2:       #3d4757;   /* secondary text */
  --muted:       #6b7689;   /* metadata / captions */
  --faint:       #97a1b2;   /* placeholder / disabled text */
  --line:        #e5e9f0;   /* borders / dividers */
  --line-2:      #eef1f6;   /* hairline */
  --surface:     #ffffff;   /* cards */
  --canvas:      #f4f6fa;   /* page background */
  --canvas-2:    #fafbfd;

  /* Semantic (status) — each has fill + text + dot, all paired with a label */
  --ok:          #15724a;   --ok-bg:   #e7f3ec;  --ok-bd:  #b7ddc6;
  --warn:        #8a5a00;   --warn-bg: #fbf2dc;  --warn-bd:#ecd9a6;
  --bad:         #a4282b;   --bad-bg:  #fbeceb;  --bad-bd: #f0c4c2;
  --info:        #08487f;   --info-bg: #e9f1fb;  --info-bd:#bfd8f2;
  --neutral:     #4a5468;   --neutral-bg:#eef1f6;--neutral-bd:#dde2ea;

  /* Financial figures (report semantics) */
  --pos:  #15724a;          /* gains / favorable */
  --neg:  #a4282b;          /* losses / unfavorable (also shown in parens) */
  /* Report surfaces (ledger, statements) keep the print-faithful style-guide values. */
  --report-neg: #a94442;    /* style-guide negative red (shared.css --csp-report-neg) */
  --report-ink: #231f20;    /* style-guide charcoal body (shared.css --csp-report-ink) */

  /* Type */
  --font-display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --font-body: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;

  /* Type scale (rem) */
  --t-display: 2.1rem;  --t-h1: 1.6rem;  --t-h2: 1.22rem;  --t-h3: 1.02rem;
  --t-body: 0.94rem;    --t-sm: 0.84rem; --t-xs: 0.76rem;  --t-eyebrow: 0.72rem;

  /* Spacing scale (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  /* Radius + shadow + motion */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.04);
  --sh-2: 0 10px 24px -12px rgba(15,23,42,.18), 0 3px 8px rgba(15,23,42,.06);
  --sh-pop: 0 24px 48px -16px rgba(10,35,80,.30);
  --ease: cubic-bezier(.2,.7,.3,1);

  --maxw: 1200px;
}

/* ---- 2. Reset + base ----------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: var(--t-body);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); }
h1 { font-family: var(--font-display); font-weight: 700; font-size: var(--t-h1); line-height: 1.1; letter-spacing: .005em; }
.display { font-family: var(--font-display); font-weight: 700; font-size: var(--t-display); line-height: 1.04; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--t-h2); letter-spacing: .005em; }
h3 { font-weight: 700; font-size: var(--t-h3); }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: var(--t-sm); }
.eyebrow { font-size: var(--t-eyebrow); letter-spacing: .14em; text-transform: uppercase; font-weight: 800; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* Visible focus on EVERYTHING interactive (audit fix: pages disabled focus) */
:where(a, button, input, select, textarea, [tabindex], .chip, .tab):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- 3. App scaffold (top bar + page) ------------------------------------ */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s4);
  height: 60px; padding: 0 var(--s5);
  background: rgba(255,255,255,.86); backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: linear-gradient(140deg, var(--navy), var(--brand));
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 1rem; letter-spacing: .04em;
}
.brand-name { font-weight: 800; font-size: .96rem; line-height: 1.1; }
.brand-sub { font-size: var(--t-xs); color: var(--muted); font-weight: 600; }
.appbar .crumb { color: var(--muted); font-size: var(--t-sm); font-weight: 600; }
.appbar .crumb b { color: var(--ink-2); }
.appbar .spacer { margin-left: auto; }
.userchip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 14px 5px 5px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: #fff; font-weight: 700; font-size: var(--t-sm); color: var(--ink-2);
}
.userchip .avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--navy), var(--brand));
  color: #fff; display: grid; place-items: center; font-size: .72rem; font-weight: 800;
}

.page { width: min(var(--maxw), calc(100% - 40px)); margin: 0 auto; padding: var(--s5) 0 var(--s7); }
.page-head { display: flex; align-items: flex-end; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head .titles { min-width: 0; }
.page-head h1 { margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }

/* ---- 4. Buttons (ONE system) -------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--r-pill); border: 1px solid transparent;
  font-family: var(--font-body); font-weight: 700; font-size: var(--t-sm);
  cursor: pointer; transition: all .15s var(--ease); white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -10px rgba(11,94,174,.9); }
.btn-primary:hover { background: var(--brand-ink); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-secondary:hover { border-color: #c7cfdd; background: var(--canvas-2); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-wash); text-decoration: none; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #8a2123; text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: var(--t-xs); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- 5. Cards + grids ---------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--sh-1); padding: var(--s5);
}
.card-pad-0 { padding: 0; overflow: hidden; }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.section-title { display: flex; align-items: center; gap: var(--s3); margin: var(--s6) 0 var(--s3); }
.section-title h2 { font-size: 1.05rem; }
.section-title .rule { flex: 1; height: 1px; background: var(--line); }

/* ---- 6. KPI tiles (ONE component; delta shows sign+arrow+color+label) ---- */
.kpis { display: grid; gap: var(--s4); grid-template-columns: repeat(4, 1fr); }
.kpi {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-1); padding: var(--s4) var(--s4) var(--s4);
  border-top: 3px solid var(--brand); cursor: pointer; transition: all .16s var(--ease);
  text-align: left; width: 100%; font: inherit;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.kpi.is-warn { border-top-color: var(--warn); }
.kpi.is-bad  { border-top-color: var(--bad); }
.kpi.is-ok   { border-top-color: var(--ok); }
.kpi .label { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em; font-weight: 800; color: var(--muted); }
.kpi .value { font-family: var(--font-display); font-weight: 700; font-size: 2.05rem; line-height: 1.05; margin-top: 6px; color: var(--ink); }
.kpi .sub { margin-top: 6px; font-size: var(--t-sm); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: var(--t-sm); }
.delta.up { color: var(--pos); } .delta.down { color: var(--neg); }

/* ---- 7. Tabs + filter chips (REAL buttons) ------------------------------ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--s4); }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; font: inherit; font-weight: 700; font-size: var(--t-sm);
  color: var(--muted); cursor: pointer; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab:hover { color: var(--ink); }
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip {
  appearance: none; display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: #fff; font: inherit; font-weight: 700; font-size: var(--t-sm);
  color: var(--ink-2); cursor: pointer; transition: all .14s var(--ease);
}
.chip:hover { border-color: #c7cfdd; }
.chip[aria-pressed="true"] { background: var(--brand-wash); border-color: var(--brand-2); color: var(--brand-ink); }
.chip .count { background: var(--neutral-bg); color: var(--ink-2); border-radius: var(--r-pill); padding: 0 7px; font-size: var(--t-xs); }
.chip[aria-pressed="true"] .count { background: #fff; color: var(--brand-ink); }

/* ---- 8. Status pills (ONE set; dot + text, never color alone) ----------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 9px; border-radius: var(--r-pill);
  font-size: var(--t-xs); font-weight: 800; letter-spacing: .01em; border: 1px solid transparent;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; opacity: .9; }
.pill-neutral { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-bd); }
.pill-info    { color: var(--info);    background: var(--info-bg);    border-color: var(--info-bd); }
.pill-ok      { color: var(--ok);      background: var(--ok-bg);      border-color: var(--ok-bd); }
.pill-warn    { color: var(--warn);    background: var(--warn-bg);    border-color: var(--warn-bd); }
.pill-bad     { color: var(--bad);     background: var(--bad-bg);     border-color: var(--bad-bd); }

/* ---- 9. Data table (ONE style) ------------------------------------------ */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); }
.tbl thead th {
  position: sticky; top: 60px; z-index: 1;
  text-align: left; padding: 10px 14px; background: var(--canvas-2);
  border-bottom: 1px solid var(--line); color: var(--muted);
  font-weight: 800; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
}
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--brand-wash); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .strong { color: var(--ink); font-weight: 700; }
.tbl .neg { color: var(--neg); }
.tbl tfoot td { padding: 12px 14px; border-top: 2px solid var(--line); background: var(--brand-wash); font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: 70vh; }
/* .tbl-wrap is its own scroll container (overflow:auto), so a sticky header inside it
   is measured from the wrapper's top, not the page's. The 60px app-bar offset above would
   push the header down over the first row (live bug: PTO Verification, 2026-10-15). */
.tbl-wrap .tbl thead th { top: 0; }

/* ---- 10. Forms ----------------------------------------------------------- */
.field { display: grid; gap: 6px; margin-bottom: var(--s3); }
.field > label { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em; font-weight: 800; color: var(--ink-2); }
.field .req { color: var(--bad); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; font-size: var(--t-sm); color: var(--ink); background: #fff;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

/* ---- 11. Slide-over drawer (ONE pattern) -------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(10,35,80,.32); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(520px, 94vw);
  background: var(--surface); box-shadow: var(--sh-pop); transform: translateX(100%);
  transition: transform .26s var(--ease); z-index: 41; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: var(--s3); }
.drawer-head .x { margin-left: auto; }
.drawer-actions { display: flex; gap: var(--s2); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line); background: var(--canvas-2); }
.drawer-body { padding: var(--s5); overflow: auto; }
.dr-sec { margin-bottom: var(--s5); }
.dr-sec > h4 { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: var(--s2); }
.dr-row { display: flex; justify-content: space-between; gap: var(--s4); padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: var(--t-sm); }
.dr-row .k { color: var(--muted); } .dr-row .v { color: var(--ink); font-weight: 700; text-align: right; }
/* timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 var(--s4) var(--s4); font-size: var(--t-sm); }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.timeline .when { color: var(--muted); font-size: var(--t-xs); }

/* ---- 12. Misc: freshness pill, empty state, toast, banners -------------- */
.freshness { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-pill); font-size: var(--t-sm); color: var(--ink-2); background: #fff; }
.freshness .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.freshness.stale .dot { background: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: var(--s7) var(--s5); }
.empty .big { font-family: var(--font-display); font-size: 1.3rem; color: var(--ink-2); margin-bottom: 6px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-sm); font-size: var(--t-sm); border: 1px solid; }
.banner-info { background: var(--info-bg); border-color: var(--info-bd); color: var(--info); }
.banner-warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn); }

/* ---- 13. Report surface (brand-blue, print-faithful financial pages) ---- */
.report-masthead {
  background: linear-gradient(135deg, var(--navy), var(--brand-ink));
  color: #fff; border-radius: var(--r-md); padding: var(--s5) var(--s5);
  display: flex; align-items: flex-end; gap: var(--s4); flex-wrap: wrap;
}
.report-masthead .eyebrow { color: #b9d2ee; }
.report-masthead h1 { color: #fff; font-size: 1.7rem; }
.report-masthead .meta { margin-left: auto; text-align: right; font-size: var(--t-sm); color: #cfe0f4; }
.report-tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.report-tbl th { text-align: left; padding: 9px 12px; color: var(--muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em; border-bottom: 2px solid var(--brand); }
.report-tbl th.r, .report-tbl td.r { text-align: right; font-variant-numeric: tabular-nums; }
.report-tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
.report-tbl tr.group td { font-weight: 800; color: var(--navy-2); background: var(--canvas-2); text-transform: uppercase; font-size: var(--t-xs); letter-spacing: .05em; }
.report-tbl tr.subtotal td { font-weight: 800; border-top: 1px solid var(--line); background: var(--brand-wash); }
.report-tbl tr.total td { font-weight: 800; color: #fff; background: var(--navy-2); }
.report-tbl tr.total td.r { font-size: 1rem; }
.report-tbl td.neg, .report-tbl td.r.neg { color: var(--neg); }
.report-tbl tr.indent td:first-child { padding-left: 28px; color: var(--ink-2); }

/* ---- 14. Responsive ------------------------------------------------------ */
@media (max-width: 980px) {
  .grid-3, .grid-4, .kpis { grid-template-columns: repeat(2, 1fr); }
  .report-masthead .meta { margin-left: 0; text-align: left; }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4, .kpis, .row2 { grid-template-columns: 1fr; }
  .page { width: calc(100% - 24px); }
  .appbar { padding: 0 14px; }
  .tbl thead th { top: 0; }
}

/* ---- 15. Print (financial pages) ---------------------------------------- */
@media print {
  .appbar, .page-head .actions, .chips, .tabs { display: none !important; }
  body { background: #fff; }
  .card, .report-masthead { box-shadow: none; }
  .report-masthead { background: #fff; color: var(--navy-2); border: 1px solid var(--line); }
  .report-masthead h1, .report-masthead .eyebrow, .report-masthead .meta { color: var(--navy-2); }
  .nav-bar { display: none !important; }
}

/* ---- 16. nav.js compatibility -------------------------------------------
   v2 pages reuse static/nav.js UNCHANGED (it calls /auth/me and renders the
   shared header). nav.js emits .nav-bar > .nav-left > .nav-logo and
   .nav-user > .nav-username; .brand-mark/.brand-name/.brand-sub/.avatar are
   already styled above. These rules give that markup the v2 look so the
   header matches the new skin without forking nav.js.
   ------------------------------------------------------------------------- */
.nav-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s4);
  height: 60px; padding: 0 var(--s5);
  background: rgba(255,255,255,.9); backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-bar .nav-left { display: flex; align-items: center; gap: var(--s4); min-width: 0; }
.nav-bar .nav-logo { display: flex; align-items: center; gap: var(--s3); text-decoration: none; }
.nav-bar .nav-logo:hover { text-decoration: none; }
.nav-bar .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.nav-bar .brand-name { font-weight: 800; font-size: .96rem; color: var(--ink); }
.nav-bar .brand-sub { font-size: var(--t-xs); color: var(--muted); font-weight: 700; }
.nav-bar .nav-user { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }
.nav-bar .nav-username {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 14px 5px 5px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: #fff; font-weight: 700; font-size: var(--t-sm); color: var(--ink-2); white-space: nowrap;
}
.nav-bar .uname-text { font-weight: 700; }
.nav-bar .nav-logout {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: #fff; color: var(--ink-2); font: inherit; font-weight: 700; font-size: var(--t-sm);
  cursor: pointer; transition: all .15s var(--ease);
}
.nav-bar .nav-logout:hover { border-color: #c7cfdd; background: var(--canvas-2); color: var(--ink); }
.top-rail { height: 0; background: transparent; }

@media (max-width: 620px) {
  .nav-bar { padding: 0 14px; gap: 10px; }
  .nav-bar .brand-sub { display: none; }
  .nav-bar .uname-text { display: none; }
}
