/* ============================================================
   Overview scoreboard, charts, timeline, project register, task table.
   Charts are inline SVG built by charts.js. The security policy forbids inline style="" attributes, so every colour
   comes from a class here and every size from an SVG attribute. Marks follow the dataviz guidance: thin marks, a 2px
   gap between adjacent fills, recessive grid, labels in text ink (never the series colour), no text on status fills.
   ============================================================ */

/* ---------- page furniture: headline sentence and ruled sections ---------- */
.headline { max-width: 30ch; font-family: var(--serif); font-size: var(--fs-hero); font-weight: 500; line-height: 1.12; letter-spacing: -0.012em; text-wrap: balance; }
.headline-sub { margin-top: var(--s2); max-width: 70ch; color: var(--ink-2); font-size: var(--fs-sm); }
.block { min-width: 0; padding-top: var(--s3); border-top: 2px solid var(--ink); }
.block-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s3); }
.block-title { font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; }
.block-sub { max-width: 52ch; margin-top: 2px; color: var(--ink-2); font-size: var(--fs-sm); }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s6) var(--s7); margin-top: var(--s6); }
.view-toggle { display: inline-flex; flex: none; overflow: hidden; border: 1px solid var(--rule-strong); border-radius: var(--r-control); }
.view-toggle button { min-height: 32px; padding: 3px var(--s3); background: var(--sheet); border: 0; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.view-toggle button + button { border-left: 1px solid var(--rule-strong); }
.view-toggle button:hover { background: var(--sheet-2); }
.view-toggle button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); font-weight: 600; }

/* ---------- the scoreboard: six figures on one ruled board, not six cards ---------- */
.scoreboard { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: var(--s6); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); }
.kpi {
  --accent: var(--st-progress);
  position: relative; display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: var(--s4) var(--s4) var(--s5);
  background: none; border: 0; border-left: 1px solid var(--rule); color: var(--ink); text-align: left; cursor: pointer;
  transition: background-color 0.15s;
}
.kpi:first-child { border-left: 0; }
.kpi::before { content: ""; position: absolute; top: -2px; left: 0; right: 0; height: 4px; background: var(--accent); }
.kpi:hover { background: var(--sheet); }
.tone-info { --accent: var(--st-progress); }
.tone-ok { --accent: var(--st-done); }
.tone-bad { --accent: var(--st-blocked); }
.tone-warn { --accent: var(--pr-high); }
.tone-neutral { --accent: var(--st-backlog); }
.kpi-figure { font-family: var(--serif); font-size: var(--fs-figure); font-weight: 600; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: lining-nums tabular-nums; }
.kpi-unit { margin-left: 2px; color: var(--ink-2); font-size: 0.4em; font-weight: 500; letter-spacing: 0; }
.kpi-name { margin-top: var(--s3); font-size: var(--fs-sm); font-weight: 600; }
.kpi-note { min-height: 3.2em; margin-top: 2px; color: var(--ink-2); font-size: var(--fs-sm); }
.kpi-bar { display: block; width: 100%; height: 8px; margin-top: var(--s2); }
.kpi-state { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--s2); font-size: var(--fs-sm); font-weight: 600; }
.state-bad { color: var(--st-blocked-ink); }
.state-ok { color: var(--st-done-ink); }
.state-warn { color: var(--warn-ink); }
.state-info { color: var(--st-progress-ink); }
.state-neutral { color: var(--ink-2); }

/* ---------- SVG colour classes (single source for fills, so dark mode follows automatically) ---------- */
.f-backlog { fill: var(--st-backlog); } .f-progress { fill: var(--st-progress); } .f-blocked { fill: var(--st-blocked); } .f-done { fill: var(--st-done); }
.t-backlog { fill: var(--st-backlog-tint); } .t-progress { fill: var(--st-progress-tint); } .t-blocked { fill: var(--st-blocked-tint); } .t-done { fill: var(--st-done-tint); }
.s-backlog { stroke: var(--st-backlog); } .s-progress { stroke: var(--st-progress); } .s-blocked { stroke: var(--st-blocked); } .s-done { stroke: var(--st-done); }
.f-critical { fill: var(--pr-critical); } .f-high { fill: var(--pr-high); } .f-medium { fill: var(--pr-medium); } .f-low { fill: var(--pr-low); }
.f-track { fill: var(--sheet-2); stroke: var(--rule); stroke-width: 1; }
.hatch-line { stroke: rgba(255, 255, 255, 0.75); stroke-width: 1.5; }
/* A sheet-coloured halo keeps labels readable where they cross the today line or a gridline. */
.svg-text, .svg-late { paint-order: stroke; stroke: var(--sheet); stroke-width: 3px; stroke-linejoin: round; font-family: var(--sans); font-size: 12px; }
.svg-text { fill: var(--ink-2); }
.svg-late { fill: var(--st-blocked-ink); font-weight: 600; }
.seg-gap { stroke: var(--sheet); stroke-width: 2; }
.defs-only { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- status mix ---------- */
.segbar { display: block; width: 100%; height: 30px; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s3); font-size: var(--fs-sm); }
.legend-item { display: inline-flex; align-items: center; gap: var(--s2); }
.legend-item b { font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 12px; height: 12px; flex: none; border-radius: 2px; }
.sw-backlog { background: var(--st-backlog); } .sw-progress { background: var(--st-progress); } .sw-blocked { background: var(--st-blocked); } .sw-done { background: var(--st-done); }
.sw-critical { background: var(--pr-critical); } .sw-high { background: var(--pr-high); } .sw-medium { background: var(--pr-medium); } .sw-low { background: var(--pr-low); }
.sw-today { width: 3px; background: var(--ink); }
.subhead { margin: var(--s5) 0 var(--s1); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }

