/* ==========================================================================
   Components.
   ========================================================================== */

/* ─────────────────────────────── buttons ─────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:hover { background: var(--surface-raised); box-shadow: var(--lift-2), var(--edge); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn--ghost { background: transparent; box-shadow: none; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--surface-1); box-shadow: var(--lift-1); color: var(--text-primary); }

.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); }

.btn--icon { width: 34px; padding: 0; }
.btn--sm { height: 28px; padding: 0 9px; font-size: 12px; }

.btn__glyph { font-size: 14px; line-height: 1; }

/* ────────────────────────── segmented control ────────────────────────── */

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.seg__btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.seg__btn:hover { color: var(--text-primary); }
.seg__btn[aria-pressed='true'] {
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: var(--lift-1);
}

/* ──────────────────────────── input panels ──────────────────────────── */

.panel {
  background: var(--surface-1);
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  box-shadow: var(--lift-1), var(--edge);
  overflow: hidden;
}

.panel__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: 13px var(--gap-4);
  text-align: left;
  transition: background 0.15s var(--ease);
}
.panel__toggle:hover { background: var(--surface-2); }

.panel__icon { font-size: 15px; line-height: 1; }

.panel__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-right: auto;
}

.panel__chevron {
  color: var(--text-muted);
  transition: transform 0.2s var(--ease);
  font-size: 11px;
}
.panel[data-open='true'] .panel__chevron { transform: rotate(90deg); }

.panel__body { padding: 0 var(--gap-4) var(--gap-4); }
.panel[data-open='false'] .panel__body { display: none; }

.panel__blurb {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 var(--gap-4);
}

.fieldset { margin-top: var(--gap-4); }
.fieldset:first-child { margin-top: 0; }

.fieldset__legend {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--gap-3);
}

/* ─────────────────────────────── fields ─────────────────────────────── */

.field { margin-bottom: var(--gap-4); }
.field:last-child { margin-bottom: 0; }

.field__head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field__derived {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.control {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.control.is-invalid { border-color: var(--critical); }

.control__prefix, .control__suffix {
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  flex: none;
  font-variant-numeric: tabular-nums;
}
.control__prefix { padding-right: 0; }
.control__suffix { padding-left: 0; }

.control__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  border: none;
  background: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border-radius: var(--r-sm);
}
.control__input:focus { outline: none; }
.control__input::-webkit-outer-spin-button,
.control__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.control__input[type='number'] { -moz-appearance: textfield; }

select.control__input {
  appearance: none;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.field__error {
  font-size: 12px;
  color: var(--critical);
  margin-top: 4px;
}

.field__hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* slider paired with the number box */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 8px 0 0;
  background: none;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--surface-2) var(--fill, 50%));
  border: 1px solid var(--border);
}
.slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--surface-2) var(--fill, 50%));
  border: 1px solid var(--border);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  box-shadow: var(--lift-1);
}
.slider::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  box-shadow: var(--lift-1);
}

/* toggle switch */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 0;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.18s var(--ease);
  flex: none;
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface-raised);
  box-shadow: var(--lift-1);
  transition: transform 0.18s var(--ease);
}
.switch input:checked + .switch__track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--accent-ring); }
.switch__label { font-size: 13px; color: var(--text-secondary); }

/* quick-pick chips */
.chips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.chip {
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.chip:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-ring); }
.chip[aria-pressed='true'] { background: var(--accent); border-color: transparent; color: #fff; }

/* ───────────────────────── explanation tooltips ───────────────────────── */

.info {
  width: 15px; height: 15px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.info:hover, .info:focus-visible { background: var(--accent); border-color: transparent; color: #fff; }

.tip-pop {
  position: fixed;
  z-index: 100;
  max-width: 288px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--lift-3);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.14s var(--ease), transform 0.14s var(--ease);
}
.tip-pop.is-visible { opacity: 1; transform: translateY(0); }
.tip-pop strong { color: var(--text-primary); display: block; margin-bottom: 3px; font-weight: 600; }

/* ────────────────────────────── verdict ────────────────────────────── */

.verdict {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  border: 1px solid transparent;
  background: var(--surface-1);
  padding: var(--gap-6);
  box-shadow: var(--lift-2), var(--edge);
}

.verdict::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--verdict-accent, var(--series-1));
}

.verdict[data-verdict='buy']   { --verdict-accent: var(--series-1); }
.verdict[data-verdict='rent']  { --verdict-accent: var(--series-2); }
.verdict[data-verdict='close'] { --verdict-accent: var(--chart-axis); }

.verdict__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--gap-4);
}
.verdict__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--verdict-accent);
}

.verdict__headline {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: var(--gap-3);
}

/* The one hero figure in the view. Proportional figures, same sans as the rest. */
.verdict__figure {
  font-size: clamp(40px, 6vw, 60px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
  margin-bottom: var(--gap-3);
  color: var(--verdict-accent);
}

.verdict__sub {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 66ch;
  line-height: 1.6;
}

.verdict__scores {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-5);
  margin-top: var(--gap-5);
  padding-top: var(--gap-5);
  border-top: 1px solid var(--border);
}

.score { display: flex; align-items: center; gap: 10px; }
.score__key { width: 3px; height: 30px; border-radius: 2px; flex: none; }
.score__label { font-size: 12px; color: var(--text-muted); display: block; }
.score__value { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.score--win .score__value { color: var(--text-primary); }

/* drivers */
.drivers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
  gap: var(--gap-4);
}

