/* =====================================================================
   PENS Executive Dashboard — App + component styles
   Built on Sentra tokens (colors_and_type.css). Light "instrument admin".
   ===================================================================== */

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "brand topbar" "rail main";
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-canvas);
}

/* Brand block (top-left) */
.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-right: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
  background: var(--graphite-900);
}
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: var(--radius-2);
  background: var(--gold-400);
  color: var(--graphite-900);
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2), 0 0 16px rgba(248,217,19,.35);
}
.brand-name { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name b { color: var(--graphite-0); font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.brand-name span { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-300); }

/* Top bar */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.1; margin-right: auto; }
.topbar-title b { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.topbar-title span { font-size: 11.5px; color: var(--fg-3); }
.topbar-meta { display: flex; align-items: center; gap: 18px; }
.topbar-clock { font-family: var(--font-mono); font-size: 12px; color: var(--fg-2); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.topbar-clock b { color: var(--fg-1); font-weight: 600; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--status-normal); }
.live-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--status-normal); box-shadow: 0 0 0 3px var(--status-normal-bg); animation: pulse 2.4s var(--ease-standard) infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Left rail */
.rail {
  grid-area: rail;
  background: var(--graphite-900);
  border-right: 1px solid var(--border-default);
  display: flex; flex-direction: column;
  padding: 10px 10px 14px;
  overflow-y: auto;
}
.rail-group-label { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--graphite-500); padding: 12px 10px 8px; }
.rail-ico { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; }
.rail-ico svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* Parent (scope) row */
.rail-sec { margin-bottom: 4px; }
.rail-parent {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 11px; border-radius: var(--radius-2);
  background: transparent; border: 1px solid transparent;
  color: var(--graphite-200); cursor: pointer; text-align: left;
  font-family: var(--font-sans);
  transition: background var(--dur-2) var(--ease-standard), color var(--dur-2);
}
.rail-parent:hover { background: rgba(255,255,255,.04); }
.rail-parent.has-active { color: var(--gold-300); }
.rail-parent.has-active .rail-ico { color: var(--gold-400); }
.rail-parent-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.rail-parent-text .rp-code { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .12em; color: var(--graphite-500); }
.rail-parent.has-active .rail-parent-text .rp-code { color: var(--gold-600); }
.rail-parent-text b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-chev { font-size: 17px; color: var(--graphite-500); transform: rotate(90deg); transition: transform var(--dur-3) var(--ease-standard); line-height: 1; }
.rail-chev.open { transform: rotate(270deg); }

/* Children (areas) */
.rail-children { overflow: hidden; transition: max-height var(--dur-4) var(--ease-standard); display: flex; flex-direction: column; }
.rail-child {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 11px 8px 14px; margin: 1px 0 1px 16px;
  border-radius: var(--radius-2); border: 1px solid transparent;
  background: transparent; cursor: pointer; text-align: left;
  color: var(--graphite-400); position: relative;
  border-left: 1px solid var(--graphite-700);
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  transition: background var(--dur-2), color var(--dur-2);
}
.rail-child:hover { background: rgba(255,255,255,.04); color: var(--graphite-100); }
.rail-child.active { background: rgba(248,217,19,.10); color: var(--gold-300); border-color: rgba(248,217,19,.22); border-left-color: var(--gold-400); }
.rail-child.active::before { content:''; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 2px; background: var(--gold-400); }
.rail-child-code { font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; color: var(--graphite-500); flex: 0 0 auto; width: 38px; }
.rail-child.active .rail-child-code { color: var(--gold-600); }
.rail-child-label { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-spacer { flex: 1; min-height: 12px; }
.rail-foot { padding: 10px; border-top: 1px solid var(--graphite-800); margin-top: 8px; }
.rail-foot .t-label { color: var(--graphite-500); }
.rail-foot-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.rail-foot-row span { font-family: var(--font-mono); font-size: 10px; color: var(--graphite-300); }

/* Main scroll area */
.main { grid-area: main; overflow-y: auto; overflow-x: hidden; position: relative; }

/* Filter bar (sticky) */
.filterbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 11px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}
.filter-field { display: flex; flex-direction: column; gap: 3px; }
.filter-field > .t-label { font-size: 9.5px; }
.select {
  position: relative; display: inline-flex; align-items: center;
  background: var(--bg-sunken);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2);
  height: 30px; padding: 0 28px 0 10px;
  font-size: 12.5px; font-weight: 500; color: var(--fg-1);
  cursor: pointer; min-width: 110px; white-space: nowrap;
  transition: border-color var(--dur-2);
}
.select:hover { border-color: var(--border-strong); }
.select select {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
  font-size: 12px;
}
.select::after { content: '▾'; position: absolute; right: 9px; color: var(--fg-3); font-size: 11px; pointer-events: none; }
.filter-sep { width: 1px; align-self: stretch; background: var(--border-subtle); margin: 4px 2px; }
.scope-tag {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-2);
  background: var(--accent-soft); border: 1px solid var(--gold-200);
  padding: 5px 11px; border-radius: var(--radius-pill);
}
.scope-tag b { color: var(--fg-1); font-weight: 600; }
.btn-reset {
  height: 30px; padding: 0 12px; border: 1px solid var(--border-default);
  background: var(--bg-surface); border-radius: var(--radius-2);
  font-size: 11.5px; font-weight: 500; color: var(--fg-2); cursor: pointer;
  font-family: var(--font-mono); letter-spacing: .03em;
}
.btn-reset:hover { border-color: var(--border-strong); color: var(--fg-1); }