/* ---------- bars ---------- */
.hbars { margin-top: var(--s1); }
.hbar-row { display: grid; grid-template-columns: minmax(120px, 36%) minmax(0, 1fr) 52px; align-items: center; gap: var(--s3); padding: 8px 0; border-top: 1px solid var(--rule); }
.hbar-row:first-child { border-top: 0; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-sm); }
.hbar-label .chip { margin-top: 2px; }
.hbar-track { display: block; width: 100%; height: 12px; }
.hbar-val { text-align: right; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }

/* ---------- attention and due-soon lists ---------- */
.attn-list { margin: 0; padding: 0; list-style: none; }
.attn-list li { border-top: 1px solid var(--rule); }
.attn-list li:first-child { border-top: 0; }
.attn-item { display: flex; align-items: flex-start; gap: var(--s3); width: 100%; padding: var(--s3) var(--s1); background: none; border: 0; border-radius: var(--r-control); color: var(--ink); text-align: left; cursor: pointer; transition: background-color 0.15s; }
.attn-item:hover { background: var(--sheet); }
.attn-glyph { display: inline-flex; flex: none; padding-top: 2px; font-size: 1.15rem; }
.attn-glyph.when-bad { color: var(--st-blocked-ink); } .attn-glyph.when-warn { color: var(--warn-ink); } .attn-glyph.when-neutral { color: var(--ink-2); }
.attn-main { display: block; flex: 1; min-width: 0; }
.attn-title { display: block; font-size: var(--fs-sm); font-weight: 600; word-break: break-word; }
.meta-row { display: flex; flex-wrap: wrap; gap: 2px 0; margin-top: 2px; color: var(--ink-2); font-size: var(--fs-sm); }
.meta-row > span { padding: 0 var(--s2); border-left: 1px solid var(--rule-strong); }
.meta-row > span:first-child { padding-left: 0; border-left: 0; font-variant-numeric: tabular-nums; }
.attn-when { flex: none; text-align: right; font-size: var(--fs-sm); font-weight: 600; }
.attn-when small { display: block; color: var(--ink-2); font-size: var(--fs-xs); font-weight: 400; }
.when-bad { color: var(--st-blocked-ink); } .when-warn { color: var(--warn-ink); } .when-ok { color: var(--st-done-ink); }
.empty-state { padding: var(--s4) 0; color: var(--ink-2); font-size: var(--fs-sm); }
.empty-state .icon { color: var(--st-done-ink); }

