/* VA Compensation Dashboard. Loads after tokens.css and maps the page's
   working names onto the OA design tokens, so light/dark follow the rest
   of the app. Layout: navy top bar + tab rail, one column of tiles, charts,
   then the actionable table. */
:root {
  --bg: var(--color-bg); --surface: var(--color-surface); --ink: var(--color-text); --muted: var(--color-text-muted);
  --line: var(--color-border); --hover: var(--color-surface-sunken);
  --accent: var(--color-primary); --accent-ink: #ffffff; --accent-soft: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
  --good: var(--color-on-track); --good-soft: color-mix(in srgb, var(--color-on-track) 16%, var(--color-surface));
  --warn: var(--color-at-risk-text); --warn-soft: var(--color-at-risk-bg);
  --crit: var(--color-critical-text); --crit-soft: var(--color-critical-bg);
  --bar: color-mix(in srgb, var(--color-primary) 45%, var(--color-surface));
  --gradient: linear-gradient(135deg, var(--color-header-gradient-start) 0%, var(--color-header-gradient-end) 100%);
  --pill-active: linear-gradient(135deg, var(--color-nav-active-start) 0%, var(--color-nav-active-mid) 50%, var(--color-nav-active-start) 100%);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; }

/* top bar + tabs */
header.top { position: sticky; top: 0; z-index: 20; }
.bar1 { background: var(--gradient); color: #fff; }
.bar1 .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; min-height: var(--topbar-height); padding-block: 10px; }
.brand { font-weight: 700; font-size: 18px; margin: 0; }
.brand small { display: block; font-weight: 400; font-size: 12.5px; opacity: .8; }
.bar1 .muted { color: rgba(255, 255, 255, .8); font-size: 13px; }
.bar1 .label { color: rgba(255, 255, 255, .8); }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.bar1 .seg { border-color: rgba(255, 255, 255, .35); background: transparent; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font-sans); padding: 7px 12px; cursor: pointer; }
.bar1 .seg button { color: rgba(255, 255, 255, .85); }
.seg button[aria-pressed="true"] { background: var(--pill-active); color: #fff; }
.btn-ghost { border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff; border-radius: var(--radius); padding: 7px 12px; font: 600 13px var(--font-sans); cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, th.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tabrail { background: var(--surface); box-shadow: var(--shadow-card); border-bottom: 1px solid var(--line); }
nav.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-block: 8px; }
nav.tabs a { flex: none; padding: 8px 16px; color: var(--muted); text-decoration: none; font-weight: 500; border-radius: var(--radius); }
nav.tabs a[aria-current="page"] { color: #fff; font-weight: 600; background: var(--pill-active); box-shadow: var(--shadow-nav-active); }

.label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
main { padding-block: 24px 64px; display: grid; gap: 22px; }
h2 { font-weight: 700; font-size: 24px; margin: 0; text-wrap: balance; }
h3 { font-weight: 600; font-size: 16px; margin: 0 0 12px; }
.q { color: var(--muted); margin: 4px 0 0; max-width: 68ch; }

/* tiles + panels: shadow only, no border */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile, .panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); min-width: 0; }
.tile { padding: 16px 18px; }
.panel { padding: 16px 18px; }
.tile .v { font-size: 1.6rem; font-weight: 700; margin-top: 4px; color: var(--accent); }
.tile .s { font-size: 13px; color: var(--muted); }
.tile.warn .v { color: var(--warn); } .tile.crit .v { color: var(--crit); } .tile.good .v { color: var(--good); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }

