/* App-specific styles for the EV Multiples redesign.
   Imports brand tokens from design-system/colors_and_type.css. */

/* Missing token from brand file — secondary foreground */
:root { --fg-secondary: #3A3A52; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--surface-page);
  color: var(--fg-body);
  font-family: var(--font-body);
  font-weight: var(--fw-body-light);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-relaxed);
  min-height: 100vh;
  -webkit-font-feature-settings: "ss01", "tnum";
  font-feature-settings: "ss01", "tnum";
}

/* Density modes — applied as data attribute on <body> */
body[data-density="compact"]    { --row-y: 6px;  --pad: 12px; --gap: 10px; --num-h: 28px; }
body[data-density="comfortable"]{ --row-y: 10px; --pad: 18px; --gap: 14px; --num-h: 34px; }
body[data-density="airy"]       { --row-y: 14px; --pad: 24px; --gap: 18px; --num-h: 40px; }

/* Theme — light (default) and navy (dark) */
body[data-theme="navy"] {
  --surface-page:        #00002A;
  --surface-raised:      #0A0A4D;
  --surface-subtle:      #0F0F60;
  --surface-muted:       #14146F;
  --fg-primary:          #FFFFFF;
  --fg-body:             rgba(255,255,255,0.88);
  --fg-muted:            rgba(255,255,255,0.58);
  --fg-subtle:           rgba(255,255,255,0.4);
  --border-subtle:       rgba(255,255,255,0.10);
  --border-default:      rgba(255,255,255,0.16);
  --border-strong:       rgba(255,255,255,0.30);
  --action-secondary-bg:        transparent;
  --action-secondary-fg:        #FFFFFF;
  --action-secondary-border:    rgba(255,255,255,0.30);
  --action-secondary-bg-hover:  rgba(255,255,255,0.08);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.40), 0 2px 6px rgba(0,0,0,0.25);
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.04);
}