/* Screen container */
.screen { padding: 20px 24px 40px; max-width: 1640px; }
.screen-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; gap: 20px; }
.screen-head h1 { font-size: 22px; }
.screen-head .crumb { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-600); margin-bottom: 5px; }
.screen-head .lede { color: var(--fg-2); font-size: 13px; max-width: 560px; margin-top: 3px; }
.screen-head-right { display: flex; align-items: center; gap: 10px; text-align: right; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.kpi-strip { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 14px; margin-bottom: 14px; }

/* ---------- KPI card ---------- */
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-3);
  padding: 14px 15px 13px;
  display: flex; flex-direction: column; gap: 9px;
  box-shadow: var(--shadow-1);
  position: relative; overflow: hidden;
}
.kpi-accent::before { content:''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold-400); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-val { display: flex; align-items: baseline; gap: 5px; font-family: var(--font-mono); font-weight: 700; font-size: 27px; letter-spacing: -.01em; color: var(--fg-1); line-height: 1; }
.kpi-unit { font-size: 13px; font-weight: 500; color: var(--fg-3); }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-height: 26px; }
.kpi-sub { font-size: 11.5px; color: var(--fg-3); line-height: 1.3; }
.kpi-foot2 { font-size: 11px; color: var(--fg-3); padding-top: 8px; border-top: 1px solid var(--border-subtle); margin-top: 1px; }

/* ---------- Panel ---------- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-3);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 13px 16px 0; }
.panel-title { font-size: 14.5px; font-weight: 600; color: var(--fg-1); margin-top: 3px; letter-spacing: -.01em; }
.panel-body { padding: 14px 16px 16px; flex: 1; min-width: 0; }
.panel-foot { padding: 9px 16px; border-top: 1px solid var(--border-subtle); font-size: 11px; color: var(--fg-3); display: flex; align-items: center; gap: 8px; }
.panel-head-right { display: flex; align-items: center; gap: 8px; }

/* spans */
.s3 { grid-column: span 3; } .s4 { grid-column: span 4; } .s5 { grid-column: span 5; }
.s6 { grid-column: span 6; } .s7 { grid-column: span 7; } .s8 { grid-column: span 8; }
.s9 { grid-column: span 9; } .s12 { grid-column: span 12; }

/* ---------- Chart axis text ---------- */
.c-axis { font-family: var(--font-mono); font-size: 9.5px; fill: var(--fg-3); letter-spacing: .02em; }

/* ---------- Legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--fg-2); }
.legend-sw { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }

/* ---------- Pills ---------- */
.dash-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--pc) 30%, transparent);
  padding: 3px 8px; border-radius: var(--radius-pill); white-space: nowrap;
}
.dash-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pc); }

/* ---------- HBars ---------- */
.hbars { display: flex; flex-direction: column; }
.hbar-row { display: grid; grid-template-columns: 132px 1fr auto; align-items: center; gap: 11px; }
.hbar-label { font-size: 11.5px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: var(--bg-sunken); border-radius: 2px; height: 9px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 2px; transition: width var(--dur-4) var(--ease-decel); }
.hbar-val { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--fg-1); min-width: 38px; text-align: right; }

/* ---------- Donut legend ---------- */
.donut-legend { display: flex; flex-direction: column; gap: 7px; min-width: 0; flex: 1; }
.dl-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.dl-label { font-size: 12px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-val { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--fg-1); }

/* ---------- Funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: 11px; }
.funnel-row { display: flex; flex-direction: column; gap: 4px; }
.funnel-meta { display: flex; align-items: baseline; justify-content: space-between; }
.funnel-name { font-size: 12px; color: var(--fg-2); }
.funnel-num { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--fg-1); }
.funnel-bar-wrap { position: relative; height: 22px; background: var(--bg-sunken); border-radius: 2px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 2px; transition: width var(--dur-4) var(--ease-decel); }
.funnel-conv { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; color: var(--fg-1); }

/* ---------- Bullet ---------- */
.bullet { display: flex; flex-direction: column; gap: 5px; }
.bullet-head { display: flex; align-items: baseline; justify-content: space-between; }
.bullet-label { font-size: 12px; color: var(--fg-2); }
.bullet-val { font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.bullet-track { position: relative; height: 14px; background: var(--bg-sunken); border-radius: 2px; }
.bullet-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; transition: width var(--dur-4) var(--ease-decel); }
.bullet-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg-1); }

