/* app.css — ZK Group BoD Dashboard.
 *
 * Architecture is ported from deliverables/bod-dashboard/prototype/ — the same
 * views, filters, KPI grammar and status vocabulary. What changed is the brand:
 * the prototype's navy/gold is replaced by the group's own black on white.
 *
 * Every colour is a token or a color-mix() of tokens. No literals.
 * Black means "look here", never "bad". There is no accent hue at all.
 * English, LTR.
 */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-small);
  color: var(--ink);
  background: var(--panel);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }

.app { max-width: 1680px; margin: 0 auto; background: var(--panel); min-height: 100vh; }

/* ══ header ══════════════════════════════════════════════════════════ */

.header { background: var(--bg); border-bottom: 1px solid var(--line); }
.header-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); padding: 16px 28px;
}
.header-id { display: flex; align-items: center; gap: 16px; }
.header-id svg { display: block; height: 44px; width: auto; color: var(--ink); }
.header h1 { font-size: var(--fs-lead); font-weight: 700; letter-spacing: -.01em; }
.header h1 .accent { color: var(--accent); }
.breadcrumb { font-size: var(--fs-label); color: var(--ink-mute); margin-top: 4px; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.header .meta { display: flex; gap: 22px; font-size: var(--fs-label); color: var(--ink-mute); }
.header .meta b { color: var(--ink-soft); font-weight: 600; }

/* the prototype's PREVIEW banner, in this build's terms */
.demo-banner {
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: .16em;
  text-align: center;
  padding: 8px 20px;
}
.demo-banner b { color: var(--accent-hi); font-weight: 700; }

/* ══ top nav ═════════════════════════════════════════════════════════ */

.top-nav { display: flex; background: var(--bg); border-bottom: 1px solid var(--line); padding: 0 28px; }
.nav-tab {
  padding: 14px 24px 12px;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.nav-tab-sub { display: block; font-size: var(--fs-micro); color: var(--ink-mute); font-weight: 400; margin-top: 2px; }
.nav-spacer { margin-inline-start: auto; display: flex; align-items: center; gap: 16px; font-size: var(--fs-label); color: var(--ink-mute); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-mute); cursor: pointer; text-decoration: underline; }

/* ══ filter bar ══════════════════════════════════════════════════════ */

.filter-bar { background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 28px; position: sticky; top: 0; z-index: 5; }
.filter-row { display: flex; align-items: center; gap: 14px; }
.filter-row + .filter-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.filter-label { font-size: var(--fs-micro); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.filter-toggle { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.filter-toggle .opt {
  font-size: var(--fs-label);
  font-weight: 500;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  background: var(--bg);
}
.filter-toggle .opt:hover { border-color: var(--field); color: var(--ink); }
.filter-toggle .opt.active { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
/* carried from the prototype: a filter option whose data is only partly there */
.filter-toggle .opt.partial { border-style: dashed; color: var(--ink-mute); }
.filter-meta { margin-inline-start: auto; font-size: var(--fs-label); color: var(--ink-mute); }

/* ══ views ═══════════════════════════════════════════════════════════ */

.view { padding: 22px 28px 70px; }
.section-label {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-mute); margin: 26px 0 12px;
}
.section-label .badge {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .1em;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: 4px; padding: 2px 7px; margin-inline-start: 8px;
}

/* ══ KPI cards (group strip) ═════════════════════════════════════════ */

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-sm); }
.kpi-card {
  background: var(--bg); border: 1px solid var(--line);
  border-top: 3px solid var(--field);
  border-radius: var(--radius-sm); padding: 16px 18px;
}
.kpi-card.accent { border-top-color: var(--accent); }
.kpi-card .label { font-size: var(--fs-micro); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-mute); }
.kpi-card .value { font-size: 29px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; line-height: 1.1; }
.kpi-card .value.gap { font-size: 20px; color: var(--ink-mute); font-weight: 500; }
.kpi-card .delta { font-size: var(--fs-label); color: var(--ink-soft); margin-top: 5px; }
.kpi-card .sub-note { font-size: var(--fs-micro); color: var(--ink-mute); margin-top: 6px; line-height: 1.5; }
/* deltas are grey in both directions — the deck rule */
.kpi-card .delta.neg { color: var(--ink-soft); }

/* ══ KPI tiles (drill-down) ══════════════════════════════════════════ */

