/* Evidentia Forge — Health System Growth demo, release 2026-10-17d.
   Extends forge.20261017c.css and reuses its tokens. Growing and declining keep the
   familiar green and red meaning, tuned for the dark ink ground; gold marks the
   current window, ice-blue the previous one, violet anything the model inferred. */

.hsg { --up: #7fd6a0; --down: #f08a7c; --panel: #08101b; }
.hsg .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Controls */
.hsg-controls {
  display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end;
  padding: 18px clamp(20px, 3vw, 32px); border-bottom: 1px solid var(--line);
  background: rgba(5, 9, 20, .35);
}
.hsg-field { display: grid; gap: 6px; min-width: 0; }
.hsg-field > span:first-child {
  color: var(--text-3); font-size: .68rem; letter-spacing: .18em; text-transform: uppercase;
}
.hsg-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 2px; }
.hsg-seg label { position: relative; }
.hsg-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.hsg-seg label span {
  display: block; padding: 8px 12px; min-height: 38px; line-height: 22px;
  font-size: .82rem; color: var(--text-2); white-space: nowrap;
}
.hsg-seg label + label span { border-left: 1px solid var(--line-strong); }
.hsg-seg input:checked + span { background: rgba(230, 184, 102, .14); color: var(--gold-soft); }
.hsg-seg input:hover + span { color: var(--gold-soft); }
.hsg-seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: -2px; }
.hsg select, .hsg input[type="search"] {
  font: inherit; font-size: .85rem; color: var(--text);
  background: var(--ink-3); border: 1px solid var(--line-strong); border-radius: 2px;
  min-height: 38px; padding: 6px 10px; max-width: 100%;
}
.hsg select:hover, .hsg input[type="search"]:hover { border-color: rgba(241, 211, 155, .5); }
.hsg input[type="search"] { width: 190px; }
.hsg input[type="search"]::placeholder { color: var(--text-3); }

/* Summary strip */
.hsg-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px; background: var(--line); border-bottom: 1px solid var(--line);
}
.hsg-kpi { background: var(--panel); padding: 14px clamp(16px, 2.4vw, 24px); display: grid; gap: 2px; align-content: start; }
.k-label { color: var(--text-3); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; }
.k-val { font-family: var(--font-mono); font-size: 1.35rem; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.35; }
.k-val .chg { font-size: inherit; }
.k-sep, .k-unit { color: var(--text-3); font-size: .85rem; font-family: var(--font-sans); }
.k-sub { color: var(--text-3); font-size: .78rem; }
.k-sub .tag { font-size: .6rem; padding: 0 6px; margin-left: 2px; }

