@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Public+Sans:wght@400;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ── Design tokens ─────────────────────────────────────────────────────────── */

:root {
  /* Core palette — names kept for backward-compat with JS inline-style refs */
  --bg:     #242b3d;
  --border: #1c2030;
  --text:   #e2e5f0;
  --muted:  #929292;
  --accent: #ffffff;

  /* Surface hierarchy */
  --surface:        #2d3345;
  --surface-raised: #353c50;
  --surface-hover:  rgba(255,255,255,0.025);
  --surface-active: rgba(255,255,255,0.048);

  /* Border scale */
  --border-card:          rgba(255,255,255,0.09);
  --border-subtle:        rgba(255,255,255,0.048);
  --border-strong:        rgba(255,255,255,0.14);
  --border-control:       #444b5e;
  --border-control-hover: #6a7090;

  /* Status */
  --color-up:      hsl(49, 84%, 63%);
  --color-down:    hsl(148, 60%, 50%);
  --color-surplus: hsl(148, 58%, 52%);
  --color-error:   hsl(0, 70%, 60%);
  --color-rf:      hsl(210, 55%, 68%);

  /* Component-specific */
  --bar-track:        rgba(255,255,255,0.07);
  --badge-surplus-bg: rgba(80, 200, 120, 0.13);
  --badge-rf-bg:      rgba(100, 160, 220, 0.12);
  --tt-underline:     rgba(255,255,255,0.25);

  /* Shadows */
  --shadow-header: 0 4px 20px rgba(0,0,0,0.45);
  --shadow-tabbar: 0 4px 12px rgba(0,0,0,0.35);

  /* Layout — header-height overwritten by JS after measurement */
  --header-height: 60px;
  --tabbar-height: 0px;
}

:root.theme-light {
  --bg:     #f8f9ff;
  --border: #c3c6cf;
  --text:   #0b1c30;
  --muted:  #43474e;
  --accent: #254870;

  --surface:        #ffffff;
  --surface-raised: #eff4ff;
  --surface-hover:  rgba(0,0,0,0.030);
  --surface-active: rgba(0,0,0,0.055);

  --border-card:          #c3c6cf;
  --border-subtle:        rgba(0,0,0,0.070);
  --border-strong:        rgba(0,0,0,0.140);
  --border-control:       #73777f;
  --border-control-hover: #43474e;

  --color-up:      hsl(38, 75%, 30%);
  --color-down:    hsl(148, 55%, 28%);
  --color-surplus: hsl(148, 55%, 28%);
  --color-error:   hsl(0, 65%, 38%);
  --color-rf:      hsl(210, 55%, 40%);

  --bar-track:        rgba(0,0,0,0.07);
  --badge-surplus-bg: rgba(0, 113, 77, 0.10);
  --badge-rf-bg:      rgba(37, 72, 112, 0.10);
  --tt-underline:     rgba(0,0,0,0.28);

  --shadow-header: 0 1px 3px rgba(0,0,0,0.08), 0 2px 12px rgba(0,0,0,0.06);
  --shadow-tabbar: 0 1px 4px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.04);
}

/* ── Focus visibility ─────────────────────────────────────────────────────── */

.theme-toggle:focus-visible,
.source-link:focus-visible,
.sel:focus-visible,
.view-btn:focus-visible,
.mob-cmp-sel:focus-visible,
.mob-bar-row:focus-visible,
[data-tt]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header / nav bar (combined) ────────────────────────────────────────── */

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}
.header-brand h1 {
  font-family: 'Public Sans', 'Inter', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}
.header-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tab-bar-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  justify-self: end;
  flex-shrink: 0;
}
.theme-toggle {
  width: 34px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-control);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  outline: none;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--border-control-hover);
  color: var(--text);
  background: var(--surface-hover);
}
.source-link {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 0.625rem;
  border-radius: 8px;
  border: 1px solid var(--border-control);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.source-link:hover {
  border-color: var(--border-control-hover);
  color: var(--text);
  background: var(--surface-hover);
}
.icon-sun  { display: block; }
.icon-moon { display: none; }
:root.theme-light .icon-sun  { display: none; }
:root.theme-light .icon-moon { display: block; }

/* ── Year select ─────────────────────────────────────────────────────────── */

.sel {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  padding: 0.3rem;
  line-height: 1.2;
  border-radius: 8px;
  border: 1px solid var(--border-control);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.12s;
}
.sel:hover { border-color: var(--border-control-hover); }
.sel:focus  { border-color: var(--accent); }
#year-select { min-width: 88px; text-align: center; }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */

.tab-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-header);
  flex-shrink: 0;
}
.tab-btns { display: flex; }
.view-toggle-wrap { justify-self: end; }
.tab-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.75rem 1rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── View container ──────────────────────────────────────────────────────── */