.kpi-tile-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: var(--gap-sm); }
.kpi-tile {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 15px 17px;
  position: relative;
}
.kpi-tile .knum {
  position: absolute; top: 12px; inset-inline-end: 14px;
  font-size: var(--fs-micro); font-weight: 700; color: var(--ink-mute);
}
.kpi-tile .label { font-size: var(--fs-label); font-weight: 600; color: var(--ink-soft); padding-inline-end: 26px; }
.kpi-tile .value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin-top: 9px; line-height: 1.15; }
.kpi-tile .delta { font-size: var(--fs-micro); color: var(--ink-soft); margin-top: 4px; }
.kpi-tile .breakdown { font-size: var(--fs-micro); color: var(--ink-mute); margin-top: 8px; line-height: 1.5; }
.kpi-tile.intra { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }

/* the three states a board KPI can be in */
.kpi-tile.measured { border-inline-start: 3px solid var(--accent); }
.kpi-tile.partial  { border-inline-start: 3px solid var(--field); }
.kpi-tile.absent   { border-inline-start: 3px solid var(--line); background: var(--panel); border-style: dashed; }
.kpi-tile.absent .value { color: var(--ink-mute); font-weight: 500; font-size: 19px; }
.kpi-tile.absent .label { color: var(--ink-mute); }

/* A KPI answered in a different unit than the board asked for says so, on the
 * tile. This is the guard against a count being read as money. */
.unit-warn {
  font-size: var(--fs-micro); color: var(--ink-soft); line-height: 1.5;
  margin-top: 8px; padding: 6px 8px;
  border-inline-start: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border-radius: 0 3px 3px 0;
}
.unit-warn b { color: var(--ink); }

.state-tag {
  display: inline-block; font-size: var(--fs-micro); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px; margin-top: 9px;
}
.state-tag.measured { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.state-tag.partial  { color: var(--ink-soft); background: var(--panel); border: 1px solid var(--line); }
.state-tag.absent   { color: var(--ink-mute); background: transparent; border: 1px dashed var(--field); }

/* ══ panels ══════════════════════════════════════════════════════════ */

.panel { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 20px; }
.panel-title { font-size: var(--fs-body); font-weight: 600; margin-bottom: 14px; }
.panel-sub { font-size: var(--fs-micro); color: var(--ink-mute); font-weight: 400; margin-inline-start: 8px; }
.mid { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--gap-sm); }
.grid-row { display: grid; grid-template-columns: 1fr 340px; gap: var(--gap-sm); }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-sm); }
.stack { display: grid; gap: var(--gap-sm); }

/* the prototype's chart empty state, as markup rather than an ECharts graphic */
.empty-state {
  display: grid; place-items: center; text-align: center;
  min-height: 190px; padding: 26px;
  border: 1px dashed var(--field); border-radius: var(--radius-sm);
  background: var(--panel);
}
.empty-state .et { font-size: var(--fs-body); font-weight: 700; color: var(--ink-mute); }
.empty-state .em { font-size: var(--fs-label); color: var(--ink-mute); margin-top: 7px; max-width: 46ch; line-height: 1.55; }
.empty-state .ec { font-size: var(--fs-micro); color: var(--accent); margin-top: 11px; font-weight: 600; }