/* ───────── App shell ───────── */

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  background: var(--surface-page);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 20;
}
body[data-theme="navy"] .topbar {
  background: var(--surface-page);
  border-bottom-color: var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--tia-navy);
  display: grid; place-items: center;
  position: relative;
  flex: none;
}
body[data-theme="navy"] .brand-mark { background: var(--tia-white); }
.brand-mark::after {
  content: "";
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--tia-red);
  position: absolute; top: 5px; right: 5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text .product {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--fg-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-text .crumb {
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.title-block {
  text-align: center;
  min-width: 0;
  overflow: hidden;
}
.title-block h1 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-primary);
  margin: 0;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-block .subtitle {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 1100px) {
  .title-block { display: none; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  line-height: 1;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
  -webkit-font-smoothing: antialiased;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn-primary {
  background: var(--tia-red);
  color: #fff;
  border-color: var(--tia-red);
  font-weight: 600;
}
.btn-primary:hover { background: var(--tia-red-600); border-color: var(--tia-red-600); }
.btn-primary:active { background: var(--tia-red-700); border-color: var(--tia-red-700); }

.btn-secondary {
  background: var(--action-secondary-bg);
  color: var(--action-secondary-fg);
  border-color: var(--action-secondary-border);
}
.btn-secondary:hover { background: var(--action-secondary-bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--fg-body);
  border-color: transparent;
  padding: 8px 10px;
}
.btn-ghost:hover { background: var(--surface-muted); color: var(--fg-primary); }
body[data-theme="navy"] .btn-ghost:hover { background: rgba(255,255,255,0.06); }

.btn-icon {
  padding: 8px;
  background: transparent;
  border-color: transparent;
  color: var(--fg-muted);
  border-radius: 6px;
}
.btn-icon:hover { background: var(--surface-muted); color: var(--fg-primary); }
body[data-theme="navy"] .btn-icon:hover { background: rgba(255,255,255,0.06); color: #fff; }

.divider-v {
  width: 1px; height: 18px; background: var(--border-subtle); margin: 0 4px;
}

/* ───────── Workspace layout ───────── */

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  align-items: stretch;
  min-height: 0;
}
body[data-layout="dashboard"] .workspace {
  grid-template-columns: 300px 1fr 280px;
}

.inputs-rail {
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-page);
  padding: 20px 22px 80px;
  overflow-y: auto;
  max-height: calc(100vh - 61px);
  position: sticky;
  top: 61px;
}

.results-pane {
  padding: 32px 36px 80px;
  background: var(--surface-page);
  min-width: 0;
}

.context-rail {
  display: none;
  border-left: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  padding: 24px 22px 80px;
  overflow-y: auto;
  max-height: calc(100vh - 61px);
  position: sticky;
  top: 61px;
}
body[data-layout="dashboard"] .context-rail { display: block; }

/* ───────── Inputs ───────── */

.section {
  margin-bottom: 26px;
}
.section + .section { padding-top: 22px; border-top: 1px solid var(--border-subtle); }

.eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.eyebrow .eyebrow-meta {
  font-weight: 400;
  letter-spacing: 0.06em;
  font-size: 10px;
  color: var(--fg-subtle);
}

.preset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-bottom: 22px;
}
.preset-row label {
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.preset-select {
  flex: 1;
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  color: var(--fg-primary);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 500;
}
.preset-select:focus { outline: none; box-shadow: var(--focus-ring); }

/* Mode tabs (Standard iROIC / Efficiency Gains) */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 22px;
}
.mode-tab {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 9px 10px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--fg-muted);
  background: transparent;
  border: 0;
  transition: all var(--dur-fast) var(--ease-standard);
}
.mode-tab:hover { color: var(--fg-primary); }
.mode-tab.active {
  background: var(--surface-raised);
  color: var(--fg-primary);
  box-shadow: var(--shadow-xs);
}
body[data-theme="navy"] .mode-tab.active { background: var(--surface-page); color: #fff; }

/* Slider control */
.field {
  margin-bottom: 14px;
}
.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-body);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0;
}
.field-label .info {
  width: 12px; height: 12px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  font-size: 9px;
  color: var(--fg-subtle);
  border: 1px solid var(--border-default);
  cursor: help;
  font-family: var(--font-display);
  font-weight: 600;
  font-style: normal;
  line-height: 1;
  padding-bottom: 1px;
}
.field-label .info:hover { color: var(--fg-primary); border-color: var(--fg-primary); }

.field-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-primary);
  font-feature-settings: "tnum";
  cursor: text;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  width: 70px;
  text-align: right;
  -moz-appearance: textfield;
}
.field-value::-webkit-outer-spin-button,
.field-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field-value:hover { border-color: var(--border-subtle); }
.field-value:focus {
  outline: none;
  border-color: var(--tia-navy);
  background: var(--surface-page);
  box-shadow: var(--focus-ring);
}
body[data-theme="navy"] .field-value:focus { border-color: rgba(255,255,255,0.5); }

.field-suffix {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  margin-left: 2px;
}

/* Slider track */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  position: relative;
}
body[data-theme="navy"] .slider { background: rgba(255,255,255,0.12); }

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--tia-navy);
  border: 2px solid var(--surface-page);
  box-shadow: 0 0 0 1px var(--tia-navy);
  cursor: grab;
  transition: transform var(--dur-fast);
}
body[data-theme="navy"] .slider::-webkit-slider-thumb {
  background: #fff; border-color: var(--surface-page); box-shadow: 0 0 0 1px #fff;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-webkit-slider-thumb:active { cursor: grabbing; background: var(--tia-red); box-shadow: 0 0 0 1px var(--tia-red); }
.slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--tia-navy);
  border: 2px solid var(--surface-page);
  cursor: grab;
}

