/* ==========================================================================
   The workspace.

   The dashboard is for reading, not for filling in forms — so the inputs live
   in a drawer and the page belongs to the data. One control decides how much of
   it you see, which is the whole answer to "simple enough / deep enough":
   one legible switch instead of thirty hidden toggles.
   ========================================================================== */

.view--detail { position: relative; }

/* ─────────────────────────────── the work bar ───────────────────────────── */

.workbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: 10px clamp(14px, 3vw, 28px);
  background: color-mix(in srgb, var(--plane) 78%, transparent);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--border);
}

.workbar__back { flex: none; }

.workbar__right {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  flex: none;
  margin-left: auto;
}

/* Section nav — scroll-spy pills. */
.worknav {
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}
.worknav::-webkit-scrollbar { display: none; }

.worknav__item {
  position: relative;
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.worknav__item:hover { color: var(--text-primary); background: var(--surface-1); }
.worknav__item[aria-current='true'] {
  color: var(--text-primary);
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
}
.worknav__num {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

/* Depth control — the one switch that scales the whole page. */
.seg--depth .seg__btn { padding: 0 11px; }
@media (max-width: 900px) {
  .seg--depth .seg__btn { padding: 0 8px; font-size: 11.5px; }
}

/* ─────────────────────────── assumptions strip ─────────────────────────── */

.strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  padding: var(--gap-4) clamp(14px, 3vw, 28px) 0;
  max-width: 1560px;
  margin: 0 auto;
}

.strip__chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
  transition: border-color 0.15s var(--ease), transform 0.16s var(--spring);
}
.strip__chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.strip__chip-label { font-size: 11px; color: var(--text-muted); }
.strip__chip-value {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────────── the dashboard ───────────────────────────── */

.dashboard {
  max-width: 1560px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 32px) clamp(14px, 3vw, 28px) 80px;
  display: flex;
  flex-direction: column;
  gap: clamp(44px, 6vw, 72px);
}

.dsec { scroll-margin-top: calc(var(--topbar-h) + 64px); }
.dsec[hidden] { display: none; }

.dsec__head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: var(--gap-5);
  padding-bottom: var(--gap-3);
  border-bottom: 1px solid var(--border);
}

.dsec__num {
  grid-row: span 2;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  opacity: 0.22;
  font-variant-numeric: tabular-nums;
}

.dsec__title {
  font-size: clamp(20px, 2.6vw, 25px);
  font-weight: 640;
  letter-spacing: -0.028em;
}

.dsec__sub {
  grid-column: 2;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.dashboard__foot { margin-top: -20px; }

/* ── the recap: one line of continuity from the answer page ─────────────── */

.recap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-4) var(--gap-6);
  padding: 18px 22px;
  margin-bottom: var(--gap-5);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
  border-left: 3px solid var(--verdict-accent, var(--series-1));
}
.recap[data-verdict='buy']   { --verdict-accent: var(--series-1); }
.recap[data-verdict='rent']  { --verdict-accent: var(--series-2); }
.recap[data-verdict='close'] { --verdict-accent: var(--chart-axis); }

.recap__lead { margin-right: auto; }
.recap__headline {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.recap__gap {
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 680;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--verdict-accent);
}
.recap__pair { display: flex; flex-direction: column; gap: 2px; }
.recap__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.recap__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.recap__value {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ── KPI hierarchy: four that matter, then the reference set ────────────── */

.kpi-groups { display: flex; flex-direction: column; gap: clamp(26px, 3vw, 36px); }

.kpi-grid--hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--gap-3);
  margin-bottom: var(--gap-5);
}

.kpi--hero { padding: 20px 22px; }
.kpi--hero .kpi__label { font-size: 12.5px; }
.kpi--hero .kpi__value {
  font-size: clamp(28px, 3.4vw, 36px);
  letter-spacing: -0.035em;
}
.kpi--hero .kpi__meta { font-size: 12.5px; }

.kpi-group__head {
  display: flex;
  align-items: baseline;
  gap: var(--gap-3);
  margin-bottom: var(--gap-3);
}
.kpi-group__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-group__sub { font-size: 12.5px; color: var(--text-muted); }

/* ───────────────────────────── the drawer ───────────────────────────── */

.drawer {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: min(400px, 100vw);
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  box-shadow: var(--lift-3);
  transform: translateX(100%);
  transition: transform 0.34s var(--ease);
}
.drawer[hidden] { display: flex; }        /* animate out rather than vanish */
body[data-drawer='open'] .drawer { transform: none; }

.drawer__head {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.drawer__title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-right: auto;
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--gap-4) 16px 40px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-3);
}
/* Column flex items shrink by default, which silently crushes a scrolling
   panel until its fields disappear. They must keep their natural height. */
.drawer__body > * { flex: 0 0 auto; }

/* Wide screens: the page makes room, so charts reflow live while you drag. */
@media (min-width: 1180px) {
  body[data-drawer='open'][data-mode='detail'] .workbar,
  body[data-drawer='open'][data-mode='detail'] .workbench {
    margin-right: 400px;
  }
  .workbar, .workbench { transition: margin-right 0.34s var(--ease); }
}

/* Narrow screens: it covers, with a scrim. */
.drawer-scrim {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  z-index: 44;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
@media (max-width: 1179px) {
  body[data-drawer='open'] .drawer-scrim { opacity: 1; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .workbar, .workbench, .drawer-scrim { transition: none; }
}

/* ───────────────────────────────── narrow ───────────────────────────────── */

@media (max-width: 820px) {
  .workbar { gap: var(--gap-2); padding: 8px 12px; }
  .workbar__back .btn__text { display: none; }
  .workbar__right { gap: 6px; }
  .strip { padding-top: var(--gap-3); }
  .dsec__head { margin-bottom: var(--gap-4); }
}

@media (max-width: 560px) {
  .seg--depth { display: none; }
  .worknav { order: 3; flex-basis: 100%; }
  .workbar { flex-wrap: wrap; }
}

@media print {
  .workbar, .drawer, .drawer-scrim, .strip { display: none !important; }
  .dashboard { padding: 0; gap: 26px; }
  .dsec[hidden] { display: block; }
}

/* ──────────────────────────── confidence & odds ─────────────────────────── */

.risk__lead { margin-bottom: var(--gap-4); }

.risk__headline {
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: var(--gap-4);
}
.risk__headline strong {
  font-size: 20px;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.risk__pending { font-size: 14px; color: var(--text-muted); }

.risk__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2px;
  margin-top: var(--gap-5);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--border);
}
.risk__stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  background: var(--surface-1);
}
.risk__stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.risk__stat-value {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.risk__stat-note { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }

/* One bar, two futures. The share of simulated outcomes each decision wins. */
.odds__bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.odds__fill {
  height: 100%;
  transition: width 0.6s var(--ease);
}
.odds__fill--buy  { background: var(--series-1); }
.odds__fill--rent { background: var(--series-2); }

.odds__legend {
  display: flex;
  justify-content: space-between;
  gap: var(--gap-3);
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.odds__side { display: inline-flex; align-items: center; gap: 6px; }
.odds__side strong { color: var(--text-primary); font-weight: 650; }
.odds__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* The same bar, on the answer page, under the two totals. */
.confidence {
  margin-top: var(--gap-5);
  padding-top: var(--gap-5);
  border-top: 1px solid var(--border);
}
.confidence:empty { display: none; }
.confidence__line {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: var(--gap-3);
  max-width: 62ch;
}
.confidence__line strong { color: var(--text-primary); font-weight: 650; }