/* ---------- timeline (Gantt) ---------- */
.gantt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.gantt-tools .field-control { width: auto; min-width: 200px; }
.gantt-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--sheet); }
.gantt { min-width: 900px; }
.g-row { display: grid; grid-template-columns: 250px minmax(0, 1fr); align-items: center; min-height: 36px; border-top: 1px solid var(--rule); }
.g-row:first-child { border-top: 0; }
.g-head { position: sticky; top: 0; z-index: 3; background: var(--sheet-2); }
.g-proj { background: var(--sheet-2); }
.g-label { position: sticky; left: 0; z-index: 2; padding: var(--s1) var(--s3); overflow: hidden; background: var(--sheet); border-right: 1px solid var(--rule); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.g-proj .g-label, .g-head .g-label { background: var(--sheet-2); font-weight: 600; }
.g-proj .g-label { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.g-label small { flex: none; color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.g-track { min-width: 0; }
.g-track svg { display: block; width: 100%; height: 36px; overflow: visible; }
.g-head .g-track svg { height: 34px; }
.g-gridline { stroke: var(--rule); stroke-width: 1; }
.g-today { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 4 3; }
.g-today-label { fill: var(--ink); font-family: var(--sans); font-size: 11px; font-weight: 600; }
.g-bar { cursor: pointer; }
.g-bar-bg { stroke-width: 1.5; }
.g-bar:hover .g-bar-bg, .g-bar:focus-visible .g-bar-bg { stroke-width: 3; }
.g-bar:focus-visible { outline: none; }
.g-bar:focus-visible .g-bar-bg { stroke: var(--focus); stroke-width: 3; }
.g-proj-bar { fill: var(--ink-2); opacity: 0.5; }
.g-legend { margin-top: var(--s3); }

/* ---------- projects: a register of rows, not a wall of cards ---------- */
.register { border-top: 2px solid var(--ink); }
.reg-row { display: grid; grid-template-columns: 84px minmax(170px, 1fr) minmax(200px, 1.4fr) minmax(200px, 1.2fr); align-items: center; gap: var(--s3) var(--s5); padding: var(--s4) var(--s1); border-bottom: 1px solid var(--rule); }
.ring { width: 76px; height: 76px; flex: none; }
.ring-track { fill: none; stroke: var(--sheet-2); stroke-width: 10; }
.ring-arc { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring-arc.ring-ok { stroke: var(--st-done); } .ring-arc.ring-warn { stroke: var(--pr-high); } .ring-arc.ring-bad { stroke: var(--st-blocked); } .ring-arc.ring-empty { stroke: var(--st-backlog); }
.ring-text { fill: var(--ink); font-family: var(--serif); font-size: 26px; font-weight: 600; }
.reg-name { margin-bottom: var(--s1); font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; }
.proj-mix { display: block; width: 100%; height: 12px; }
.reg-counts { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }
.reg-next { color: var(--ink-2); font-size: var(--fs-sm); }
.reg-next b { display: block; color: var(--ink); font-weight: 600; }

/* ---------- task table ---------- */
.tbl-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s4); margin-bottom: var(--s3); }
.tbl-tools > div { flex: 1 1 160px; min-width: 140px; }
.tbl-quick { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.toggle-btn { display: inline-flex; align-items: center; gap: var(--s2); min-height: 36px; padding: 3px var(--s3); background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--r-control); color: var(--ink); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.toggle-btn:hover { background: var(--sheet-2); }
.toggle-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.tbl-count { margin: var(--s2) 0; color: var(--ink-2); font-size: var(--fs-sm); }
.table-wrap { overflow-x: auto; border-top: 2px solid var(--ink); }
.data-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th, .data-table td { padding: var(--s2) var(--s3); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--rule); }
.data-table thead th { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; border-bottom: 1px solid var(--rule-strong); }
.data-table tbody tr:hover { background: var(--sheet); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-2); }
.th-sort { display: inline-flex; align-items: center; gap: var(--s1); padding: 0; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; }
.th-sort:hover { color: var(--ink); }
.cell-title { max-width: 360px; }
.cell-title button { padding: 0; background: none; border: 0; color: var(--link); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.cell-title button:hover { text-decoration: underline; }
.pbar { display: inline-flex; align-items: center; gap: var(--s2); font-variant-numeric: tabular-nums; }
.pbar svg { width: 80px; height: 8px; }

/* ---------- tooltip ---------- */
.tooltip { position: fixed; z-index: 80; max-width: 320px; padding: var(--s2) var(--s3); background: var(--ink); color: var(--sheet); border-radius: var(--r-control); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); line-height: 1.4; white-space: pre-line; pointer-events: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .scoreboard { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3n + 1) { border-left: 0; }
  .kpi:nth-child(n + 4) { border-top: 1px solid var(--rule); }
}
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; gap: var(--s6); }
  .reg-row { grid-template-columns: 76px minmax(0, 1fr); }
  .reg-row > :nth-child(n + 3) { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: var(--s3) var(--s3) var(--s4); }
  .kpi:nth-child(3n + 1) { border-left: 1px solid var(--rule); }
  .kpi:nth-child(2n + 1) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  .kpi-figure { font-size: clamp(3.25rem, 15vw, 4.25rem); }
  .g-row { grid-template-columns: 150px minmax(0, 1fr); }
  .hbar-row { grid-template-columns: minmax(96px, 40%) minmax(0, 1fr) 46px; }
}
@media (max-width: 340px) {
  .scoreboard { grid-template-columns: 1fr; }
  .kpi, .kpi:nth-child(n) { border-left: 0; }
  .kpi:nth-child(n + 2) { border-top: 1px solid var(--rule); }
}

/* Touch screens: 44px targets. These live here, in the last stylesheet, so they beat the smaller desktop sizes above. */
@media (pointer: coarse) {
  .view-toggle button, .toggle-btn, .btn-small { min-height: 44px; }
  .view-toggle button { padding-left: var(--s4); padding-right: var(--s4); }
  .th-sort, .cell-title button { display: inline-flex; align-items: center; min-height: 44px; }
  .th-sort { min-width: 44px; }
  .attn-item { min-height: 56px; }
  .tbl-quick { gap: var(--s2); }
}

/* Must stay LAST: the hidden attribute has to beat every display rule above and in app.css (no !important needed). */
[hidden][hidden][hidden] { display: none; }