.slider-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-muted);
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  padding: 0;
}
.slider-stepper button {
  background: transparent;
  border: 0;
  width: 22px;
  height: 22px;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  border-radius: 4px;
}
.slider-stepper button:hover { background: var(--surface-page); color: var(--fg-primary); }
.slider-stepper button:active { transform: translateY(1px); }
body[data-theme="navy"] .slider-stepper button:hover { background: rgba(255,255,255,0.06); color: #fff; }

/* Field-attached alert */
.field-alert {
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
  background: var(--tia-warning-soft);
  color: #6B4604;
  border-left: 3px solid var(--tia-warning);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
body[data-theme="navy"] .field-alert {
  background: rgba(181,119,10,0.18);
  color: #FFE3AE;
  border-left-color: #E0A646;
}
.field-alert .alert-dot {
  width: 6px; height: 6px;
  background: var(--tia-warning); border-radius: 999px;
  margin-top: 6px; flex: none;
}

/* Checkbox */
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  font-size: 12.5px;
  color: var(--fg-body);
  cursor: pointer;
  user-select: none;
}
.check-row input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--border-default);
  background: var(--surface-raised);
  cursor: pointer;
  display: grid; place-items: center;
  flex: none;
  position: relative;
  transition: all var(--dur-fast);
}
.check-row input[type="checkbox"]:checked {
  background: var(--tia-navy);
  border-color: var(--tia-navy);
}
.check-row input[type="checkbox"]:checked::after {
  content: "";
  width: 7px; height: 4px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(0px, -1px);
}
.check-row:hover input[type="checkbox"] { border-color: var(--tia-navy); }

/* Reinvestment / Payout split bar */
.split-bar {
  margin: 10px 0 4px;
  padding: 8px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}
.split-bar .split-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  font-family: var(--font-mono);
}
.split-bar .split-labels .label-reinvest { color: var(--tia-navy); }
body[data-theme="navy"] .split-bar .split-labels .label-reinvest { color: #B8B8FF; }
.split-bar .split-labels .label-payout { color: var(--tia-positive); }
.split-bar .split-track {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-page);
}
.split-bar .split-track .reinvest { background: var(--tia-navy); }
body[data-theme="navy"] .split-bar .split-track .reinvest { background: #6E6EFF; }
.split-bar .split-track .payout { background: var(--tia-positive); }

/* ───────── Results ───────── */

.results-pane > * + * { margin-top: 24px; }

.result-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: end;
  padding: 28px 32px;
  border: 1px solid var(--tia-navy);
  border-radius: 14px;
  background: var(--tia-navy);
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0,0,100,0.18);
}
.result-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 280px at 0% 0%, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(600px 240px at 100% 100%, rgba(255,0,0,0.10), transparent 60%);
  pointer-events: none;
}
body[data-theme="navy"] .result-hero {
  background: var(--tia-navy);
  border-color: rgba(255,255,255,0.16);
}
body[data-theme="navy"] .result-hero::before {
  background: radial-gradient(800px 240px at 0% 0%, rgba(255,0,0,0.10), transparent 60%);
}

.result-hero .hero-eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  font-family: var(--font-display);
  color: rgba(255,255,255,0.72);
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 8px;
  position: relative;
}
.result-hero .hero-eyebrow .dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--tia-red);
  box-shadow: 0 0 0 3px rgba(255,0,0,0.22);
}
.result-hero h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 5.2vw, 72px);
  letter-spacing: -0.025em;
  line-height: 1;
  color: #fff;
  margin: 0;
  font-feature-settings: "tnum";
  position: relative;
  white-space: nowrap;
}
.result-hero h2 .unit {
  font-weight: 400;
  font-family: var(--font-body);
  color: rgba(255,255,255,0.7);
  font-size: 0.32em;
  letter-spacing: 0.02em;
  margin-left: 14px;
  vertical-align: 0.42em;
  white-space: nowrap;
}
.result-hero .hero-headline-suffix {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  color: rgba(255,255,255,0.88);
  letter-spacing: -0.01em;
}
.result-hero .hero-meta {
  margin-top: 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: rgba(255,255,255,0.66);
  letter-spacing: 0.01em;
  position: relative;
}
.result-hero .hero-meta .sep { margin: 0 10px; color: rgba(255,255,255,0.32); }
.result-hero .hero-meta b {
  font-weight: 500;
  color: #fff;
}