.tab-placeholder {
  border-inline-start: 3px solid var(--field);
  background: var(--bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 22px 24px;
}
.tab-placeholder .tt { font-size: var(--fs-body); font-weight: 600; }
.tab-placeholder .tm { font-size: var(--fs-label); color: var(--ink-soft); margin-top: 8px; line-height: 1.6; }

/* ══ status vocabulary — carried whole from the prototype ════════════ */

/* Five states told apart by fill and ring. In a black-and-white system
 * there is no hue to lean on, so shape carries the whole distinction. */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.status-dot.yellow  { background: var(--field); }                                  /* watch: solid grey   */
.status-dot.red     { background: var(--accent); box-shadow: 0 0 0 2px var(--ink); }  /* action: ringed      */
.status-dot.gray    { background: var(--line); border: 1px solid var(--field); }   /* pending: faint      */
.status-dot.partial { background: var(--bg); border: 2px solid var(--accent); }       /* partial: hollow     */
.legend-item .status-dot { flex: none; margin-inline-end: 2px; }

.status-legend { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: var(--fs-micro); color: var(--ink-mute); }

/* ══ subsidiary cards + table ════════════════════════════════════════ */

.sub-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sub-card {
  border: 1px solid var(--line); border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 13px 15px; background: var(--bg);
  text-decoration: none; display: block; position: relative;
}
.sub-card:hover { box-shadow: var(--shadow); border-inline-start-color: var(--accent-lo); }
.sub-card.yellow { border-inline-start-color: var(--field); }
.sub-card.red    { border-inline-start-color: var(--accent-lo); }
.sub-card.gray   { border-inline-start-color: var(--line); background: var(--panel); }
.sub-card.gray:hover { box-shadow: none; }
.sub-card.partial { border-inline-start-width: 5px; border-inline-start-style: double; }
.click-hint { position: absolute; bottom: 12px; inset-inline-end: 14px; font-size: var(--fs-micro); color: var(--ink-mute); }
.sub-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sub-name { font-size: var(--fs-small); font-weight: 600; }
.sub-metric { font-size: var(--fs-lead); font-weight: 700; margin-top: 7px; letter-spacing: -.01em; }
.sub-metric.pending { font-size: var(--fs-small); color: var(--ink-mute); font-weight: 500; }
.sub-sub { font-size: var(--fs-micro); color: var(--ink-mute); margin-top: 4px; }

.sub-table { width: 100%; border-collapse: collapse; }
.sub-table th {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-mute); text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line);
}
.sub-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: var(--fs-label); }
.sub-table .center { text-align: center; }
.sub-table .right { text-align: end; font-variant-numeric: tabular-nums; }
.sub-table tbody tr:hover { background: var(--panel); }
.sub-table tr.vert-head td {
  background: var(--panel); font-weight: 700; font-size: var(--fs-micro);
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
}
.sub-table tr.is-pending td { color: var(--ink-mute); }
.sub-name-cell { font-weight: 600; color: var(--ink); text-decoration: none; }
.sub-name-cell .tag { display: block; font-weight: 400; font-size: var(--fs-micro); color: var(--ink-mute); margin-top: 2px; }
a.sub-name-cell:hover { color: var(--accent); }

/* ══ vertical rollup bars ════════════════════════════════════════════ */

.vertical-bars { display: grid; gap: 11px; }
.vertical-row { display: grid; grid-template-columns: minmax(96px, 150px) 1fr auto; align-items: center; gap: 12px; }
.vertical-row .vname { font-size: var(--fs-label); color: var(--ink); }
.vertical-row .vtrack { display: block; height: 20px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.vertical-row .vfill { display: block; height: 100%; background: var(--field); }
.vertical-row.hi .vfill { background: var(--accent); }
.vertical-row .vval { font-size: var(--fs-label); font-weight: 600; font-variant-numeric: tabular-nums; }
.vertical-row .vval.gap { color: var(--ink-mute); font-weight: 500; }

/* ══ drill-down identity + tabs ══════════════════════════════════════ */

.sub-id {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--gap); flex-wrap: wrap;
}
.sub-id .left { display: flex; align-items: center; gap: 16px; }
.logo-circle {
  width: 104px; height: 56px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  display: grid; place-items: center; overflow: hidden; background: var(--bg); flex: none;
}
.logo-circle img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 7px 10px; }
.sub-id .name { font-size: var(--fs-h3); font-weight: 700; letter-spacing: -.015em; }
.sub-id .tagline { font-size: var(--fs-label); color: var(--ink-mute); margin-top: 3px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  font-size: var(--fs-label); font-weight: 500; padding: 8px 15px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink-soft); cursor: pointer; text-decoration: none; background: var(--bg);
}
.tab:hover { border-color: var(--field); color: var(--ink); }
.tab.active { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }

.intra-section { margin-top: 26px; }
.intra-block { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 20px; }

/* ══ alerts ══════════════════════════════════════════════════════════ */

.alerts { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 20px; }
.alerts-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.alerts-title { font-size: var(--fs-body); font-weight: 600; }
.alerts-count {
  font-size: var(--fs-micro); font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 999px; padding: 3px 10px;
}
.alert-row { display: flex; gap: 13px; padding: 12px 0; border-top: 1px solid var(--line); }
.alert-row .alert-tag {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); background: var(--panel); border: 1px solid var(--line);
  border-radius: 3px; padding: 3px 8px; height: fit-content; white-space: nowrap;
}
.alert-row.hi .alert-tag { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); border-color: color-mix(in srgb, var(--accent) 26%, transparent); }
.alert-row .alert-body { font-size: var(--fs-label); color: var(--ink-soft); line-height: 1.6; }
.alert-row .alert-body b { color: var(--ink); }

/* ══ charts (inline SVG, server-rendered) ════════════════════════════ */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--ink-soft); }
.chart .seg { fill: var(--field); }
.chart .seg-hi { fill: var(--accent); }
.chart .seg:hover, .chart .seg-hi:hover { fill: var(--accent-lo); cursor: pointer; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke: var(--field); stroke-width: 1.5; stroke-dasharray: 5 5; fill: none; }
.chart .curve { stroke: var(--accent); stroke-width: 3; fill: none; }
.chart .fillzone { fill: color-mix(in srgb, var(--accent) 8%, transparent); }
.chart .lab { font-size: 11px; }
.chart .val { font-size: 12px; font-weight: 600; fill: var(--ink); }