/* Body: table beside detail */
.hsg-body { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.hsg-main { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.hsg-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 14px;
  padding: 10px clamp(16px, 2.4vw, 24px); border-bottom: 1px solid var(--line);
  color: var(--text-3); font-size: .82rem;
}
.hsg-crumb { color: var(--text-2); }
.hsg-crumb button {
  background: none; border: 0; padding: 4px 0; font: inherit; color: var(--gold-soft); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.hsg-scroll { max-height: 560px; overflow: auto; overscroll-behavior: contain; }

.hsg-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.hsg-table thead th {
  position: sticky; top: 0; z-index: 1; background: #0b1422;
  text-align: left; font-weight: 500; white-space: nowrap;
  color: var(--text-3); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase;
  padding: 0 8px; border-bottom: 1px solid var(--line-strong);
}
.hsg-table thead th:first-child, .hsg-table tbody th { padding-left: clamp(16px, 2.4vw, 24px); }
.hsg-table thead th:not([aria-sort]) { padding-block: 12px; }
.hsg-table thead button {
  background: none; border: 0; padding: 12px 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: pointer; display: inline-flex; gap: 4px; align-items: center;
}
.hsg-table thead button:hover, .hsg-table thead th[aria-sort="ascending"] button, .hsg-table thead th[aria-sort="descending"] button { color: var(--gold-soft); }
.sort-i { display: inline-block; width: .7em; }
.hsg-table .num { text-align: right; }
.hsg-table thead .num button { flex-direction: row-reverse; }
.hsg-table th.col-name { min-width: 210px; }
.hsg-table td, .hsg-table tbody th { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text-2); font-weight: 400; text-align: left; }
.hsg-table td.num { text-align: right; }
.hsg-table tbody tr { cursor: pointer; transition: background-color .15s; }
.hsg-table tbody tr:hover { background: rgba(255, 255, 255, .03); }
.hsg-table tbody tr.is-sel { background: rgba(230, 184, 102, .08); box-shadow: inset 3px 0 0 var(--gold); }
.hsg-name {
  background: none; border: 0; padding: 0; font: inherit; font-size: .95rem; color: var(--text);
  text-align: left; cursor: pointer;
}
.hsg-name:hover, tr.is-sel .hsg-name { color: var(--gold-soft); }
.hsg-sub { display: block; color: var(--text-3); font-size: .74rem; margin-top: 1px; }
.hsg-empty { text-align: center !important; padding: 36px 20px !important; color: var(--text-3) !important; }

.chg { font-family: var(--font-mono); white-space: nowrap; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.flat { color: var(--text-3); }
.ol { font-size: .78rem; white-space: nowrap; }
.ol b { font-family: var(--font-mono); font-weight: 400; margin-left: 2px; opacity: .85; }
.ol-acc { color: var(--up); }
.ol-risk { color: var(--down); }
.ol-steady { color: var(--text-3); }

.spark { width: 76px; height: 26px; display: block; }
.spark polyline { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .old { stroke: rgba(179, 209, 232, .25); }
.spark .prev { stroke: var(--blue); }
.spark .cur { stroke: var(--gold); }

/* Detail */
.hsg-detail { padding: clamp(20px, 3vw, 28px); display: grid; gap: 18px; align-content: start; min-width: 0; scroll-margin-top: calc(var(--header-h) + 12px); }
.hsg-d-head { display: grid; gap: 4px; }
.hsg-d-kicker { color: var(--blue); font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; }
.hsg-detail h4 { font-size: var(--step-2); font-weight: 300; line-height: 1.2; }
.hsg-nums { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.hsg-nums div { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.hsg-nums dt { color: var(--text-3); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; }
.hsg-nums dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 1.02rem; color: var(--text); font-variant-numeric: tabular-nums; }
.hsg-chart .bar-old { fill: rgba(179, 209, 232, .16); }
.hsg-chart .bar-prev { fill: var(--blue); opacity: .75; }
.hsg-chart .bar-cur { fill: var(--gold); }
.hsg-chart .bar-fc { fill: rgba(195, 168, 240, .16); stroke: var(--infer); stroke-width: 1; stroke-dasharray: 3 2; }
.hsg-chart .fc-t { fill: var(--infer); }
.hsg-key { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-3); font-size: .74rem; }
.hsg-key i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.hsg-key .k-prev { background: var(--blue); opacity: .75; }
.hsg-key .k-cur { background: var(--gold); }
.hsg-key .k-fc { border: 1px dashed var(--infer); background: rgba(195, 168, 240, .16); }
.hsg-block { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.hsg-o-big { font-size: 1.15rem; }
.hsg-o-big b { font-family: var(--font-mono); font-weight: 500; margin-left: 4px; }
.hsg-o-big span { display: block; font-size: .8rem; color: var(--text-3); margin-top: 2px; }
.hsg-drivers { display: grid; gap: 6px; }
.hsg-drivers li { position: relative; padding-left: 18px; color: var(--text-2); font-size: .9rem; line-height: 1.45; }
.hsg-drivers li::before { content: "•"; position: absolute; left: 2px; top: 0; color: var(--text-3); }
.hsg-drivers .pos::before { content: "▲"; color: var(--up); font-size: .62rem; top: .35em; }
.hsg-drivers .neg::before { content: "▼"; color: var(--down); font-size: .62rem; top: .35em; }
.hsg-def { color: var(--text-3); font-size: .86rem; line-height: 1.55; }
.hsg-def code { font-family: var(--font-mono); font-size: .8rem; color: var(--ice); background: rgba(144, 184, 214, .08); padding: 1px 5px; border-radius: 2px; }
.hsg-d-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Responsive */
@media (max-width: 1180px) and (min-width: 901px) {
  .hsg .col-spark { display: none; }
}
@media (max-width: 900px) {
  .hsg-body { grid-template-columns: minmax(0, 1fr); }
  .hsg-main { border-right: 0; border-bottom: 1px solid var(--line); }
  .hsg-scroll { max-height: 440px; }
}
@media (max-width: 640px) {
  .hsg .col-spark { display: none; }
  .hsg-table th.col-name { min-width: 0; }
  .hsg-table thead th { white-space: normal; }
  .hsg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hsg-kpi:first-child { grid-column: 1 / -1; }
  .k-val { font-size: 1.15rem; }
  .hsg-field-search { flex: 1 1 100%; }
  .hsg input[type="search"] { width: 100%; }
  .hsg-field:has(select) { flex: 1 1 calc(50% - 9px); }
  .hsg select { width: 100%; }
}
@media (max-width: 480px) {
  .hsg .col-cur { display: none; }
  .hsg-seg label span { padding: 8px 10px; }
  .ol b { display: none; }
  .hsg-nums dd { font-size: .92rem; }
}