.hero-multiples {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 22px;
  font-family: var(--font-mono);
  font-size: 13px;
  align-self: end;
  position: relative;
  padding-left: 24px;
  border-left: 1px solid rgba(255,255,255,0.14);
}
.hero-multiples .label { color: rgba(255,255,255,0.56); letter-spacing: 0.02em; }
.hero-multiples .value { color: #fff; text-align: right; font-weight: 500; font-feature-settings: "tnum"; }

/* Inline thesis */
.thesis {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.thesis h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 14px;
}
.thesis ol {
  margin: 0; padding: 0; list-style: none;
  counter-reset: thesis;
  display: grid;
  gap: 14px;
}
.thesis ol li {
  position: relative;
  padding-left: 36px;
  counter-increment: thesis;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg-body);
  font-weight: 300;
}
.thesis ol li::before {
  content: counter(thesis, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--tia-red);
  letter-spacing: 0.06em;
  position: absolute;
  left: 0;
  top: 4px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin: 4px 0 0;
}
.tab {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  background: transparent;
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
  position: relative;
  letter-spacing: 0;
}
.tab:hover { color: var(--fg-primary); }
.tab.active { color: var(--fg-primary); font-weight: 600; }
.tab.active::after {
  content: "";
  position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px;
  background: var(--tia-red);
  border-radius: 999px;
}
.tab .badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  background: var(--tia-navy);
  color: #fff;
  padding: 2px 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 600;
  vertical-align: 1px;
}
body[data-theme="navy"] .tab .badge {
  background: rgba(255,255,255,0.18); color: #fff;
}

/* Multiples table */
.multiples-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-raised);
}
.multiples-head {
  display: grid;
  grid-template-columns: 2fr 1fr 1.4fr 1fr;
  gap: 12px;
  padding: 12px 18px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border-subtle);
}
.multiples-head > :nth-child(2),
.multiples-head > :nth-child(3),
.multiples-head > :nth-child(4) { text-align: right; }
.multiples-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.4fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13.5px;
  transition: background var(--dur-fast);
}
.multiples-row:first-of-type { border-top: 0; }
.multiples-row:hover { background: var(--surface-muted); }
.multiples-row .name {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-primary);
  font-weight: 500;
  font-family: var(--font-display);
  font-size: 14px;
}
.multiples-row .name .accent-bar {
  width: 3px; height: 18px;
  background: var(--tia-navy-200);
  border-radius: 999px;
}
.multiples-row.is-headline .name .accent-bar { background: var(--tia-red); }
.multiples-row.is-headline { background: rgba(255,0,0,0.025); }
body[data-theme="navy"] .multiples-row.is-headline { background: rgba(255,0,0,0.08); }

.multiples-row .value {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--fg-primary);
  font-feature-settings: "tnum";
}
.multiples-row .vs {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
}
.multiples-row .bar-cell {
  height: 6px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
  align-self: center;
}
.multiples-row .bar-fill {
  height: 100%;
  background: var(--tia-navy);
  border-radius: 999px;
  transition: width 320ms var(--ease-standard);
}
.multiples-row.is-headline .bar-fill { background: var(--tia-red); }

/* Analytical framework */
.framework-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 22px 26px;
  background: var(--surface-page);
}
.framework-card h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 12px;
}
.framework-card p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg-body);
  font-weight: 300;
  max-width: none;
  margin: 0;
}
.framework-card p .tia-accent { font-weight: 500; }
.framework-card .stat {
  font-family: var(--font-mono);
  color: var(--fg-primary);
  font-weight: 500;
}

/* Sensitivity panel */
.sens-panel {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 1100px) { .sens-panel { grid-template-columns: 1fr; } }

