/* Colour roles — see the dataviz skill's palette.md for where these values
   come from. Status colours (--good/--critical) are fixed, never themed. */
:root {
  color-scheme: light;
  --page-bg: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --good-wash: rgba(12, 163, 12, 0.10);
  --critical: #d03b3b;
  --critical-wash: rgba(208, 59, 59, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page-bg: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.15);
    --good: #0ca30c;
    --good-wash: rgba(12, 163, 12, 0.15);
    --critical: #e66767;
    --critical-wash: rgba(230, 103, 103, 0.15);
  }
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  margin: 0;
  padding: 2rem 1.5rem;
}

.page { max-width: 1200px; margin: 0 auto; }

h1 { margin: 0 0 0.15rem 0; font-size: 1.85rem; }
.subtitle { color: var(--text-secondary); margin: 0 0 1.75rem 0; }

.disclaimer {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem 0;
  max-width: 62ch;
}

.scenario-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.5rem 0;
}

.scenario-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}
.scenario-btn:hover { border-color: var(--accent); color: var(--accent); }

.scenario-message {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.scenario-message.error { color: var(--critical); }
.scenario-message.success { color: var(--good); }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .results-col { position: static !important; }
}

.results-col { position: sticky; top: 1.5rem; }

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(11, 11, 11, 0.04);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem 0;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.section-heading svg:first-child { color: var(--accent); flex-shrink: 0; }

.collapsible-heading {
  cursor: pointer;
  user-select: none;
}
.chevron {
  margin-left: auto;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.collapsed .chevron { transform: rotate(-90deg); }

.section-summary {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 0.6rem;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}
.collapsed .section-summary { display: block; }

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--text-secondary);
  gap: 0.3rem;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input[type="number"], input[type="text"] {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--page-bg);
  color: var(--text-primary);
  font-size: 0.95rem;
  width: 10rem;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

input:disabled {
  background: var(--gridline);
  color: var(--text-muted);
  border-color: transparent;
  cursor: not-allowed;
}
input:disabled::placeholder { color: var(--text-muted); opacity: 0.7; }

.note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0 0;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gridline);
}

.row input[type="text"] { width: 12rem; }
.row input[type="number"] { width: 8rem; }

button { font-family: inherit; cursor: pointer; border-radius: 6px; font-size: 0.9rem; }

.add-row-btn {
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--border);
  padding: 0.55rem 1rem;
  width: 100%;
}

.remove-btn {
  background: transparent;
  color: var(--critical);
  border: 1px solid var(--border);
  padding: 0.45rem 0.8rem;
  height: fit-content;
}

.button-row {
  display: flex;
  gap: 0.75rem;
}

.calculate-btn {
  background: var(--accent);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border: none;
  flex: 2;
}

.reset-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  flex: 1;
}

.form-error {
  color: var(--critical);
  background: var(--critical-wash);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  margin: 0 0 1rem 0;
}

.stage-group {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--gridline);
}
.stage-group:last-child { border-bottom: none; padding-bottom: 0; }

.stage-label { margin: 0 0 0.2rem 0; font-size: 0.95rem; color: var(--text-primary); }
.stage-hint { margin: 0 0 0.6rem 0; font-size: 0.8rem; color: var(--text-muted); }

.advanced-block { padding-top: 1.4rem; border-top: 1px solid var(--gridline); margin-top: 0.4rem; }
.advanced-block:first-of-type { padding-top: 0; border-top: none; margin-top: 0; }
.advanced-subheading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 1.75rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 0.75rem; opacity: 0.6; }
.empty-state p { margin: 0; max-width: 22rem; margin-inline: auto; }

.terms-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.toggle-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}
.toggle-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.headline {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.headline.good { background: var(--good-wash); }
.headline.critical { background: var(--critical-wash); }

.headline-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}
.headline-status svg { flex-shrink: 0; }
.headline.good .headline-status { color: var(--good); }
.headline.critical .headline-status { color: var(--critical); }

.headline-value { font-size: 2.5rem; font-weight: 600; line-height: 1.1; color: var(--text-primary); }
.headline-sub { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.35rem; }

.chart-wrap { margin-bottom: 1rem; }
canvas { max-width: 100%; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

th, td {
  border-bottom: 1px solid var(--gridline);
  padding: 0.45rem 0.6rem;
  text-align: right;
}

th { color: var(--text-muted); font-weight: 600; }
td:first-child, th:first-child { text-align: left; }
td { color: var(--text-secondary); }

/* Match the stacked chart's pot colours (General/ISA/Pension) so the table reads as an extension of it. */
.pot-col-general { color: #2a78d6; }
.pot-col-isa { color: #eb6834; }
.pot-col-pension { color: #1baf7a; }

@media (prefers-color-scheme: dark) {
  .pot-col-general { color: #3987e5; }
  .pot-col-isa { color: #d95926; }
  .pot-col-pension { color: #199e70; }
}

.table-scroll { overflow-x: auto; }