.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 1.15fr) minmax(60px, 1fr) auto; align-items: center; gap: 12px; }
.hbar .name { font-size: var(--fs-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { display: block; height: 20px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--field); }
.hbar.hi .fill { background: var(--accent); }
.hbar .amt { font-size: var(--fs-label); font-weight: 600; text-align: end; font-variant-numeric: tabular-nums; }

/* ══ data tables ═════════════════════════════════════════════════════ */

.dtable { width: 100%; border-collapse: collapse; font-size: var(--fs-label); }
.dtable th { font-size: var(--fs-micro); font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-mute); text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.dtable td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.dtable td.num, .dtable th.num { text-align: end; font-variant-numeric: tabular-nums; }
.dtable tbody tr:hover { background: var(--panel); }
.dtable tr.is-gap td { color: var(--ink-mute); }
.scroll-y { max-height: 540px; overflow-y: auto; }

/* ══ the gap mark — blank is NEVER zero ══════════════════════════════ */

.gap { color: var(--ink-mute); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--field); margin-inline-start: 6px; vertical-align: 1px; }
.dot.measured { background: var(--accent); }
.dot.file { background: var(--ink); }

.gapnote {
  border-inline-start: 3px solid var(--field); padding: 11px 15px;
  background: var(--panel); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--fs-label); color: var(--ink-soft); margin-top: 14px; line-height: 1.6;
}
.gapnote b { color: var(--ink); }

.pickgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pick { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; text-decoration: none; display: block; background: var(--bg); }
.pick:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pick .pname { font-size: var(--fs-small); font-weight: 600; }
.pick .par { font-size: var(--fs-micro); color: var(--ink-mute); margin-top: 2px; }
.pick .pnum { font-size: var(--fs-h3); font-weight: 700; margin-top: 10px; font-variant-numeric: tabular-nums; }
.pick .plab { font-size: var(--fs-micro); color: var(--ink-soft); }
.pick.is-gap { background: var(--panel); border-style: dashed; }
.pick.is-gap:hover { border-color: var(--field); box-shadow: none; }
.pick.is-gap .pnum { color: var(--ink-mute); font-weight: 500; }

/* ══ auth ════════════════════════════════════════════════════════════ */

.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; background: var(--panel); }
.authcard { width: 100%; max-width: 430px; }
.authcard .brand { display: flex; justify-content: center; margin-bottom: 30px; }
.authcard .brand svg { height: 54px; width: auto; color: var(--ink); }
.authbox { border: 1px solid var(--line); border-radius: var(--radius); padding: 34px; background: var(--bg); }
.authbox h1 { font-size: var(--fs-h2); font-weight: 700; letter-spacing: -.02em; }
.authbox .lede { color: var(--ink-soft); margin-top: 10px; font-size: var(--fs-small); line-height: 1.55; }

label { display: block; font-size: var(--fs-label); font-weight: 600; color: var(--ink-soft); margin: 24px 0 8px; }
input[type="email"], input[type="text"], input[type="password"] {
  width: 100%; font: inherit; padding: 13px 15px;
  border: 1px solid var(--field); border-radius: var(--radius-sm);
  color: var(--ink); background: var(--bg);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input.code { font-size: 30px; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; padding-inline-start: .5em; }

.btn { width: 100%; font: inherit; font-weight: 600; padding: 14px; margin-top: 24px; border: 0; border-radius: var(--radius-sm); background: var(--accent); color: var(--bg); cursor: pointer; }
.btn:hover { background: var(--accent-lo); }
.btn.secondary { background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line); }
.btn:disabled { background: var(--panel); color: var(--ink-mute); cursor: not-allowed; }
.formnote { font-size: var(--fs-label); color: var(--ink-mute); margin-top: 14px; line-height: 1.55; }
.errorbox {
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  color: var(--accent-lo); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: var(--fs-label); margin-top: 20px;
}

/* ══ narrow ══════════════════════════════════════════════════════════ */

@media (max-width: 1080px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .mid, .grid-row, .charts-row { grid-template-columns: 1fr; }
  .pickgrid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .kpi-row, .sub-grid, .pickgrid { grid-template-columns: 1fr; }
  .view { padding: 16px 14px 60px; }
  .header-top, .top-nav, .filter-bar { padding-inline: 14px; }
}