.sens-controls {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 18px;
  background: var(--surface-page);
}
.sens-controls h4 {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 12px;
}
.sens-control { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.sens-control label { font-size: 11px; font-weight: 600; color: var(--fg-muted); letter-spacing: 0.06em; text-transform: uppercase; }
.sens-control select {
  border: 1px solid var(--border-default);
  background: var(--surface-raised);
  color: var(--fg-primary);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font-body);
}
.sens-control select:focus { outline: none; box-shadow: var(--focus-ring); }

.sens-grid-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: auto;
  background: var(--surface-raised);
  padding: 6px;
}
.sens-grid {
  border-collapse: separate;
  border-spacing: 4px;
  width: 100%;
}
.sens-grid th, .sens-grid td {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: center;
  padding: 9px 8px;
  font-feature-settings: "tnum";
  border-radius: 4px;
}
.sens-grid th {
  font-weight: 600;
  color: var(--fg-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.sens-grid .axis-corner { background: transparent; }
.sens-grid .axis-y, .sens-grid .axis-x { color: var(--fg-muted); font-weight: 600; }
.sens-grid td.cell {
  color: var(--fg-primary);
  font-weight: 500;
}
.sens-grid td.cell.center {
  outline: 2px solid var(--tia-red);
  outline-offset: -2px;
  font-weight: 700;
}

/* Compare */
.compare-grid {
  display: grid;
  gap: 16px;
}
.compare-row {
  display: grid;
  grid-template-columns: 240px 1fr auto;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--surface-raised);
  align-items: center;
}
.compare-row .name h4 { margin: 0; font-size: 14px; font-weight: 600; }
.compare-row .name .meta { font-size: 12px; color: var(--fg-muted); margin-top: 2px; font-family: var(--font-mono); }
.compare-row .bars {
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: center;
  gap: 10px;
}
.compare-row .bars .lbl { font-size: 11px; color: var(--fg-muted); font-family: var(--font-display); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.compare-row .bar { height: 6px; background: var(--surface-muted); border-radius: 999px; overflow: hidden; position: relative; }
.compare-row .bar .fill { height: 100%; background: var(--tia-navy); border-radius: 999px; }
.compare-row.you .bar .fill { background: var(--tia-red); }
.compare-row .bar .marker {
  position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--tia-red); opacity: 0.4;
}
.compare-row .ev {
  font-family: var(--font-mono); font-weight: 700; font-size: 18px; color: var(--fg-primary); font-feature-settings: "tnum";
  text-align: right;
}
.compare-row .ev .delta { display: block; font-size: 11px; font-weight: 500; color: var(--fg-muted); margin-top: 2px; }
.compare-row.you { border-color: var(--tia-red); box-shadow: 0 0 0 1px var(--tia-red) inset; }
body[data-theme="navy"] .compare-row.you { background: rgba(255,0,0,0.06); }

/* Risk */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.risk-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--surface-raised);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
}
.risk-card .head {
  display: flex; align-items: center; justify-content: space-between;
}
.risk-card .head h4 {
  font-size: 13px; font-weight: 600;
  font-family: var(--font-display);
  margin: 0;
}
.risk-card .pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.pill.low { background: var(--tia-positive-soft); color: var(--tia-positive); }
.pill.med { background: var(--tia-warning-soft); color: var(--tia-warning); }
.pill.high { background: var(--tia-negative-soft); color: var(--tia-negative); }
body[data-theme="navy"] .pill.low { background: rgba(15,138,95,0.18); color: #6BD3A4; }
body[data-theme="navy"] .pill.med { background: rgba(181,119,10,0.18); color: #FFCB66; }
body[data-theme="navy"] .pill.high { background: rgba(197,23,46,0.18); color: #FF8896; }

.risk-card .stat-row {
  display: flex; align-items: baseline; gap: 8px;
}
.risk-card .stat-row .stat {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--fg-primary);
  font-feature-settings: "tnum";
}
.risk-card .stat-row .unit {
  font-size: 12px; color: var(--fg-muted);
}
.risk-card p {
  margin: 0;
  font-size: 12.5px;
  color: var(--fg-muted);
  line-height: 1.55;
  font-weight: 300;
}

/* Footer */
.app-footer {
  padding: 26px 36px 32px;
  font-size: 12px;
  color: var(--fg-muted);
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border-subtle);
  margin-top: 32px;
}
.app-footer .left { display: flex; gap: 16px; align-items: center; }
.app-footer .right { font-family: var(--font-mono); }

/* Tooltip */
.tt {
  position: relative;
}
.tt[data-tt]:hover::after {
  content: attr(data-tt);
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--tia-navy);
  color: #fff;
  padding: 8px 10px;
  font-size: 11.5px;
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.45;
  border-radius: 6px;
  width: max-content;
  max-width: 260px;
  white-space: normal;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

/* Scroll niceness */
.inputs-rail::-webkit-scrollbar,
.context-rail::-webkit-scrollbar,
.sens-grid-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.inputs-rail::-webkit-scrollbar-thumb,
.context-rail::-webkit-scrollbar-thumb,
.sens-grid-wrap::-webkit-scrollbar-thumb {
  background: var(--border-subtle); border-radius: 999px;
}

/* Methodology drawer (slide-over) */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 58, 0.4);
  backdrop-filter: blur(4px);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 92vw);
  background: var(--surface-page);
  border-left: 1px solid var(--border-subtle);
  z-index: 31;
  transform: translateX(100%);
  transition: transform 280ms var(--ease-standard);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; background: var(--surface-page);
}
.drawer-head h3 { margin: 0; font-size: 18px; }
.drawer-body { padding: 24px 28px 60px; }
.drawer-body h4 {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 24px 0 8px;
  font-weight: 600;
}
.drawer-body h4:first-child { margin-top: 0; }
.drawer-body p { font-size: 14px; line-height: 1.7; }
.drawer-body .formula {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--surface-muted);
  padding: 14px 16px;
  border-radius: 8px;
  border-left: 3px solid var(--tia-red);
  margin: 8px 0 16px;
  color: var(--fg-primary);
}