#view {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Tab panels ──────────────────────────────────────────────────────────── */

.tab-panel {
  display: none;
  flex-direction: column;
  min-height: calc(100dvh - var(--header-height) - var(--tabbar-height));
}
.tab-panel.active { display: flex; }
.tab-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
}
.mob-card-placeholder {
  min-height: 120px;
  align-items: center;
  justify-content: center;
}
.mob-card-placeholder .tab-placeholder { flex: none; }

/* ── Reconciliation strip ───────────────────────────────────────────────── */

.recon-strip {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 1.5rem;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}
.recon-track {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: max-content;
}
.recon-arrow {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.recon-step {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', sans-serif;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.recon-step-lbl {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.recon-step-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  font-family: 'Public Sans', 'Inter', sans-serif;
}
.recon-step--muted { opacity: 0.5; }
.recon-step--muted:hover { opacity: 0.85; background: var(--surface-hover); }
.recon-step--active {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
}
.recon-step--active .recon-step-lbl { color: var(--text); }
.recon-step--active .recon-step-val {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.recon-step--deduct .recon-step-val { font-size: 0.85rem; }

/* ── Mobile pill track (<640px) ─────────────────────────────────────────── */

.recon-track-mobile { display: none; }

@media (max-width: 640px) {
  .recon-strip {
    padding: 6px 8px;
    overflow-x: hidden;
    justify-content: stretch;
  }
  .recon-track { display: none; }
  .recon-track-mobile {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 2px;
  }
  .recon-arrow--mobile {
    flex: 0 0 auto;
    font-size: 0.6rem;
    color: var(--muted);
    line-height: 1;
  }
  .recon-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    gap: 1px;
    padding: 4px 2px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    line-height: 1.15;
  }
  .recon-pill-lbl {
    font-size: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .recon-pill-val {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    font-family: 'Public Sans', 'Inter', sans-serif;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .recon-pill--muted { opacity: 0.5; }
  .recon-pill--active {
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    flex: 1.6 1 0;
  }
  .recon-pill--active .recon-pill-lbl { color: var(--text); }
}

/* ── Sankey ──────────────────────────────────────────────────────────────── */

#sankey-view {
  flex: 1;
  position: relative;
  display: none;
}
#income-view {
  flex: 1;
  position: relative;
}
.sk-col-head {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  fill: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.sk-label { font-family: 'Inter', sans-serif; font-size: 1rem; fill: var(--text); }
.sk-value { font-family: 'Inter', sans-serif; font-size: 0.9rem; fill: var(--muted); }
.sk-link { transition: opacity 0.12s; cursor: default; }
.sk-link:hover { opacity: 0.55 !important; }
.sk-node { cursor: default; }
.sk-page-btn { cursor: pointer; }
.sk-page-btn-bg {
  fill: var(--surface);
  stroke: #aac4f0;
  stroke-width: 1;
  transition: fill 0.12s;
}
.sk-page-btn:hover .sk-page-btn-bg { fill: #dce8ff; }
.sk-page-btn-label {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  fill: #2a5fb0;
  pointer-events: none;
  user-select: none;
}
.sk-page-btn--off { cursor: default; }
.sk-page-btn--off .sk-page-btn-bg    { fill: #f5f5f5; stroke: #d0d0d0; }
.sk-page-btn--off .sk-page-btn-label { fill: #bbb; }

/* ── Tooltip — always dark for contrast in both modes ───────────────────── */

#tooltip {
  position: fixed;
  background: #21273a;
  border: 1px solid #2a3045;
  color: #dde3f0;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.72rem;
  pointer-events: none;
  z-index: 999;
  display: none;
  max-width: 260px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.65);
  line-height: 1.45;
}
#tooltip strong { display: block; font-weight: 700; margin-bottom: 4px; font-size: 0.78rem; color: #e2e5f0; }
.tt-val     { font-family: 'Inter', sans-serif; color: #dde3f0; }
.tt-sub     { display: block; color: #8892aa; font-family: 'Inter', sans-serif; font-size: 0.63rem; margin-top: 4px; }
.tt-explain { font-style: italic; border-top: 1px solid rgba(255,255,255,0.10); margin-top: 8px; padding-top: 4px; max-width: 200px; white-space: normal; line-height: 1.4; }

/* ── Status overlay ──────────────────────────────────────────────────────── */

#status-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 50;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  flex-direction: column;
  gap: 10px;
}
#status-overlay.hidden { display: none; }
.status-error { color: var(--color-error); }

/* ── View toggle ─────────────────────────────────────────────────────────── */

.view-toggle-wrap { display: flex; gap: 4px; justify-self: end; align-self: end; padding-bottom: 0.5rem; }
.view-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-control);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  outline: none;
  transition: border-color 0.12s, color 0.12s;
}
.view-btn:hover  { border-color: var(--border-control-hover); color: var(--text); }
.view-btn.active { border-color: var(--accent); color: var(--accent); }

/* ── Treemap ─────────────────────────────────────────────────────────────── */

#treemap-view { flex: 1; position: relative; display: none; }
.tm-cell { cursor: default; transition: filter 0.1s; }
.tm-cell:hover { filter: brightness(1.18); }
.tm-drillable { cursor: pointer; }
.tm-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  fill: rgba(255,255,255,0.92);
  font-weight: 500;
  pointer-events: none;
}
.tm-value {
  font-family: 'Inter', sans-serif;
  font-size: 0.62rem;
  fill: rgba(255,255,255,0.58);
  pointer-events: none;
}
.tm-breadcrumb { font-family: 'Inter', sans-serif; font-size: 0.7rem; dominant-baseline: middle; pointer-events: none; }
.tm-back-label { fill: var(--accent); }
.tm-path-sep   { fill: var(--border-control); }
.tm-path-cur   { fill: var(--muted); }

/* ── Council Tax tab ─────────────────────────────────────────────────────── */

#tab-council-tax.active { display: block; }

/* ── Council Tax redesigned layout (ct2-*) ───────────────────────────────── */

.ct2-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.ct2-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 1rem;
}