/* charts */
.hbar { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 64px; align-items: center; gap: 10px; font-size: 14px; margin-block: 7px; }
.hbar .track { position: relative; height: 18px; background: var(--hover); border-radius: 4px; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--bar); }
.hbar .fill.warn { background: var(--warn); } .hbar .fill.crit { background: var(--crit); } .hbar .fill.good { background: var(--good); }
.hbar .num { text-align: right; font-weight: 600; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yearbars { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: end; height: 190px; margin-top: 6px; }
.yb { display: grid; grid-template-rows: auto 1fr auto; height: 100%; text-align: center; gap: 4px; min-width: 0; }
.yb .col { position: relative; background: var(--hover); border-radius: 6px; overflow: hidden; }
.yb .col span { position: absolute; left: 0; right: 0; bottom: 0; background: var(--gradient); border-radius: 6px 6px 0 0; }
.yb b { font-size: 14px; } .yb small { color: var(--muted); font-size: 12px; }
.histo { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; align-items: end; height: 140px; }
.histo div { background: var(--bar); border-radius: 3px 3px 0 0; }
.histo div.crit { background: var(--crit); } .histo div.warn { background: var(--warn); } .histo div.good { background: var(--good); }
.histo-x { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 4px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.filters label { display: grid; gap: 4px; }
select, input[type="search"], input[type="number"], input[type="password"] { font: 15px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }
input[type="number"] { width: 72px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: 600 13px var(--font-sans); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.chip .n { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* tables: navy gradient header */
.tablewrap { overflow-x: auto; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card); }
table { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--gradient); color: #fff; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: none; position: sticky; top: 0; }
td.r, th.r { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--hover); }
th.sort { cursor: pointer; user-select: none; }
th.sort[aria-sort="ascending"]::after { content: " \2191"; }
th.sort[aria-sort="descending"]::after { content: " \2193"; }
.hist-table table { min-width: 640px; }

.link { color: var(--accent); font-weight: 600; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.pill.good { background: var(--good-soft); color: var(--good); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.neutral { background: var(--hover); color: var(--muted); } .pill.acc { background: var(--accent-soft); color: var(--accent); }
.muted { color: var(--muted); }
.approx { color: var(--warn); font-weight: 700; cursor: help; }
.list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.list li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 7px; }
.list li:last-child { border-bottom: 0; }
.note { font-size: 13px; color: var(--muted); }
.defs { display: grid; margin: 0; }
.defs div { display: grid; grid-template-columns: minmax(150px, 240px) 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.defs div:last-child { border-bottom: 0; }
.defs dt { font-weight: 700; } .defs dd { margin: 0; color: var(--muted); max-width: 68ch; }
.settings { display: flex; flex-wrap: wrap; gap: 14px; }
.settings label { display: grid; gap: 4px; font-size: 13px; }
.hidden-note { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; color: var(--muted); font-size: 14px; }
details.issues summary { cursor: pointer; font-weight: 600; }
details.issues ul { font-size: 13px; color: var(--muted); max-height: 320px; overflow: auto; padding-left: 18px; }
.srcs a { color: var(--accent); }
.status-msg { padding: 40px 0; color: var(--muted); }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%); background: var(--surface); z-index: 41; overflow-y: auto; padding: 20px 22px 30px; box-shadow: -4px 0 24px rgba(0, 0, 0, .15); }
.drawer h2 { font-size: 21px; }
.close { float: right; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 5px 10px; cursor: pointer; font: 600 13px var(--font-sans); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.kv div { background: var(--hover); border-radius: 8px; padding: 9px 11px; }
.kv b { display: block; font-size: 17px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-card); padding: 28px 26px; display: grid; gap: 14px; }
.login-card .brand small { color: var(--muted); opacity: 1; }
.login-card form { display: grid; gap: 12px; }
.login-card label { display: grid; gap: 5px; font-weight: 600; font-size: 14px; }
.login-card input { width: 100%; }
.btn { background: var(--pill-active); color: #fff; border: 0; border-radius: var(--radius); padding: 10px 14px; font: 600 15px var(--font-sans); cursor: pointer; }
.lg-err { color: var(--crit); font-weight: 600; margin: 0; font-size: 14px; }

@media (max-width: 560px) {
  .wrap { padding-inline: 16px; }
  .hbar { grid-template-columns: 96px 1fr 52px; }
  .defs div { grid-template-columns: 1fr; gap: 4px; }
  .tile .v { font-size: 22px; }
}
@media (prefers-reduced-motion: no-preference) { .fill { transition: width .3s ease; } }

/* refresh banner + sign-in lock */
.btn-ghost:disabled { opacity: .7; cursor: wait; }
#banner-wrap { padding-top: 16px; }
.banner { padding: 10px 14px; border-radius: var(--radius); background: var(--accent-soft); color: var(--ink); font-size: 14px; box-shadow: var(--shadow-card); }
.banner.err { background: var(--crit-soft); color: var(--crit); font-weight: 600; }
.lg-locked { background: var(--crit-soft); border-radius: 8px; padding: 10px 12px; line-height: 1.4; }

/* light/dark toggle: shows the mode it switches to */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff; border-radius: var(--radius); padding: 7px 12px; font: 600 13px var(--font-sans); cursor: pointer; }
.theme-toggle:hover { background: rgba(255, 255, 255, .12); }
.theme-toggle .ico-sun { display: none; }
.theme-toggle.is-dark .ico-sun { display: inline; }
.theme-toggle.is-dark .ico-moon { display: none; }
.login-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }
.login-theme .theme-toggle { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.login-theme .theme-toggle:hover { background: var(--hover); }
@media (max-width: 560px) { .theme-toggle [data-theme-label] { display: none; } }