/* When dashboard layout cannot fit 3 columns, drop the context rail */
@media (max-width: 1280px) {
  body[data-layout="dashboard"] .workspace { grid-template-columns: 300px 1fr; }
  body[data-layout="dashboard"] .context-rail { display: none; }
}

/* Responsive collapse to single column */
@media (max-width: 720px) {
  .workspace { grid-template-columns: 1fr !important; }
  .inputs-rail {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
    max-height: none;
  }
  .topbar { grid-template-columns: 1fr auto; }
  .title-block { display: none; }
  .results-pane { padding: 22px 20px 60px; }
  .multiples-head, .multiples-row { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
  .compare-row { grid-template-columns: 1fr; }
  .risk-grid { grid-template-columns: 1fr; }
}

/* ───────── Navy header band (DCF Workbench pattern) ───────── */
.app-shell .topbar { display: none !important; }
.app-shell .result-hero { display: none !important; }

.navy-band {
  background: var(--tia-navy);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.navy-band::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 280px at 0% 0%, rgba(255,255,255,0.04), transparent 60%),
    radial-gradient(700px 260px at 100% 100%, rgba(255,0,0,0.06), transparent 60%);
}

.navy-topline {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 14px 28px 8px;
}

.navy-band .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.navy-band .brand-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--tia-red);
  box-shadow: 0 0 0 4px rgba(255,0,0,0.18);
  flex: none;
}
.navy-band .brand-text {
  display: flex; flex-direction: column;
  line-height: 1.15;
  gap: 2px;
  min-width: 0;
}
.navy-band .product {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navy-band .product .muted {
  font-weight: 400;
  color: rgba(255,255,255,0.52);
}
.navy-band .crumb {
  font-size: 11.5px;
  color: rgba(255,255,255,0.56);
  letter-spacing: 0.01em;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navy-band .live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.78);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.navy-band .live-dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: #2BD37B;
  box-shadow: 0 0 0 3px rgba(43,211,123,0.18);
}

