/* ==========================================================================
   WNC Resourcing — stylesheet
   Brand: navy #0E335B, gold #E2CA76, page #E9EEF3, typeface Asap.
   Utilisation is never signalled by colour alone: every band also carries
   a numeric value and a text label (WCAG 2.2 AA, 1.4.1 Use of Colour).
   ========================================================================== */

:root {
  --navy: #0E335B;
  --navy-800: #0A2745;
  --navy-600: #174879;
  --navy-300: #5C7EA5;
  --gold: #E2CA76;
  --gold-dark: #8A7327;
  --page: #E9EEF3;
  --surface: #FFFFFF;
  --surface-2: #F4F7FA;
  --line: #D3DCE6;
  --line-strong: #B4C1D0;
  --ink: #17222E;
  --ink-2: #495A6B;
  --ink-3: #6D7D8D;

  --band-free-bg: #EAEEF3;      --band-free-ink: #4A5A6B;
  --band-light-bg: #CFE1F6;     --band-light-ink: #0D4272;
  --band-healthy-bg: #C9E7D2;   --band-healthy-ink: #14522A;
  --band-full-bg: #F7E4AE;      --band-full-ink: #6A5210;
  --band-over-bg: #F7CFCF;      --band-over-ink: #8A1C1C;

  --ok: #1B6E3A;
  --warn: #8A6100;
  --bad: #A32020;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow-1: 0 1px 2px rgba(14, 51, 91, .10), 0 2px 8px rgba(14, 51, 91, .06);
  --shadow-2: 0 8px 28px rgba(14, 51, 91, .18);
  --row-h: 34px;
  --name-col: 250px;
  --cell-w: 62px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Asap, 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 .6rem; }

a { color: var(--navy-600); }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 3px;
}

.app-header :focus-visible { outline-color: var(--gold); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--gold); color: var(--navy-800);
  padding: .6rem 1rem; font-weight: 600; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ header */

.app-header {
  background: var(--navy);
  color: #fff;
  border-bottom: 4px solid var(--gold);
  position: sticky; top: 0; z-index: 60;
}

.header-top {
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.1rem;
  max-width: 1900px; margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand img { height: 34px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.08rem; letter-spacing: .01em; }
.brand-text span { font-size: .74rem; color: #C6D4E4; text-transform: uppercase; letter-spacing: .1em; }

.header-spacer { flex: 1 1 auto; }

.header-meta {
  display: flex; align-items: center; gap: .8rem;
  font-size: .8rem; color: #C6D4E4;
}
.header-meta .pill {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px; padding: .15rem .6rem;
  color: #fff; font-weight: 600; font-size: .74rem;
}

/* tabs */
.tabs {
  display: flex; gap: .15rem; padding: 0 1.1rem;
  max-width: 1900px; margin: 0 auto; overflow-x: auto;
}
.tab {
  appearance: none; border: 0; cursor: pointer;
  background: transparent; color: #CBD8E7;
  font: inherit; font-weight: 600; font-size: .92rem;
  padding: .55rem .95rem; border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.tab[aria-selected="true"] {
  background: var(--page); color: var(--navy); border-bottom-color: var(--gold);
}

/* ----------------------------------------------------------------- toolbar */

.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: .55rem 1.1rem;
  position: sticky; top: 0; z-index: 40;
}
.toolbar-inner {
  max-width: 1900px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: .55rem .9rem; align-items: center;
}

.field { display: flex; align-items: center; gap: .4rem; }
.field label { font-size: .78rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

input[type="text"], input[type="search"], input[type="date"], input[type="number"],
select, textarea {
  font: inherit; font-size: .88rem;
  padding: .32rem .5rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); min-height: 32px;
}
input[type="number"] { width: 5.5rem; }
select { min-width: 8rem; }
textarea { min-height: 60px; width: 100%; }

.switch { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--navy); }

.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: .86rem;
  padding: .38rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; gap: .35rem; min-height: 32px;
}
.btn:hover { background: var(--navy-600); }
.btn.secondary { background: #fff; color: var(--navy); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--navy); }
.btn.danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: #FBEDED; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--navy-800); }
.btn.gold:hover { background: #D8BC5E; }
.btn.small { font-size: .78rem; padding: .2rem .5rem; min-height: 26px; }
.btn-icon {
  appearance: none; cursor: pointer; background: transparent; border: 0;
  color: var(--ink-2); font: inherit; padding: .1rem .3rem; border-radius: 4px;
}
.btn-icon:hover { background: var(--surface-2); color: var(--navy); }

/* -------------------------------------------------------------------- main */

main { max-width: 1900px; margin: 0 auto; padding: 1rem 1.1rem 3rem; }

.view { display: none; }
.view.active { display: block; }

.view-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1rem;
  margin: .2rem 0 .9rem;
}
.view-head h2 { font-size: 1.3rem; color: var(--navy); }
.view-head .sub { font-size: .86rem; color: var(--ink-2); }
.view-head .grow { flex: 1 1 auto; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card-head {
  padding: .65rem .9rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .6rem;
}
.card-head h3 { font-size: .98rem; color: var(--navy); }
.card-head .grow { flex: 1 1 auto; }
.card-head .hint { font-size: .78rem; color: var(--ink-3); font-weight: 400; }
.card-body { padding: .9rem; }
.card-body.tight { padding: .4rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1rem; }
.stack { display: grid; gap: 1rem; }

/* ----------------------------------------------------------------- KPIs */

.kpis {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1rem;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--navy); border-radius: var(--radius);
  padding: .7rem .85rem; box-shadow: var(--shadow-1);
}
.kpi.gold { border-left-color: var(--gold); }
.kpi.good { border-left-color: var(--ok); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.bad { border-left-color: var(--bad); }
.kpi .label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); font-weight: 700;
}
.kpi .value { font-size: 1.75rem; font-weight: 700; color: var(--navy); line-height: 1.15; }
.kpi .value.small { font-size: 1.3rem; }
.kpi .foot { font-size: .78rem; color: var(--ink-2); }