/* Hero split layout */
.ct2-hero-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
  align-items: center;
}
.ct2-hero-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  min-width: 0;
}
.ct2-hero-card[data-tt] { cursor: help; }
.ct2-hero-val {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.ct2-support-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Cards */
.ct2-card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  min-width: 0;
}
.ct2-card[data-tt] { cursor: help; }
.ct2-card-lbl {
  font-size: 0.67rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}
.ct2-card-val {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.ct2-note-mark {
  font-size: 0.6em;
  font-weight: 400;
  vertical-align: super;
  margin-left: 0.15em;
  opacity: 0.55;
}
.ct2-card-sub { font-size: 0.73rem; margin-top: 4px; color: var(--muted); }
.ct2-lbl-full  { display: none; }
.ct2-lbl-short { display: inline; }
@media (min-width: 721px) {
  .ct2-lbl-full  { display: inline; }
  .ct2-lbl-short { display: none; }
}
.ct2-breakdown-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 1.25rem;
}
.ct2-cards-sub-hdr {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.ct2-cards-sub {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ct2-cards-sub .ct2-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.75rem 1rem;
}
.ct2-cards-sub .ct2-card-lbl {
  grid-column: 1;
  grid-row: 1 / 3;
  margin-bottom: 0;
  align-self: center;
}
.ct2-cards-sub .ct2-card-val {
  grid-column: 2;
  grid-row: 1;
  font-size: 1.05rem;
  text-align: right;
}
.ct2-cards-sub .ct2-card-sub {
  grid-column: 2;
  grid-row: 2;
  margin-top: 0;
  text-align: right;
}
.ct2-card-solo {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

/* Section wrapper */
.ct2-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}
.ct2-h3 {
  font-family: 'Public Sans', 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0;
}

/* Collapsible sections (band table, waterfall) */
.ct2-section.ct2-details { display: block; padding: 0; gap: 0; }
.ct2-details-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 1.25rem 1.5rem;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.ct2-details-toggle .ct2-h3 { margin: 0; }
.ct2-details-toggle .ct2-explain-icon { font-size: 0.7rem; color: var(--muted); transition: transform 0.15s; flex-shrink: 0; }
.ct2-details-toggle[aria-expanded="true"] .ct2-explain-icon { transform: rotate(180deg); }
.ct2-details-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 1.5rem 1.25rem;
}
.ct2-details-body[hidden] { display: none; }