.navy-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ghost-pill {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12.5px;
  color: rgba(255,255,255,0.78);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 7px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  white-space: nowrap;
}
.ghost-pill:hover { background: rgba(255,255,255,0.10); color: #fff; }
.ghost-pill .muted { color: rgba(255,255,255,0.46); font-weight: 400; }
.ghost-pill .seg-active {
  background: #fff; color: var(--tia-navy);
  padding: 3px 8px; border-radius: 4px; font-weight: 600; font-size: 11.5px;
}

/* KPI strip */
.kpi-strip {
  position: relative;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1.6fr;
  gap: 0;
  padding: 14px 28px 26px;
  align-items: end;
}
.kpi {
  position: relative;
  padding: 0 24px;
  border-left: 1px solid rgba(255,255,255,0.10);
  min-width: 0;
}
.kpi:first-child { padding-left: 0; border-left: 0; }
.kpi-label {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.56);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #fff;
  font-feature-settings: "tnum";
  white-space: nowrap;
}
.kpi-value--xl { font-size: 44px; }
.kpi-sub {
  margin-top: 8px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tia-accent-on-dark { color: #FF4646; }

/* Peer range slider in last KPI cell */
.peer-range {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: rgba(255,255,255,0.56);
}
.peer-low, .peer-high { font-feature-settings: "tnum"; }
.peer-track {
  position: relative;
  height: 4px;
  background: rgba(255,255,255,0.16);
  border-radius: 999px;
}
.peer-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--tia-red);
  box-shadow: 0 0 0 3px rgba(255,0,0,0.22), 0 0 0 1px rgba(255,255,255,0.4) inset;
}
.peer-marker-tip {
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tia-red);
  white-space: nowrap;
  display: none;
}
.peer-median {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: rgba(255,255,255,0.52);
  transform: translateX(-50%);
}

/* ───────── Scenario row (light, sits under navy band) ───────── */
.scenario-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px;
  padding: 14px 28px;
  align-items: center;
  background: var(--surface-page);
  border-bottom: 1px solid var(--border-subtle);
}
.scen-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.scen-eyebrow {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.scen-chips {
  display: flex;
  gap: 6px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: 8px;
}
.scen-chip {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12.5px;
  color: var(--fg-secondary);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.scen-chip:hover { color: var(--fg-primary); }
.scen-chip.active {
  background: var(--tia-navy);
  color: #fff;
}
.scen-chip .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.scen-chip .caret-up,
.scen-chip .caret-down {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
.scen-chip .caret-up { border-bottom: 5px solid #0F8A5F; }
.scen-chip .caret-down { border-top: 5px solid var(--tia-red); }
.scen-chip.active .caret-up { border-bottom-color: #4DDB94; }
.scen-chip.active .caret-down { border-top-color: #FF6868; }

.scen-readout {
  display: flex;
  align-items: center;
  gap: 28px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-secondary);
}
.scen-readout > span { display: inline-flex; align-items: center; gap: 8px; }
.scen-readout .r-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.scen-readout b {
  color: var(--fg-primary);
  font-weight: 500;
  font-feature-settings: "tnum";
}
.scen-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 1100px) {
  .kpi-strip { grid-template-columns: 1.4fr 1fr 1fr 1.6fr; }
  .kpi:nth-child(4) { display: none; }
  .scen-readout { gap: 20px; }
  .scen-readout > span:nth-child(n+3) { display: none; }
}
@media (max-width: 820px) {
  .kpi-strip { grid-template-columns: 1fr 1fr; gap: 18px; padding: 14px 20px 22px; }
  .kpi { padding: 0; border-left: 0; }
  .kpi-value--xl { font-size: 36px; }
  .scenario-row { grid-template-columns: 1fr; gap: 12px; }
}