/* ---------- Heatmap ---------- */
.heatmap { display: grid; gap: 3px; }
.hm-corner { }
.hm-colhead { font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); text-align: center; padding-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.hm-rowhead { font-size: 11.5px; color: var(--fg-2); display: flex; align-items: center; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-cell { height: 34px; display: grid; place-items: center; border-radius: 2px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--graphite-900); }

/* ---------- Box plot ---------- */
.boxrow { display: grid; grid-template-columns: 150px 1fr 48px; align-items: center; gap: 12px; height: 30px; }
.box-label { font-size: 11.5px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-track { position: relative; height: 22px; }
.box-whisker { position: absolute; top: 50%; height: 1.5px; background: var(--graphite-400); transform: translateY(-50%); }
.box-iqr { position: absolute; top: 4px; bottom: 4px; background: color-mix(in srgb, var(--gold-400) 26%, transparent); border: 1px solid var(--gold-500); border-radius: 2px; }
.box-med { position: absolute; top: 2px; bottom: 2px; width: 2px; background: var(--graphite-900); }
.box-target { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--status-info); }
.box-cap { position: absolute; top: 50%; width: 1.5px; height: 11px; background: var(--graphite-400); transform: translate(-50%,-50%); }
.box-val { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--fg-1); text-align: right; }

/* ---------- Stat list ---------- */
.statlist { display: flex; flex-direction: column; }
.statlist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border-subtle); }
.statlist-row:last-child { border-bottom: none; }
.sl-label { font-size: 12.5px; color: var(--fg-2); }
.sl-val { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; color: var(--fg-1); display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Mini table ---------- */
.dtable { width: 100%; border-collapse: collapse; }
.dtable th { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-3); text-align: right; padding: 0 10px 9px; font-weight: 500; border-bottom: 1px solid var(--border-default); }
.dtable th:first-child, .dtable td:first-child { text-align: left; }
.dtable td { font-size: 12.5px; padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--fg-1); }
.dtable td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.dtable tr:last-child td { border-bottom: none; }
.dtable tr:hover td { background: var(--bg-sunken); }
.dtable .td-name { color: var(--fg-1); font-weight: 500; }
.dtable .td-sub { color: var(--fg-3); font-size: 10.5px; font-family: var(--font-mono); }

/* ---------- Tag / chips ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: var(--radius-pill); border: 1px solid var(--border-default); color: var(--fg-2); background: var(--bg-sunken); }
.tag.gold { background: var(--accent-soft); border-color: var(--gold-200); color: var(--gold-700); }
.tag.ok { background: var(--status-normal-bg); border-color: color-mix(in srgb,var(--status-normal) 26%,transparent); color: var(--status-normal); }
.tag.warn { background: var(--status-warn-bg); border-color: color-mix(in srgb,var(--status-warn) 30%,transparent); color: var(--status-warn); }
.tag.trip { background: var(--status-trip-bg); border-color: color-mix(in srgb,var(--status-trip) 30%,transparent); color: var(--status-trip); }

/* big readout for gauges row */
.readout-block { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.readout-block .rb-val { font-family: var(--font-mono); font-weight: 700; font-size: 30px; color: var(--fg-1); line-height: 1; }
.readout-block .rb-label { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-3); }

/* Age pyramid */
.pyramid { display: flex; flex-direction: column; gap: 6px; }
.pyr-row { display: grid; grid-template-columns: 1fr 96px 1fr; align-items: center; gap: 6px; height: 22px; }
.pyr-side { display: flex; height: 14px; }
.pyr-side.left { justify-content: flex-end; }
.pyr-side.right { justify-content: flex-start; }
.pyr-bar { height: 100%; border-radius: 2px 0 0 2px; transition: width var(--dur-4) var(--ease-decel); }
.pyr-bar.r { border-radius: 0 2px 2px 0; }
.pyr-label { text-align: center; font-family: var(--font-mono); font-size: 11px; color: var(--fg-2); white-space: nowrap; }
.pyr-legend { display: flex; justify-content: center; gap: 16px; margin-top: 8px; }

/* utility */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--fg-3); }
.center { display: grid; place-items: center; }
.fade-in { animation: fadein var(--dur-4) var(--ease-decel); }
@keyframes fadein { from { opacity: 0.4; } to { opacity: 1; } }

.note-line { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--fg-2); }
.note-line .dotmark { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }

/* scrollbar */
.main::-webkit-scrollbar, .rail::-webkit-scrollbar { width: 10px; }
.main::-webkit-scrollbar-thumb, .rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
.rail::-webkit-scrollbar-thumb { background: var(--graphite-700); border-color: var(--graphite-900); border-style: solid; border-width: 3px; background-clip: content-box; }