/* --------------------------------------------------------------- timeline */

.timeline-wrap {
  overflow: auto; max-height: 74vh;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-1);
}

table.timeline { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }

table.timeline th, table.timeline td {
  padding: 0; margin: 0; border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); background: var(--surface);
}

table.timeline thead th {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-2); color: var(--navy);
  font-size: .72rem; font-weight: 700; text-align: center;
  height: 42px; min-width: var(--cell-w); width: var(--cell-w);
  border-bottom: 2px solid var(--line-strong);
}
table.timeline thead th .wk-month { display: block; font-size: .64rem; color: var(--ink-3); font-weight: 600; }
table.timeline thead th.is-current { background: #FBF3D8; box-shadow: inset 0 -3px 0 var(--gold); }

table.timeline th.rowhead, table.timeline td.rowhead {
  position: sticky; left: 0; z-index: 25;
  width: var(--name-col); min-width: var(--name-col); max-width: var(--name-col);
  text-align: left; padding: .25rem .5rem;
  border-right: 2px solid var(--line-strong);
  background: var(--surface);
}
table.timeline thead th.rowhead { z-index: 30; background: var(--surface-2); }

table.timeline td.rowhead.total, table.timeline td.total { background: var(--surface-2); font-weight: 600; }

tr.group-row td {
  background: var(--navy); color: #fff; position: sticky; left: 0;
  font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .25rem .5rem;
}
tr.group-row td.rowhead { background: var(--navy); color: #fff; z-index: 26; }

.person-cell { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.person-cell .disclose {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  color: var(--ink-2); width: 18px; height: 18px; flex: 0 0 18px;
  font-size: .7rem; line-height: 1; border-radius: 3px;
}
.person-cell .disclose:hover { background: var(--surface-2); color: var(--navy); }
.person-cell .who { min-width: 0; }
.person-cell .nm {
  font-size: .84rem; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; display: block;
}
.person-cell .rl {
  font-size: .7rem; color: var(--ink-3); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; display: block;
}
.person-cell .avatar {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--navy-300); color: #fff; font-size: .66rem; font-weight: 700;
  display: grid; place-items: center;
}
.person-cell.is-placeholder .avatar { background: #fff; color: var(--gold-dark); border: 2px dashed var(--gold-dark); }
.person-cell.is-placeholder .nm { font-style: italic; }

/* heat cells */
.cell {
  height: var(--row-h); width: var(--cell-w); min-width: var(--cell-w);
  position: relative; padding: 0; border: 0; margin: 0;
  cursor: pointer; font: inherit; display: block;
  background: transparent; text-align: center;
}
.cell:hover { box-shadow: inset 0 0 0 2px var(--navy); }
.cell .num { font-size: .76rem; font-weight: 700; font-variant-numeric: tabular-nums; position: relative; z-index: 2; }
.cell .bar {
  position: absolute; left: 3px; right: 3px; bottom: 3px; height: 3px;
  background: rgba(14, 51, 91, .14); border-radius: 2px; overflow: hidden;
}
.cell .bar i { display: block; height: 100%; background: currentColor; opacity: .8; }

td.b-free   .cell { background: var(--band-free-bg);   color: var(--band-free-ink); }
td.b-light  .cell { background: var(--band-light-bg);  color: var(--band-light-ink); }
td.b-healthy .cell { background: var(--band-healthy-bg); color: var(--band-healthy-ink); }
td.b-full   .cell { background: var(--band-full-bg);   color: var(--band-full-ink); }
td.b-over   .cell { background: var(--band-over-bg);   color: var(--band-over-ink); font-weight: 800; }
td.b-leave  .cell {
  color: #4A3268; font-weight: 600;
  background: repeating-linear-gradient(45deg, #EFE8F6 0 6px, #E2D6EF 6px 12px);
}
td.b-conflict .cell {
  background: var(--band-over-bg); color: var(--band-over-ink); font-weight: 800;
  border-top: 4px solid #7A5195;
}
td.b-conflict .cell::after {
  content: ''; position: absolute; inset: 0;
  border: 2px solid #7A5195; pointer-events: none;
}
td.b-unavailable .cell {
  color: var(--ink-3);
  background:
    repeating-linear-gradient(45deg, #E4E9EF 0 5px, #D6DDE5 5px 10px);
}
td.b-over .cell::after {
  content: ''; position: absolute; inset: 0;
  border: 2px solid var(--band-over-ink); pointer-events: none;
}
.cell.drag-sel { box-shadow: inset 0 0 0 3px var(--navy); }
.cell.drag-sel::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(14, 51, 91, .12);
}

td.has-leave .cell { box-shadow: inset 0 3px 0 #7A5195; }
td.is-current-week { border-left: 2px solid var(--gold); border-right: 2px solid var(--gold); }

/* assignment sub-rows */
tr.assign-row td.rowhead { background: var(--surface-2); }
tr.assign-row .assign-name {
  font-size: .76rem; padding-left: 28px; display: flex; align-items: center; gap: .35rem;
}
tr.assign-row .swatch { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 9px; }
tr.assign-row .assign-cell { height: 26px; }
.abar {
  position: absolute; inset: 3px 1px; border-radius: 3px;
  display: grid; place-items: center; color: #fff;
  font-size: .7rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.abar.tentative {
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 4px, transparent 4px 8px);
}
tr.assign-row td { background: var(--surface-2); }
tr.assign-row td .cell { background: transparent; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: .35rem .8rem; align-items: center; font-size: .78rem; color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: .35rem; }
.legend .chip {
  width: 26px; height: 15px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .12);
  display: inline-block;
}
.chip.b-free { background: var(--band-free-bg); }
.chip.b-light { background: var(--band-light-bg); }
.chip.b-healthy { background: var(--band-healthy-bg); }
.chip.b-full { background: var(--band-full-bg); }
.chip.b-over { background: var(--band-over-bg); border-color: var(--band-over-ink); }
.chip.b-leave { background: repeating-linear-gradient(45deg, #EFE8F6 0 4px, #E2D6EF 4px 8px); }
.chip.b-conflict { background: var(--band-over-bg); border: 2px solid #7A5195; }
.chip.b-partleave { background: #fff; box-shadow: inset 0 3px 0 #7A5195; }

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

table.data { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data th, table.data td { padding: .42rem .6rem; text-align: left; border-bottom: 1px solid var(--line); }
table.data thead th {
  background: var(--navy); color: #fff; font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; z-index: 5;
}
table.data tbody tr:nth-child(even) td { background: var(--surface-2); }
table.data tbody tr:hover td { background: #EFF4F9; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.mono { font-family: var(--mono); font-size: .8rem; }
.table-scroll { max-height: 62vh; overflow: auto; }

.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .45rem;
  border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.badge.confirmed { background: #DCEBDF; color: #14522A; border-color: #A9CDB2; }
.badge.tentative { background: #FBF0D3; color: #6A5210; border-color: #E0CB8E; }
.badge.complete { background: #E6EAEF; color: #4A5A6B; border-color: #C6CFD9; }
.badge.contract { background: #E3E8FB; color: #2A3A8C; border-color: #B9C3EE; }
.badge.placeholder { background: #fff; color: var(--gold-dark); border: 1px dashed var(--gold-dark); }
.badge.billable { background: #E1EEF6; color: #0D4272; border-color: #B3D2E6; }
.badge.nonbill { background: #F1EDF6; color: #573A78; border-color: #D2C4E4; }
.badge.over { background: var(--band-over-bg); color: var(--band-over-ink); border-color: var(--band-over-ink); }
.badge.ok { background: var(--band-healthy-bg); color: var(--band-healthy-ink); border-color: #A9CDB2; }

.meter { display: block; height: 8px; background: #E2E8EF; border-radius: 4px; overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--navy); }
.meter i.over { background: var(--bad); }
.meter i.full { background: var(--gold-dark); }
.meter i.good { background: var(--ok); }

.swatch-inline { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; }

/* ------------------------------------------------------------------ charts */

.chart { width: 100%; display: block; }
.chart text { font-family: Asap, system-ui, sans-serif; }
.chart .axis-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .lbl { font-size: 10px; fill: var(--ink-3); }
.chart .lbl-strong { font-size: 11px; fill: var(--ink-2); font-weight: 600; }
.chart .val { font-size: 10px; fill: var(--ink-2); font-weight: 700; }

.chart-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .78rem; color: var(--ink-2); margin-top: .4rem; }
.chart-legend .key { display: inline-flex; align-items: center; gap: .3rem; }
.chart-legend .box { width: 12px; height: 12px; border-radius: 2px; }

/* ----------------------------------------------------------------- dialogs */

dialog {
  border: 0; border-radius: var(--radius); padding: 0;
  box-shadow: var(--shadow-2); max-width: 620px; width: calc(100% - 2rem);
  color: var(--ink); background: var(--surface);
}
dialog::backdrop { background: rgba(10, 39, 69, .55); }
.dlg-head {
  background: var(--navy); color: #fff; padding: .7rem .9rem;
  display: flex; align-items: center; gap: .6rem;
  border-bottom: 3px solid var(--gold);
}
.dlg-head h3 { font-size: 1rem; flex: 1 1 auto; }
.dlg-head .btn-icon { color: #CBD8E7; font-size: 1.1rem; }
.dlg-head .btn-icon:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.dlg-body { padding: .9rem; display: grid; gap: .7rem; max-height: 68vh; overflow: auto; }
.dlg-foot {
  padding: .7rem .9rem; border-top: 1px solid var(--line);
  display: flex; gap: .5rem; align-items: center; background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.dlg-foot .grow { flex: 1 1 auto; }

.form-row { display: grid; gap: .25rem; }
.form-row > label { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.form-row .help { font-size: .74rem; color: var(--ink-3); }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.form-cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .7rem; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }

.callout {
  border-left: 4px solid var(--gold); background: #FCF7E6;
  padding: .55rem .7rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .84rem; color: #5A4A14;
}
.callout.bad { border-left-color: var(--bad); background: #FBEDED; color: #7A1B1B; }
.callout.good { border-left-color: var(--ok); background: #EDF6EF; color: #14522A; }

/* ------------------------------------------------------------------ toasts */

#toasts {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 300;
  display: grid; gap: .5rem; max-width: 340px;
}
.toast {
  background: var(--navy); color: #fff; padding: .55rem .8rem;
  border-radius: var(--radius); box-shadow: var(--shadow-2);
  font-size: .85rem; border-left: 4px solid var(--gold);
  animation: toast-in .18s ease-out;
}
.toast.bad { border-left-color: #F08A8A; }
.toast.good { border-left-color: #86D69C; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------- misc */

.empty {
  padding: 1.6rem; text-align: center; color: var(--ink-3);
  font-size: .9rem; border: 2px dashed var(--line-strong); border-radius: var(--radius);
}

.inline-list { display: flex; flex-wrap: wrap; gap: .3rem; }

.footnote { font-size: .78rem; color: var(--ink-3); margin-top: .6rem; }

.site-footer {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: .8rem 1.1rem; font-size: .78rem; color: var(--ink-3);
}
.site-footer .inner { max-width: 1900px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }

@media (max-width: 720px) {
  :root { --name-col: 168px; --cell-w: 52px; }
  .header-meta { display: none; }
  .form-cols, .form-cols-3 { grid-template-columns: 1fr; }
}

@media print {
  .app-header, .toolbar, .site-footer, #toasts { display: none; }
  .timeline-wrap { max-height: none; overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition: none !important; }
}