/* Waterfall */
.ct2-wf { display: flex; flex-direction: column; }
.ct2-wf-row {
  display: grid;
  grid-template-columns: minmax(160px, 212px) 1fr minmax(68px, 88px) minmax(100px, 132px);
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.ct2-wf-row:last-child { border-bottom: none; }
.ct2-wf-top    { padding-top: 4px; }
.ct2-wf-result { padding-top: 0.5rem; }
.ct2-wf-lbl { font-size: 0.84rem; color: var(--text); font-weight: 500; min-width: 0; }
.ct2-wf-top .ct2-wf-lbl,
.ct2-wf-result .ct2-wf-lbl { font-weight: 600; }
.ct2-wf-less .ct2-wf-lbl { color: var(--muted); font-size: 0.8rem; padding-left: 0.75rem; }
.ct2-bar-track { height: 8px; background: var(--bar-track); border-radius: 4px; overflow: hidden; }
.ct2-bar-fill  { height: 100%; border-radius: 4px; }
.ct2-wf-val {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.ct2-wf-less-val { color: var(--muted); font-weight: 400; }
.ct2-wf-result .ct2-wf-val { font-weight: 600; }
.ct2-wf-chg { font-size: 0.72rem; white-space: nowrap; text-align: right; color: var(--muted); }
.ct2-wf-sep {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.5rem 0 0.25rem 0.75rem;
}
.ct2-wf-rule { height: 1px; background: var(--border-strong); margin: 4px 0; }
.ct2-has-tt {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 4px;
  text-decoration-color: var(--tt-underline);
}

/* Band table */
.ct2-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ct2-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.ct2-table thead th {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.5rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  cursor: default;
}
.ct2-table thead th[data-tt] { cursor: help; }
.ct2-table thead th:first-child { text-align: left; }
.ct2-table tbody td {
  padding: 0.5rem 1rem;
  text-align: right;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ct2-table tbody td:first-child { text-align: left; }
.ct2-table tbody tr:hover td { background: var(--surface-hover); }
.ct2-band-d td { background: var(--surface-active); font-weight: 600; }
.ct2-muted   { color: var(--muted) !important; }
.ct2-col-sep { border-left: 1px solid var(--border-strong); }

.ct2-area-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.ct2-area-link:hover { opacity: 1; color: var(--text); }
.ct2-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 8px;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
}
.ct2-note { font-size: 0.75rem; color: var(--muted); margin: 0; }
.ct2-explainer { font-size: 0.75rem; font-weight: 400; color: var(--muted); line-height: 1.4; margin: 0; }
.ct2-explainer + .ct2-explainer { margin-top: 8px; }
.ct2-explainer-lead {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}
.ct2-explainer-lead + .ct2-explainer { margin-top: 8px; }

/* ── Plain-English landing callout (all tabs) ────────────────────────────── */

.plain-summary {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 16px;
}

/* ── Glossary inline tooltips (jargon terms, badges) ─────────────────────── */

.gloss-term {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: help;
}
.gloss-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 8px;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  opacity: 0.7;
  flex-shrink: 0;
}

/* ── Reporting-change warning banner (Council Tax tab) ────────────────────── */

.ct2-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid hsl(4, 70%, 45%);
  border-radius: 8px;
  background: hsl(4, 70%, 45%, 0.12);
  color: hsl(4, 75%, 35%);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
}
:root:not(.theme-light) .ct2-warning {
  border-color: hsl(4, 80%, 60%);
  background: hsl(4, 70%, 45%, 0.18);
  color: hsl(4, 90%, 78%);
}
.ct2-warning-icon { font-size: 1.1rem; flex-shrink: 0; line-height: 1.4; }

