/* ─────────────────────────────────────────────────────────────────
 * TreeGuard — Dashboard
 * ───────────────────────────────────────────────────────────────── */

.dash-content { padding: 20px 28px 40px; display: flex; flex-direction: column; gap: 16px; }

/* KPI row */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.kpi .label {
  font: var(--t-caption-up);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.kpi .label .tok {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.kpi .value {
  font: var(--t-metric-xl);
  color: var(--text-primary);
  line-height: 1.1;
}
.kpi .sub {
  font: var(--t-data-sm);
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.kpi .sub .tri { width: 0; height: 0; border: 4px solid transparent; }
.kpi .sub .tri.up   { border-bottom-color: currentColor; margin-bottom: 3px; }
.kpi .sub .tri.down { border-top-color: currentColor;    margin-top: 3px; }

.kpi-accent {
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}

.kpi.alarm .value { color: var(--status-alarm); }
.kpi.alarm .kpi-accent { background: var(--status-alarm); }
.kpi.alert .value { color: var(--status-alert); }
.kpi.alert .kpi-accent { background: var(--status-alert); }
.kpi.stable .value { color: var(--status-stable); }
.kpi.stable .kpi-accent { background: var(--status-stable); }
.kpi.total .kpi-accent { background: var(--brand-500); }

/* Perspective KPI tiles — one per risk perspective (growth / fall / clearance) */
.kpi.perspective {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.kpi.perspective:hover { background: var(--bg-card-hover, var(--bg-card)); border-color: var(--border-strong, var(--border-subtle)); }
.kpi.perspective .label { margin-bottom: 0; }
.kpi.perspective.has-alarm .kpi-accent { background: var(--status-alarm); }
.kpi.perspective.has-alert .kpi-accent { background: var(--status-alert); }
.kpi.perspective.is-stable .kpi-accent { background: var(--status-stable); }
.kpi.perspective.has-alarm .value { color: var(--status-alarm); }
.kpi.perspective.has-alert .value { color: var(--status-alert); }
.kpi.perspective.is-stable .value { color: var(--status-stable); }

.persp-row { display: flex; align-items: baseline; }
.persp-headline { display: flex; align-items: baseline; gap: 8px; }
.persp-headline .value { font: var(--t-metric-xl); line-height: 1; }
.persp-headline .of {
  font: var(--t-data-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.persp-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--border-subtle);
  margin-top: 2px;
}
.persp-bar .seg { display: block; height: 100%; }
.persp-bar .seg + .seg { margin-left: 2px; }
.persp-bar .seg-alarm  { background: var(--status-alarm); }
.persp-bar .seg-alert  { background: var(--status-alert); }
.persp-bar .seg-stable { background: var(--status-stable); }

.persp-legend {
  display: flex;
  gap: 14px;
  font: var(--t-data-sm);
  color: var(--text-muted);
  flex-wrap: wrap;
}
.persp-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.persp-legend .lg .d {
  width: 8px; height: 8px; border-radius: 2px; display: inline-block;
}
.persp-legend .lg b {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 500;
}
.persp-legend .lg-alarm  .d { background: var(--status-alarm); }
.persp-legend .lg-alert  .d { background: var(--status-alert); }
.persp-legend .lg-stable .d { background: var(--status-stable); }

/* Locked perspective — frosted glass overlay with Contact-sales CTA.
   Title stays readable above the glass; the data below it is heavily blurred
   so users can sense there's content + color underneath but cannot read it. */
.kpi.perspective.locked {
  position: relative;
  cursor: default;
  overflow: hidden;
}
.kpi.perspective.locked:hover {
  background: var(--bg-card);
  border-color: var(--border-subtle);
}
.kpi.perspective.locked .label { position: relative; z-index: 3; }
.lock-overlay {
  position: absolute;
  /* Start just below the label so the title remains readable */
  left: 0; right: 0; bottom: 0;
  top: 36px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Heavy blur so text underneath is unreadable, but scrim is translucent
     so the warm color cast and shapes still bleed through. */
  backdrop-filter: blur(18px) saturate(0.85);
  -webkit-backdrop-filter: blur(18px) saturate(0.85);
  background: color-mix(in oklab, var(--bg-card) 38%, transparent);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
/* Fallback for engines without backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
  .lock-overlay { background: color-mix(in oklab, var(--bg-card) 90%, transparent); }
}
.lock-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 8px 12px;
  max-width: 100%;
}
.lock-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--brand-500) 16%, transparent);
  color: var(--brand-500);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lock-sub {
  font: var(--t-data-sm);
  color: var(--text-secondary);
}
.lock-cta {
  font: var(--t-data-sm);
  font-weight: 500;
  color: var(--brand-500);
  background: color-mix(in oklab, var(--brand-500) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--brand-500) 35%, transparent);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.lock-cta:hover {
  background: color-mix(in oklab, var(--brand-500) 22%, transparent);
  border-color: var(--brand-500);
}

/* Donut + critical assets row */
.overview-row {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 12px;
}
@media (max-width: 1280px) { .overview-row { grid-template-columns: 1fr; } }

.donut-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.donut-panel h3 { margin: 0; font: var(--t-h3); color: var(--text-primary); }
.donut-wrap {
  display: flex; align-items: center; justify-content: center;
  position: relative; padding: 8px 0 4px;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  text-align: center;
}
.donut-center .n {
  font: 500 44px/1 var(--font-mono);
  color: var(--text-primary);
}
.donut-center .l {
  font: var(--t-caption);
  color: var(--text-muted);
  margin-top: 4px;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.donut-legend .lg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.donut-legend .lg-row:last-child { border-bottom: none; }
.donut-legend .dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.donut-legend .name { font: var(--t-body); color: var(--text-primary); flex: 1; }
.donut-legend .pct  { font: var(--t-data-sm); color: var(--text-muted); font-family: var(--font-mono); }
.donut-legend .ct   { font: var(--t-data); color: var(--text-primary); font-family: var(--font-mono); min-width: 28px; text-align: right; }

/* Critical assets list */
.critical-list { display: flex; flex-direction: column; }
.critical-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.critical-row:last-child { border-bottom: none; }
.critical-row .left {
  display: flex; flex-direction: column; gap: 2px;
}
.critical-row .name {
  font: 500 14px/20px var(--font-mono);
  color: var(--text-primary);
}
.critical-row .meta {
  font: var(--t-caption); color: var(--text-muted);
}
.critical-row .right {
  display: flex; align-items: center; gap: 8px;
}
.pill {
  font: var(--t-data-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--status-alarm-bg);
  color: var(--status-alarm);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.pill.alarm  { background: var(--status-alarm-bg);  color: var(--status-alarm); }
.pill.alert  { background: var(--status-alert-bg);  color: var(--status-alert); }
.pill.stable { background: var(--status-stable-bg); color: var(--status-stable); }
.pill.cut-cut     { background: var(--status-stable-bg); color: var(--status-stable); }
.pill.cut-partial { background: var(--status-alert-bg);  color: var(--status-alert); }
.pill.cut-no-cut  { background: var(--status-alarm-bg);  color: var(--status-alarm); }

/* ─────────────────────────────────────────────────────────────
 * TABLE — MAIN style (full-width page tables)
 * Frame 14 reference:
 *  - Each table is its own contained surface
 *  - Header strip has subtle darker fill
 *  - Orange underline accent on sorted column
 *  - 13–14px Inter regular; mono only on codes/IDs
 *  - Stacked tables get a real page-bg gap between them
 * ───────────────────────────────────────────────────────────── */
.tbl-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.tbl-panel .hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
}
.tbl-panel .hdr .title { display: flex; flex-direction: column; gap: 2px; }
.tbl-panel .hdr h3 { margin: 0; font: var(--t-h3); color: var(--text-primary); }
.tbl-panel .hdr .hint { font: var(--t-caption); color: var(--text-muted); }

/* Clear page-bg gap between stacked main tables */
.tbl-panel + .tbl-panel { margin-top: 16px; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead tr { background: rgba(0,0,0,0.20); }
.tbl th {
  text-align: left;
  font: 500 11px/1.3 var(--font-sans);
  color: var(--text-muted);
  padding: 12px 20px;
  border-bottom: 1px solid transparent;
  white-space: nowrap;
  position: relative;
}
.tbl th.th-sort {
  cursor: pointer;
  user-select: none;
  transition: color 0.1s;
}
.tbl th.th-sort:hover { color: var(--text-secondary); }
.tbl th.th-sort .th-label { margin-right: 4px; }
.tbl th.th-sort .arrow {
  display: inline-block;
  opacity: 0.28;
  transition: opacity 0.1s, color 0.1s;
  font-size: 10px;
  vertical-align: 1px;
}
.tbl th.th-sort:hover .arrow { opacity: 0.55; }
.tbl th.th-sort .arrow.on { opacity: 1; color: var(--brand-500); }
.tbl th.sorted { color: var(--text-primary); }
.tbl th.sorted::after {
  content: '';
  position: absolute; left: 20px; right: 20px; bottom: -1px;
  height: 2px; background: var(--brand-500);
}
.tbl th .arrow { margin-left: 4px; opacity: 0.7; }

.tbl td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  font: 400 13px/1.4 var(--font-sans);
  color: var(--text-primary);
  vertical-align: middle;
}
.tbl td.mono { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.01em; }
.tbl td.num  { font-family: var(--font-mono); font-size: 13px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.1s; }
.tbl tbody tr:hover td { background: rgba(255,255,255,0.02); cursor: pointer; }

/* ─────────────────────────────────────────────────────────────
 * TABLE — SUPPORTING style (inside a card panel)
 * Frame 11 reference:
 *  - Wrapped in rounded card with border
 *  - Panel title at top + orange accent underline
 *  - Header row has darker fill strip
 *  - Compact vertical rhythm
 * ───────────────────────────────────────────────────────────── */
.support-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.support-panel > .sp-hdr {
  padding: 16px 20px 0;
  position: relative;
}
.support-panel > .sp-hdr h3 {
  margin: 0 0 14px;
  font: 500 14px/1.3 var(--font-sans);
  color: var(--text-primary);
}
.support-panel > .sp-hdr::after {
  content: '';
  position: absolute; left: 20px; bottom: 0;
  width: 56px; height: 2px; background: var(--brand-500);
}
.support-panel > .sp-hdr .sp-meta {
  font: var(--t-caption); color: var(--text-muted);
  margin-bottom: 12px;
}

.support-panel table.tbl thead tr {
  background: rgba(0,0,0,0.20);
}
.support-panel table.tbl th {
  padding: 10px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: none;
}
.support-panel table.tbl th.sorted::after { display: none; }
.support-panel table.tbl td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
}
.support-panel table.tbl tr:last-child td { border-bottom: none; }
.support-panel table.tbl td.mono,
.support-panel table.tbl td.num { font-size: 12px; }

.type-chip {
  font: var(--t-data-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-400);
}
.type-chip.completed { color: var(--text-muted); }
.int-row.completed td { color: var(--text-muted); }
.int-row.completed td.mono { color: var(--text-muted); }

/* Analysis date picker (in top bar) */
.date-picker {
  position: relative;
}
.date-btn {
  font: var(--t-label);
  padding: 9px 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer;
  min-width: 220px;
}
.date-btn .lbl { color: var(--text-secondary); font-weight: 400; }
.date-btn .val { font-family: var(--font-mono); font-size: 13px; }
.date-btn .chev { color: var(--text-muted); margin-left: auto; }
.date-btn.open { border-color: var(--brand-500); }
.date-btn.open .chev { color: var(--brand-500); }

.date-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  min-width: 240px;
  background: var(--bg-input);
  border: 1px solid var(--brand-500);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 10;
}
.date-menu .opt {
  padding: 8px 12px;
  font: 400 13px/18px var(--font-mono);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.date-menu .opt:hover { background: rgba(255,255,255,0.04); }
.date-menu .opt.sel { background: var(--brand-bg); color: var(--brand-400); }
