/* Visual Insights portal prototype
   Brand: deep aubergine/plum, signature gold, violet secondary.
   Type: Fraunces for figures and headings, Jost for interface text. */

:root {
  --plum-900: #2A1733;
  --plum-800: #3A2146;
  --plum-600: #5C3A6E;
  --plum-100: #EFE8F2;
  --plum-50:  #F7F3F9;
  --ink: #241A2C;
  --muted: #6B6072;
  --line: #E6DEEA;
  --paper: #FBF9FC;
  --surface: #FFFFFF;
  --gold: #B8862F;
  --gold-bright: #D9B45C;
  --gold-soft: #F6EDD9;
  --violet: #7552B0;
  --violet-soft: #EEE8F8;
  --ok: #2E7A68;
  --ok-soft: #E3F1EC;
  --warn: #C07420;
  --warn-soft: #FBEEDD;
  --bad: #B03A3A;
  --bad-soft: #F8E4E3;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Jost', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --rail-w: 220px;
  --radius-s: 6px;
  --radius-m: 10px;
}

* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select, textarea, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; }

/* ---------- Rail ---------- */
.rail {
  width: var(--rail-w);
  flex: 0 0 var(--rail-w);
  background: var(--plum-900);
  color: #E9E1EE;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 8px 26px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 15px;
  background: var(--gold-bright); color: var(--plum-900);
}
.brand-text { font-family: var(--serif); font-size: 17px; font-weight: 500; letter-spacing: 0.01em; color: #fff; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a {
  text-decoration: none; padding: 9px 12px; border-radius: var(--radius-s);
  color: #CFC3D6; font-weight: 500;
}
.rail nav a:hover { background: var(--plum-800); color: #fff; }
.rail nav a[aria-current="page"] { background: var(--plum-800); color: #fff; box-shadow: inset 3px 0 0 var(--gold-bright); }
.client { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; }
.client-label { font-size: 12px; color: #A999B3; }
.client-name { font-family: var(--serif); font-size: 16px; color: #fff; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  padding: 10px 36px 12px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.filters { display: flex; gap: 14px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); }
.filters select {
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
  padding: 6px 28px 6px 10px; color: var(--ink); font-size: 14px;
}
.actions { display: flex; gap: 10px; }
.btn-quiet { background: none; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); border-color: var(--plum-600); }
.btn-ask { background: var(--plum-900); color: #fff; border: 0; border-radius: var(--radius-s); padding: 8px 14px; cursor: pointer; font-weight: 500; }
.btn-ask:hover { background: var(--plum-800); }
.btn-primary { background: var(--gold); color: #fff; border: 0; border-radius: var(--radius-s); padding: 8px 16px; cursor: pointer; font-weight: 600; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

#view { padding: 32px 36px 48px; flex: 1; outline: none; max-width: 1360px; width: 100%; }
.banner { margin: 16px 36px 0; padding: 12px 16px; border-radius: var(--radius-s); background: var(--warn-soft); color: #6E4310; }
.powered { padding: 14px 36px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.powered strong { font-family: var(--serif); font-weight: 600; color: var(--plum-900); }

/* ---------- Type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 500; color: var(--plum-900); margin: 0; }
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 21px; line-height: 1.25; }
h3 { font-size: 16px; line-height: 1.3; font-weight: 600; }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 72ch; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head p { margin: 0; color: var(--muted); font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Hero (overview) ---------- */
.hero { padding: 6px 0 4px; }
.hero-line {
  font-family: var(--serif); font-weight: 400; color: var(--plum-900);
  font-size: clamp(34px, 4.6vw, 58px); line-height: 1.08; letter-spacing: -0.015em; margin: 0; max-width: 20ch;
}
.hero-line .hero-count { font-weight: 600; }
.hero-line .hero-late { color: var(--bad); }
.hero-sub { margin: 14px 0 0; font-size: 17px; color: var(--muted); max-width: 70ch; }
.health-line { margin-top: 16px; display: inline-flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.health-line a { color: var(--plum-600); }

/* ---------- KPI strip ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-top: 28px;
}
.kpi { padding: 18px 20px 16px; border-right: 1px solid var(--line); text-decoration: none; display: flex; flex-direction: column; gap: 6px; }
.kpi:last-child { border-right: 0; }
a.kpi:hover { background: var(--plum-50); }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-family: var(--serif); font-size: 30px; line-height: 1.1; color: var(--plum-900); font-variant-numeric: tabular-nums; }
.kpi-value.bad { color: var(--bad); }
.kpi-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; width: fit-content;
  font-size: 11.5px; font-weight: 500; line-height: 1; padding: 4px 8px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap; cursor: help;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-certified { color: #7A5716; background: var(--gold-soft); border-color: #E8D3A6; }
.badge-certified-warn { color: #7A5716; background: var(--gold-soft); border-color: var(--warn); }
.badge-certified-issue { color: var(--bad); background: var(--bad-soft); border-color: #E7B9B6; }
.badge-pilot { color: var(--violet); background: var(--violet-soft); border: 1px dashed #B9A5DF; }
.badge-draft, .badge-retired { color: var(--muted); background: var(--plum-50); border-color: var(--line); }

/* ---------- Overview grid ---------- */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin-top: 32px; align-items: stretch; }
.overview-grid.even { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px 22px; }
.panel h2 { margin-bottom: 4px; }
.panel .hint { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }

/* State tile map */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.tile {
  aspect-ratio: 1 / 1; border-radius: var(--radius-s); border: 1px solid var(--line);
  padding: 7px 8px; gap: 2px; display: flex; flex-direction: column; justify-content: space-between;
  text-decoration: none; background: var(--plum-50); transition: transform 120ms ease; min-width: 0; overflow: hidden;
}
.tile:hover { transform: translateY(-1px); border-color: var(--plum-600); }
.tile.empty { visibility: hidden; }
.tile-code { font-family: var(--serif); font-weight: 600; font-size: 17px; color: var(--plum-900); }
.tile-count { font-family: var(--serif); font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
.tile-count small { font-family: var(--sans); font-size: 11px; color: var(--muted); margin-left: 3px; }
@container (max-width: 520px) { .tile-count small { display: none; } .tile-code { font-size: 15px; } .tile-count { font-size: 19px; } }
.tiles-wrap { container-type: inline-size; }
@container (max-width: 380px) { .tile { padding: 4px 5px; } .tile .hbar { display: none; } .tile-code { font-size: 12px; } .tile-count { font-size: 15px; } .tiles { gap: 4px; } }
.tile.dark .tile-code, .tile.dark .tile-count { color: #fff; }
.tile.dark .tile-count small { color: #D9CDE0; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 14px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* Health bar */
.hbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); min-width: 60px; }
.hbar span { display: block; height: 100%; }
.hbar .on { background: var(--ok); } .hbar .risk { background: var(--warn); } .hbar .late { background: var(--bad); }

/* Attention lists */
.att-block h3 { margin-top: 2px; }
.att-block h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.att-list { list-style: none; margin: 0; padding: 0; }
.att-list li + li { border-top: 1px solid var(--line); }
.att-list a { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 9px 2px; text-decoration: none; }
.att-list a:hover { background: var(--plum-50); }
.att-name { font-weight: 500; }
.att-meta { font-size: 12.5px; color: var(--muted); grid-column: 1; }
.att-value { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-family: var(--serif); font-size: 17px; font-variant-numeric: tabular-nums; }
.att-value.bad { color: var(--bad); } .att-value.warn { color: var(--warn); }
.empty-note { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--plum-50); }
th .badge { margin-left: 6px; vertical-align: 1px; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--plum-50); }
tr.clickable:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--plum-50); color: var(--plum-600); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.cell-strong { font-weight: 500; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: 1px; cursor: help; }
.dot-certified { background: var(--gold); } .dot-certified-warn { background: var(--surface); box-shadow: inset 0 0 0 2px var(--warn); } .dot-certified-issue { background: var(--bad); } .dot-pilot { background: var(--violet); }
.status-key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.status-key .dot { margin: 0 6px 0 0; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); }

/* ---------- Breadcrumb & stage flow ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--plum-600); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: #C7BCCD; }
.flow { display: flex; gap: 3px; margin-top: 18px; }
.flow-seg { min-width: 64px; padding: 10px 12px; background: var(--plum-100); color: var(--plum-900); display: flex; flex-direction: column; gap: 2px; }
.flow-seg:first-child { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.flow-seg:last-child { border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.flow-seg:nth-child(n+4) { background: #E2D6E9; }
.flow-seg:nth-child(6) { background: var(--plum-600); color: #fff; }
.flow-seg strong { font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1; }
.flow-seg span { font-size: 12.5px; }
.flow-seg em { font-style: normal; font-size: 11.5px; opacity: 0.8; }

/* ---------- Project page ---------- */
.proj-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px 24px; margin-top: 22px; }
.fact span { display: block; font-size: 12.5px; color: var(--muted); }
.fact strong { font-weight: 500; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.schedule-summary { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 14px; }
.big { font-family: var(--serif); font-size: 28px; color: var(--plum-900); line-height: 1.1; font-variant-numeric: tabular-nums; }
.big.bad { color: var(--bad); } .big.ok { color: var(--ok); } .big.warn { color: var(--warn); }
.big-label { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
svg text { font-family: var(--sans); }

/* Budget rows */
.brow { display: grid; grid-template-columns: 150px 1fr 120px; gap: 12px; align-items: center; padding: 7px 0; font-size: 13.5px; }
.brow + .brow { border-top: 1px solid var(--line); }
.btrack { position: relative; height: 12px; background: var(--plum-50); border-radius: 3px; }
.bbudget { position: absolute; inset: 0 auto 0 0; border: 1px solid #CDBFD5; border-radius: 3px; }
.bactual { position: absolute; inset: 2px auto 2px 2px; background: var(--plum-600); border-radius: 2px; }
.bactual.over { background: var(--bad); }
.bactual.contingency { background: var(--gold); }
.bval { text-align: right; font-variant-numeric: tabular-nums; }
.bval small { display: block; color: var(--muted); font-size: 11.5px; }

/* ---------- Finance ---------- */
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; }
.timeline-key { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 6px; }
.timeline-key i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; margin-right: 6px; vertical-align: 3px; }
.axis-label { fill: var(--muted); font-size: 11px; }

/* ---------- Health ---------- */
.score { font-family: var(--serif); font-size: 64px; line-height: 1; color: var(--plum-900); font-variant-numeric: tabular-nums; }
.score-row { display: flex; gap: 40px; flex-wrap: wrap; align-items: flex-end; }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat strong { font-family: var(--serif); font-size: 26px; font-weight: 500; }
.stat strong.bad { color: var(--bad); } .stat strong.warn { color: var(--warn); }
.view-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.vs { padding: 14px 16px; border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--surface); }
.vs h3 { font-size: 15px; margin-bottom: 6px; }
.vs.bad { border-left: 4px solid var(--bad); } .vs.warn { border-left: 4px solid var(--warn); } .vs.ok { border-left: 4px solid var(--ok); }
.vs p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ---------- Library ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 18px; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--plum-900); border-bottom-color: var(--gold); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--plum-900); color: #fff; border-color: var(--plum-900); }
.dict-table-head { margin: 26px 0 8px; }
.dict-table-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- States ---------- */
.loading { color: var(--muted); padding: 40px 0; display: flex; gap: 12px; align-items: center; }
.loading::before { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { background: var(--bad-soft); color: #7A2323; padding: 14px 16px; border-radius: var(--radius-s); margin: 16px 0; }
.error strong { display: block; margin-bottom: 4px; }

/* ---------- Assistant drawer ---------- */
.assistant {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(42, 23, 51, 0.12);
  display: flex; flex-direction: column; transform: translateX(105%); transition: transform 200ms ease; z-index: 50;
}
.assistant { visibility: hidden; transition: transform 200ms ease, visibility 0s linear 200ms; }
.assistant.open { transform: none; visibility: visible; transition: transform 200ms ease; }
.assistant-head { display: flex; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.assistant-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.assistant-tools { display: flex; gap: 6px; align-items: flex-start; white-space: nowrap; }
.btn-close { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.chat { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.msg-user { align-self: flex-end; background: var(--plum-900); color: #fff; padding: 9px 13px; border-radius: 12px 12px 2px 12px; max-width: 85%; }
.msg-bot { align-self: stretch; background: var(--plum-50); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px 12px 12px 2px; }
.msg-bot p { margin: 0 0 8px; } .msg-bot p:last-child { margin-bottom: 0; }
.msg-bot .table-wrap { margin: 10px 0 4px; max-height: 260px; overflow: auto; }
.msg-bot table { font-size: 12.5px; }
.msg-bot th, .msg-bot td { padding: 6px 9px; }
.msg-bot details { margin-top: 8px; font-size: 12.5px; }
.msg-bot pre { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); padding: 8px; border-radius: 6px; font-size: 12px; }
.msg-error { color: var(--bad); }
.suggest { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.suggest button { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; text-align: left; }
.suggest button:hover { border-color: var(--plum-600); }
.ask-form { display: flex; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.ask-form textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .overview-grid, .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { flex-direction: column; }
  .rail { position: static; height: auto; width: 100%; flex: none; flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; overflow-x: auto; }
  .brand { padding: 0; } .brand-text, .client { display: none; }
  .rail nav { flex-direction: row; }
  .rail nav a { white-space: nowrap; padding: 7px 10px; }
  .rail nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--gold-bright); }
  .topbar, #view, .powered { padding-left: 16px; padding-right: 16px; }
  .brow { grid-template-columns: 110px 1fr 90px; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpi .badge { white-space: normal; line-height: 1.25; }
  .overview-grid.even { grid-template-columns: 1fr; }
  .flow { flex-wrap: wrap; } .flow-seg { border-radius: var(--radius-s) !important; }
}
@media (max-width: 1080px) { .overview-grid.even { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Interactivity ---------- */
#view { transition: opacity 160ms ease; }
#view.updating { opacity: 0.55; pointer-events: none; }

.tip {
  position: fixed; z-index: 80; pointer-events: none; max-width: 280px;
  background: var(--plum-900); color: #EFE7F3; border-radius: 8px; padding: 9px 12px;
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 8px 24px rgba(42, 23, 51, 0.25);
  opacity: 0; transform: translateY(4px); transition: opacity 120ms ease, transform 120ms ease;
}
.tip.show { opacity: 1; transform: none; }
.tip strong { display: block; font-family: var(--serif); font-weight: 500; font-size: 14px; color: #fff; margin-bottom: 2px; }
.tip span { display: block; }

.ask-this {
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px 4px 9px;
  font-size: 12.5px; color: var(--plum-600); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.ask-this::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.ask-this:hover { border-color: var(--plum-600); background: var(--plum-50); }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.focus-chip { margin-top: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--plum-900);
  background: var(--gold-soft); border: 1px solid #E8D3A6; border-radius: var(--radius-s); padding: 8px 12px; width: fit-content; }
.focus-chip button { background: none; border: 0; padding: 0; color: var(--plum-600); text-decoration: underline; cursor: pointer; }
.focus-chip a { color: var(--plum-600); }

.segs { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin: 2px 0 10px; flex-wrap: wrap; }
.seg { background: var(--surface); border: 0; border-right: 1px solid var(--line); padding: 5px 10px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.seg:last-child { border-right: 0; }
.seg[aria-pressed="true"] { background: var(--plum-900); color: #fff; }

button.tile { font: inherit; text-align: left; cursor: pointer; width: 100%; color: inherit; }
.tile.selected { outline: 3px solid var(--gold); outline-offset: 1px; }
.tile.muted { opacity: 0.45; }
.tile.muted:hover { opacity: 0.8; }

.flow-seg { text-decoration: none; transition: opacity 120ms ease; }
.flow-seg:hover { filter: brightness(0.96); }
.flow-seg.selected { outline: 3px solid var(--gold); outline-offset: -3px; }
.flow-seg.muted { opacity: 0.45; }

.slicers { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 22px 0 12px; }
.slicers .chips { margin: 0; }
a.chip { text-decoration: none; color: var(--ink); }
.search input { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 11px; min-width: 220px; background: var(--surface); }

.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }
th.r .th-sort { justify-content: flex-end; }
.th-sort:hover { color: var(--plum-900); }
.th-sort .arrow { font-size: 9px; color: var(--gold); }

.bar-hit { cursor: pointer; }
.bar-hit:hover rect:last-child { filter: brightness(1.25); }
.bar-hit:focus-visible { outline: none; }
.bar-hit:focus-visible rect:first-child { stroke: var(--gold); stroke-width: 2; }
.btrack[data-tip], .hbar { cursor: default; }
.panel .section-head { align-items: center; }
.table-total { margin: 10px 2px 0; font-size: 13.5px; color: var(--muted); }
.proj-head + .kpis { margin-top: 22px; }
.lede a { color: var(--plum-600); }
.link-blue { color: #1F5FBF; font-weight: 500; text-decoration: none; margin-left: 4px; white-space: nowrap; }
.link-blue:hover { text-decoration: underline; }
td.nw { white-space: nowrap; }

/* ---------- Critical Tasks ---------- */
.tasks-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.matrix th, .matrix td { padding: 6px 8px; }
.matrix thead th { text-align: center; }
.matrix thead th:first-child, .matrix tbody th, .matrix tfoot th { text-align: left; }
.matrix tbody th { font-weight: 500; font-size: 13.5px; color: var(--ink); background: none; white-space: nowrap; }
.matrix tfoot th, .matrix tfoot td { border-top: 1px solid var(--line); background: var(--plum-50); font-size: 13px; }
.mx-phase { text-decoration: none; padding: 4px 6px; border-radius: 4px; }
.mx-phase:hover, .mx-phase.selected { background: var(--gold-soft); }
.mx-col { text-decoration: none; display: inline-block; padding: 2px; border-radius: 999px; }
.mx-col.selected { outline: 2px solid var(--gold); }
.mx-cell {
  display: grid; place-items: center; min-width: 64px; height: 40px; border-radius: 6px; text-decoration: none;
  font-family: var(--serif); font-size: 19px; color: var(--ink); font-variant-numeric: tabular-nums;
  border: 1px solid rgba(42, 23, 51, 0.06); transition: transform 100ms ease;
}
.mx-cell:hover { transform: scale(1.04); border-color: var(--plum-600); }
.mx-cell.dark { color: #fff; }
.mx-cell.zero { color: #C3B8C9; }
.mx-cell.selected { outline: 3px solid var(--plum-900); outline-offset: 1px; }
.mx-total { text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); }
tr.mx-dim th, tr.mx-dim td { opacity: 0.45; }
.pill.minor { background: var(--gold-soft); color: #7A5716; }
.kpi-tag { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--violet); background: var(--violet-soft); border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: 1px; }
.owner-link { color: #1F5FBF; text-decoration: none; font-weight: 500; }
.owner-link:hover { text-decoration: underline; }
.owner-link::after { content: ' ✉'; font-size: 12px; }
.count { font-family: var(--sans); font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.txt-bad { color: var(--bad); }
.done { color: var(--ok); font-weight: 500; }
@media (max-width: 1080px) { .tasks-grid { grid-template-columns: 1fr; } }

/* ---------- Project Plan (Gantt) ---------- */
.gantt-panel { padding: 16px 0 14px; }
.gantt-panel .legend { padding: 0 20px; }
.gantt-tools { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; padding: 0 20px 12px; }
button.chip { font: inherit; font-size: 13px; }
.gantt { --label-w: 330px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.g-head { display: grid; grid-template-columns: var(--label-w) 1fr; background: var(--plum-50); border-bottom: 1px solid var(--line); position: relative; z-index: 2; }
.g-head .g-label { padding: 8px 14px 8px 20px; font-size: 12.5px; color: var(--muted); }
.g-axis { position: relative; height: 34px; border-left: 1px solid var(--line); overflow: hidden; }
.g-tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid #E3DAE8; padding: 9px 0 0 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.g-tick.year { border-left-color: #C9BBD2; color: var(--plum-900); font-weight: 600; }
.g-scroll { max-height: 620px; overflow-y: auto; }
.g-body { position: relative; }
.g-row { display: grid; grid-template-columns: var(--label-w) 1fr; min-height: 38px; border-bottom: 1px solid #F0EAF3; cursor: pointer; }
.g-row:hover { background: var(--plum-50); }
.g-row:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.g-row.selected { background: var(--gold-soft); box-shadow: inset 4px 0 0 var(--gold); }
.g-row.lvl2 { background: #FCFBFD; } .g-row.lvl2:hover { background: var(--plum-50); }
.g-row.lvl3 { min-height: 32px; } .g-row.lvl2.selected, .g-row.lvl3.selected { background: var(--gold-soft); }
.g-label { display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 16px; min-width: 0; font-size: 13.5px; }
.g-row.lvl2 .g-label { padding-left: 36px; font-size: 13px; }
.g-row.lvl3 .g-label { padding-left: 62px; font-size: 12.5px; }
.g-name { min-width: 0; overflow: hidden; }
.g-name .cell-strong, .g-name .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-name .cell-sub { font-size: 11.5px; }
.g-caret { background: none; border: 0; width: 20px; height: 20px; flex: 0 0 20px; cursor: pointer; color: var(--plum-600); font-size: 13px; border-radius: 4px; padding: 0; }
.g-caret:hover { background: var(--plum-100); }
.g-spacer { width: 0; }
.g-kpi-ico { color: var(--violet); font-size: 10px; margin-right: 4px; vertical-align: 1px; }
.g-track { position: relative; border-left: 1px solid var(--line); }
.g-bar { position: absolute; top: 50%; transform: translateY(-50%); border-radius: 3px; }
.g-bar.planned { height: 16px; background: #EFE8F2; border: 1px solid #D8CCE0; }
.g-bar.planned.thin { height: 10px; }
.g-bar.actual.lvl1 { height: 8px; }
.g-bar.actual.lvl2 { height: 7px; }
.g-bar.actual.lvl3 { height: 5px; }
.g-mark { position: absolute; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; transform: translateX(-1px); }
.g-mark.target { background: var(--gold); } .g-mark.forecast { background: var(--violet); }
.g-diamond { position: absolute; top: 50%; width: 11px; height: 11px; transform: translate(-50%, -50%) rotate(45deg); background: var(--surface); border: 2px solid var(--c); z-index: 1; }
.g-diamond.done { background: var(--c); }
.g-today { position: absolute; top: 0; bottom: 0; left: calc(var(--label-w) + (100% - var(--label-w)) * var(--x) / 100); width: 0; border-left: 2px dashed rgba(107, 96, 114, 0.55); pointer-events: none; }
.lg-planned { background: #EFE8F2 !important; border: 1px solid #D8CCE0; }
.lg-diamond { display: inline-block; width: 9px; height: 9px; transform: rotate(45deg); border: 2px solid var(--violet); margin-right: 7px; vertical-align: 0; }
.lg-tick { display: inline-block; width: 3px; height: 12px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.lg-tick.gold { background: var(--gold); } .lg-tick.violet { background: var(--violet); }
.lg-today { display: inline-block; width: 0; height: 12px; border-left: 2px dashed #6B6072; margin-right: 6px; vertical-align: -1px; }
.btn-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
@media (max-width: 900px) { .gantt { --label-w: 200px; } }

/* ---------- Coverage map ---------- */
.map-panel { padding-bottom: 16px; }
.pmap { height: 540px; border-radius: var(--radius-m); overflow: hidden; border: 1px solid var(--line); background: #1d2430; margin-top: 6px; }
.map-msg { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--plum-50); border-radius: var(--radius-m); margin: 6px 0 0; }
.vi-pin-wrap, .vi-cluster-wrap { background: none; border: 0; }
.vi-pin { display: block; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,0.55); }
.vi-pin.approx { border-style: dashed; }
.vi-pin.sm { display: inline-block; width: 12px; height: 12px; border-width: 2px; margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 1px #D8CCE0; }
.vi-cluster { border-radius: 50%; display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.55); cursor: pointer; }
.vi-cluster span { width: 70%; height: 70%; border-radius: 50%; background: rgba(42, 23, 51, 0.92); color: #fff; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 14px; }
.vi-cluster.sm { display: inline-grid; width: 22px; height: 22px; margin-right: 6px; vertical-align: -6px; box-shadow: none; }
.vi-cluster.sm span { font-size: 9px; font-family: var(--sans); }
.vi-pop { font-family: var(--sans); font-size: 13px; min-width: 200px; }
.vi-pop strong { font-family: var(--serif); font-size: 15px; font-weight: 500; color: var(--plum-900); display: block; }
.vi-pop p { margin: 6px 0; }
.leaflet-container { font-family: var(--sans); }
.leaflet-popup-content-wrapper { border-radius: 10px; }

/* ---------- Data checks ---------- */
.pill.vi { background: var(--violet-soft); color: var(--violet); }
.btn-a { text-decoration: none; display: inline-flex; align-items: center; }
.key-cards .panel p { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
.key-cards .panel p .pill { margin-right: 6px; }
.filters-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-label { font-size: 12.5px; color: var(--muted); min-width: 96px; }
a.link-blue, .lede a.link-blue, .hint a.link-blue { color: #1F5FBF; }
.checks-table td { vertical-align: top; }
.checks-table td:nth-child(1) { width: 22%; } .checks-table td:nth-child(2) { width: 26%; }
.checks-table td:nth-child(3) { width: 18%; } .checks-table td:nth-child(4) { width: 20%; }
.cell-strong.wrap { white-space: normal; }
.checks-table .cell-sub + .cell-sub { margin-top: 2px; }
.checks-table .pill + .cell-sub { margin-top: 4px; }

/* ---------- PM Performance ---------- */
.ring { width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; flex: 0 0 var(--size); }
.ring span { width: 76%; height: 76%; border-radius: 50%; background: var(--surface); display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(var(--size) * 0.3); color: var(--plum-900); font-variant-numeric: tabular-nums; }
.pm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 22px; }
.pm-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; transition: border-color 120ms ease, transform 120ms ease; }
.pm-card:hover { border-color: var(--plum-600); transform: translateY(-1px); }
.pm-card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.pm-card strong { font-family: var(--serif); font-weight: 500; font-size: 16px; color: var(--plum-900); margin-top: 6px; }
.pm-card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.pm-rank { font-size: 12.5px; color: var(--muted); }
.pm-pillar { display: grid; grid-template-columns: 78px 1fr 26px; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.pm-pillar .btrack { height: 7px; } .pm-pillar .bactual { inset: 1px auto 1px 1px; }
.pm-pillar em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.heatmap th, .heatmap td { padding: 8px 10px; }
.heatmap .pillar-h { text-align: center; border-left: 1px solid var(--line); color: var(--plum-900); font-weight: 600; }
.heatmap .metric-h { white-space: normal; min-width: 92px; font-size: 11.5px; line-height: 1.3; vertical-align: bottom; cursor: help; }
.heatmap tbody th { text-align: left; background: none; font-weight: 400; white-space: nowrap; }
.heatmap td.heat { text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; border-left: 1px solid rgba(255,255,255,0.7); }
.heatmap tr.row-sel th, .heatmap tr.row-sel td { box-shadow: inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold); }
.score-chip { display: inline-block; min-width: 34px; text-align: center; color: #fff; border-radius: 6px; padding: 2px 6px; font-family: var(--serif); font-weight: 600; }
.pm-id { display: flex; gap: 16px; align-items: center; }
.pm-detail h3 { margin-bottom: 8px; }

.hint { color: var(--muted); font-size: 13.5px; }
.filter-note { margin: 0 0 16px; padding: 8px 12px; border-radius: var(--radius-s); background: var(--plum-50); border: 1px solid var(--line); color: var(--muted); font-size: 13.5px; width: fit-content; }
.filters select { max-width: 150px; padding-right: 22px; }
.filters { gap: 10px; }
.topbar { padding-left: 28px; padding-right: 28px; }
#btn-clear-filters { font-size: 13.5px; align-self: flex-end; padding-bottom: 7px; }
#f-client, #f-pm { max-width: 180px; }