/* ── "Why did my bill change?" explainer (Council Tax tab) ───────────────── */

.ct2-explain {
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background: var(--surface-hover);
  overflow: hidden;
}
.ct2-explain-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.ct2-explain-icon { font-size: 0.7rem; transition: transform 0.15s; }
.ct2-explain-toggle[aria-expanded="true"] .ct2-explain-icon { transform: rotate(180deg); }
.ct2-explain-body {
  padding: 0 16px 16px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.ct2-explain-body p { margin: 0 0 8px; }
.ct2-explain-body p:last-child { margin-bottom: 0; }

/* Change indicators */
.ct-up   { color: var(--color-up); }
.ct-dn   { color: var(--color-down); }
.ct-flat { color: var(--muted); }
.ct-na   { color: var(--muted); font-style: italic; font-size: 0.9em; }

/* ── Mobile bar list (Expenditure, Services, Income) ─────────────────────── */

.mob-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}
.mob-bar-row { cursor: pointer; }
.mob-bar-row:active { opacity: 0.65; }
.mob-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mob-swatch { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.mob-name { flex: 1; font-size: 0.87rem; font-weight: 500; color: var(--text); min-width: 0; }
.mob-val  { font-size: 0.8rem; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mob-pct  { font-size: 0.72rem; color: var(--muted); min-width: 60px; text-align: right; flex-shrink: 0; white-space: normal; line-height: 1.35; }
.mob-bar-track { height: 4px; background: var(--bar-track); border-radius: 999px; margin-left: 20px; }
.mob-bar-fill  { height: 100%; border-radius: 999px; opacity: 0.8; }
.mob-bar-track-split { display: flex; }
.mob-bar-income-fill { height: 100%; border-radius: 999px; opacity: 0.28; }
.mob-income-sub {
  font-size: 0.68rem;
  color: var(--muted);
  margin-left: 20px;
  margin-top: 4px;
  margin-bottom: 4px;
  line-height: 1.35;
}
.mob-income-sub-earn { color: var(--color-surplus); }
.mob-sub-total  { font-size: 0.72rem; color: var(--muted); margin-top: -4px; }
.mob-explainer  { font-size: 0.75rem; color: var(--muted); line-height: 1.4; }
.mob-surplus-val {
  font-size: 0.8rem;
  color: var(--color-surplus);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.mob-surplus-tag {
  font-size: 0.62rem;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--badge-surplus-bg);
  color: var(--color-surplus);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}
.mob-surplus-note { font-size: 0.68rem; color: var(--muted); margin-left: 20px; margin-top: 4px; line-height: 1.4; }
.mob-na { color: var(--muted); font-style: italic; font-size: 0.85rem; padding: 8px 0; }

/* Expenditure rows: net-cost primary bar + muted grants/fees underbar */
.mob-exp-row { position: relative; }
.mob-expand-icon {
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.mob-exp-row-open .mob-expand-icon { transform: rotate(45deg); }
.mob-bar-track-under { margin-top: 4px; height: 2px; }
.mob-bar-track-under .mob-bar-income-fill { opacity: 0.45; }

/* Service-group drill-down panel */
.mob-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: -4px 0 4px 20px;
  padding: 8px 0 0 12px;
  border-left: 1px solid var(--border-subtle);
}
.mob-detail[hidden] { display: none; }

/* Net Earners section divider */
.mob-divider { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.mob-divider-label {
  font-family: 'Public Sans', 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.mob-divider-note { font-size: 0.72rem; color: var(--muted); line-height: 1.4; margin: 0 0 8px; }
.mob-total { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mob-total > .mob-controls { margin-left: auto; align-self: center; }
.mob-total-val {
  font-family: 'Public Sans', 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.mob-total-lbl { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.mob-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mob-card > .mob-controls:last-child { margin-bottom: -8px; }
.mob-cmp-sel {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  padding: 8px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-control);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  outline: none;
  margin-left: auto;
  transition: border-color 0.12s, color 0.12s;
}
.mob-cmp-sel:hover  { border-color: var(--border-control-hover); color: var(--text); }
.mob-cmp-sel.active { border-color: hsl(44,80%,56%); color: hsl(44,80%,56%); }
.mob-cmp-sel option { background: var(--surface); color: var(--text); }

/* ── Card containers for tab sections (matches Council Tax .ct2-card) ─────── */

.mob-card {
  padding: 1rem;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background: var(--surface-hover);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mob-card-pad-b { padding-bottom: 1.5rem; }
.mob-card .mob-divider:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ── Ring-fenced callout (Expenditure tab) ───────────────────────────────── */

.mob-rf-box {
  margin-top: 8px;
  padding: 1rem;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background: var(--surface-hover);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mob-rf-title { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.mob-rf-row   { display: flex; align-items: center; gap: 8px; }
.mob-rf-name  { flex: 1; font-size: 0.82rem; color: var(--muted); min-width: 0; }
.mob-rf-val   { font-size: 0.8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mob-rf-tag {
  font-size: 0.62rem;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--badge-rf-bg);
  color: var(--color-rf);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}
.mob-rf-note { font-size: 0.72rem; color: var(--muted); line-height: 1.45; margin: 0; }

/* ── Tablet ──────────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .ct2-wrap { padding: 1rem 1.25rem; gap: 1.5rem; }
  .ct2-hero-split { grid-template-columns: 1fr; }
  .ct2-wf-row { grid-template-columns: 1fr minmax(64px, 80px) minmax(80px, 112px); }
  .ct2-bar-track { display: none; }
  .ct2-wf-chg { min-width: 80px; }
  .ct2-muted { display: none; }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  :root {
    --header-height: 88px;
    --tabbar-height: 0px;
  }

  .header-subtitle { display: none; }
  .header-brand h1 { font-size: 0.9rem; }
  .tab-bar { grid-template-columns: 1fr auto; grid-template-rows: auto auto; padding: 0; }
  .header-brand { padding: 0.5rem 1rem 0; }
  .tab-bar-right { grid-row: 1; grid-column: 2; padding: 0.5rem 1rem 0; }
  .tab-btns { grid-column: 1 / -1; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 0 8px; border-top: 1px solid var(--border-subtle); }
  .tab-btns::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 0.5rem 0.75rem; font-size: 0.72rem; white-space: nowrap; }
  .view-btn { font-size: 0.65rem; padding: 8px 8px; }

  .ct2-wrap { padding: 0.75rem 1rem; gap: 1.25rem; }
  .ct2-hero-val { font-size: 1.8rem; }
  .ct2-card-val { font-size: 1.05rem; }
  .ct2-cards-sub .ct2-card-val { font-size: 0.95rem; }
  .ct2-wf-row { grid-template-columns: 1fr minmax(56px,72px) minmax(72px,100px); }
  .ct2-bar-track { display: none; }
  .ct2-table-wrap { scrollbar-width: none; }
  .ct2-table-wrap::-webkit-scrollbar { display: none; }
  .ct2-wf-less .ct2-wf-lbl { padding-left: 8px; }
}

/* ── Landing overlay ─────────────────────────────────────────────────────── */

.landing-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.landing-overlay.hidden { display: none; }

.landing-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
}

.landing-logo {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.landing-logo-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.landing-logo-sub {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.landing-intro {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.landing-warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid hsl(38, 70%, 45%);
  background: hsla(38, 70%, 45%, 0.12);
  color: var(--color-up);
  font-size: 0.83rem;
  line-height: 1.55;
}
:root.theme-light .landing-warn {
  border-color: hsl(38, 65%, 38%);
  background: hsla(38, 80%, 50%, 0.10);
  color: hsl(38, 75%, 30%);
}
.landing-warn-icon {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1.55;
}
.landing-warn strong { font-weight: 700; }
.landing-warn-link {
  color: inherit;
  text-underline-offset: 2px;
}
.landing-warn-link:hover { opacity: 0.8; }

.landing-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  align-self: flex-end;
  transition: opacity 0.15s;
}
.landing-btn:hover { opacity: 0.88; }
.landing-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .landing-card { padding: 24px 20px; gap: 16px; }
  .landing-btn { align-self: stretch; text-align: center; }
}

/* ── Site footer ─────────────────────────────────────────────────────────── */

.site-footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 16px 16px 24px;
  opacity: 0.6;
}