.driver {
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
  padding: var(--gap-4);
}
.driver__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.driver__key { width: 3px; height: 15px; border-radius: 2px; flex: none; }
.driver__label { font-size: 13px; font-weight: 600; }
.driver__side {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.driver__text { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* tipping points */
.tipping { display: flex; flex-direction: column; gap: 10px; }
.tipping__item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.tipping__marker {
  margin-top: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  flex: none;
}

.caveat {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  border-left: 2px solid var(--border-strong);
  padding-left: var(--gap-3);
}

/* ──────────────────────────────── KPIs ──────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--gap-3);
}

.kpi {
  position: relative;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
  padding: 14px 15px;
  transition: transform 0.18s var(--spring), box-shadow 0.18s var(--ease);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--lift-2), var(--edge); }

.kpi__head { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; }
.kpi__label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.kpi__value {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.kpi__meta { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.kpi__meta--good { color: var(--good-ink); }
.kpi__meta--bad { color: var(--critical); }

.kpi--accent-buy  { box-shadow: inset 3px 0 0 var(--series-1); }
.kpi--accent-rent { box-shadow: inset 3px 0 0 var(--series-2); }

/* ──────────────────────────────── cards ──────────────────────────────── */

.card {
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
  padding: var(--gap-5);
}

.card__head { margin-bottom: var(--gap-4); }
.card__title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card__sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--gap-4);
}

.card--full { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: var(--gap-4); }
}

/* ────────────────────────────── warnings ────────────────────────────── */

.notices { display: flex; flex-direction: column; gap: var(--gap-2); }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface-1);
  box-shadow: var(--lift-1), var(--edge);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.notice__icon { font-size: 13px; line-height: 1.4; flex: none; }
.notice__title { font-weight: 600; color: var(--text-primary); display: block; margin-bottom: 2px; }
.notice[data-level='warning'] { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }

/* ───────────────────────────── data table ───────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  box-shadow: var(--lift-1), var(--edge);
  background: var(--surface-1);
  max-height: 520px;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  text-align: right;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table thead th:first-child { text-align: left; }

.data-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.data-table td:first-child {
  text-align: left;
  color: var(--text-primary);
  font-weight: 500;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tbody tr[data-breakeven='true'] td { background: var(--accent-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.pill__dot { width: 6px; height: 6px; border-radius: 50%; }
.pill[data-side='buy']  { color: var(--text-primary); }
.pill[data-side='rent'] { color: var(--text-primary); }

/* ─────────────────────────── sensitivity ─────────────────────────── */

.sens-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-3);
  align-items: flex-end;
  margin-bottom: var(--gap-4);
}
.sens-controls .field { margin-bottom: 0; min-width: 190px; flex: 1 1 190px; }

.heat-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--gap-3);
  font-size: 11.5px;
  color: var(--text-muted);
}
.heat-legend__ramp { display: flex; flex: none; gap: 2px; }
.heat-legend__step { width: 20px; height: 10px; border-radius: 2px; }

/* ──────────────────────────── scenarios ──────────────────────────── */

.scenario-save {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  margin-bottom: var(--gap-4);
}
.scenario-save .control { flex: 1 1 180px; min-width: 0; }

.scenario-list { display: flex; flex-direction: column; gap: var(--gap-2); }

.scenario {
  display: flex;
  align-items: center;
  gap: var(--gap-4);
  padding: 14px 16px;
  border-radius: var(--r-lg);
  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);
}
.scenario:hover { transform: translateY(-1px); box-shadow: var(--lift-2), var(--edge); }
.scenario[data-active='true'] { border-color: var(--accent); }
.scenario[data-picked='true'] { box-shadow: var(--lift-2), 0 0 0 2px var(--accent-ring); }

.scenario__pick { padding: 0; flex: none; }
.scenario__body { min-width: 0; margin-right: auto; }

.scenario__name {
  display: block;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-bottom: 3px;
}

.scenario__verdict {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.scenario__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.scenario__facts { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.scenario__fact { font-size: 11.5px; color: var(--text-muted); }
.scenario__fact strong {
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.scenario__spark { flex: none; opacity: 0.9; }
@media (max-width: 640px) { .scenario__spark { display: none; } }

.scenario__actions { display: flex; gap: 4px; flex: none; }

.compare-key {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 7px;
}

.empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: var(--gap-4);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

/* comparison table highlight */
.compare-table td.is-best { color: var(--text-primary); font-weight: 600; }

/* ─────────────────────────────── toast ─────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 120;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text-primary);
  color: var(--plane);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--lift-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ───────────────────────────── mobile nav ───────────────────────────── */

.mobile-switch {
  position: sticky;
  top: var(--topbar-h);
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: var(--gap-3) var(--gap-4) 0;
  background: var(--plane);
}
.mobile-switch .seg { width: 100%; max-width: 340px; }
.mobile-switch .seg__btn { flex: 1; }

/* The inputs/results switch only exists while the two columns are stacked. */
@media (min-width: 1041px) {
  .mobile-switch { display: none; }
}

/* Narrow screens: the toolbar keeps every action but drops to glyphs, and the
   brand gives up its tagline before anything is allowed to overflow. */
@media (max-width: 720px) {
  :root { --topbar-h: 52px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .brand { gap: 8px; }
  .brand__name { font-size: 14px; }
  .topbar .switch__label { display: none; }
  .btn__text { display: none; }
  .toolbar { gap: 6px; }
  .btn { padding: 0 10px; }
}

@media (max-width: 420px) {
  .brand__name { display: none; }
}

/* ──────────────────────────────── print ──────────────────────────────── */

@media print {
  .topbar, .sidebar, .mobile-switch, .no-print { display: none !important; }
  .shell { display: block; padding: 0; max-width: none; }
  body { background: #fff; }
  .card, .verdict, .kpi, .panel {
    break-inside: avoid;
    box-shadow: none;
    border-color: #ddd;
  }
  .main { gap: 18px; }
  .table-wrap { max-height: none; overflow: visible; }
  .verdict__figure { font-size: 40px; }
}
