/* Solar Split design system: components.
   Section 1 is the Modernist component layer from the approved mockup (verbatim values).
   Section 2 is the app-level components the prototype builds on top (nav, bottom tab bar,
   More sheet, segmented buttons, switch, slider, toast, statement dialog, meters).
   Class names are the public API: see docs/architecture/design-system.md. */

/* ── 1. Modernist layer ─────────────────────────────────────────────── */
.hr { height: 2px; border: 0; margin: var(--space-4) 0; background: var(--color-divider); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); color: var(--color-bg); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); color: var(--color-text); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; margin-top: var(--space-2); justify-content: flex-start; text-align: left; }

.field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }

.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.radio input, .seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.radio .dot { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid var(--color-divider); }
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot { border-color: var(--color-accent); background: var(--color-accent); box-shadow: inset 0 0 0 4px var(--color-bg); }
.radio input:focus-visible + .dot { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.seg { display: inline-flex; overflow: hidden; border: 1px solid var(--color-divider); border-radius: var(--radius-md); }
.seg-opt { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked) { background: var(--color-accent); color: var(--color-bg); }
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: -2px; }

.card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface); }
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.card-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 17px; line-height: 1.2; }
.card-body { margin: 0; font-size: 13px; opacity: 0.8; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

.tag { display: inline-flex; align-items: center; font-size: 11px; letter-spacing: 0.02em; padding: 3px 10px; border-radius: calc(var(--radius-md) * 0.75); }
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-accent-2 { background: var(--color-accent-2-100); color: var(--color-accent-2-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
.tag-outline-strong { border: 1px solid var(--color-accent-700); color: var(--color-accent-700); }
.tag-ink { background: var(--color-text); color: var(--color-bg); }
.tag-battery { background: var(--color-accent-800); color: var(--color-bg); }

.nav { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-bottom: 2px solid var(--color-divider); }
.nav-brand { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 18px; margin-right: auto; }
.nav a { color: inherit; text-decoration: none; font-size: 14px; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--color-accent); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 72%, transparent);
  padding: var(--space-2); border-bottom: 2px solid var(--color-divider);
}
.table td { padding: var(--space-2); border-bottom: 1px solid var(--color-divider); }
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.dialog-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: var(--space-4); background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent); }
.dialog { width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-lg); }
.dialog-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 20px; }
.dialog-body { font-size: 14px; opacity: 0.85; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* ── 2. App components ──────────────────────────────────────────────── */
/* skip link */
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--color-text); color: var(--color-bg); font-weight: 600; }
.skip-link:focus { top: 8px; }

/* brand mark + wordmark */
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { display: block; flex: none; }

/* pulse square ("live") */
.pulse-dot { display: block; flex: none; background: var(--color-accent); width: 8px; height: 8px; }
.pulse-dot--sm { width: 6px; height: 6px; }

/* desktop top navigation */
.appnav { position: sticky; top: 0; z-index: 20; background: var(--color-bg); padding: 0 var(--space-6); min-height: 64px; gap: var(--space-6); flex-wrap: wrap; --tab-h: 64px; }
.appnav .nav-brand { gap: 10px; margin-right: var(--space-2); }
.appnav-tabs { display: flex; gap: var(--space-4); align-self: stretch; margin-right: auto; flex-wrap: wrap; }
.nav a.appnav-tab, .nav a.appnav-tab:hover {
  display: flex; align-items: center; min-height: var(--tab-h);
  font-size: 14px; font-weight: 400; color: var(--color-text);
  box-shadow: inset 0 -3px 0 transparent; text-decoration: none; white-space: nowrap;
}
.nav a.appnav-tab[aria-current='page'] { font-weight: 800; color: var(--color-accent-700); box-shadow: inset 0 -3px 0 var(--color-accent); }
.appnav--wrap { --tab-h: 48px; }
.appnav--wrap .appnav-tabs { order: 3; flex-basis: 100%; border-top: 1px solid var(--color-divider); }
.appnav-tag { margin-left: auto; }
.avatar-btn { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* mobile top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--color-bg); padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 2px solid var(--color-divider); }
.topbar-title { font: 800 17px var(--font-heading); }
.topbar-status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; }

/* bottom tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); border-top: 2px solid var(--color-divider); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--color-bg); }
.tabbar-item {
  appearance: none; border: 0; margin: 0; font: inherit; text-align: inherit; cursor: pointer;
  background: var(--color-bg); color: var(--color-text);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 10px; min-height: 48px; font-size: 10px;
  box-shadow: inset 0 3px 0 transparent; text-decoration: none;
}
.tabbar-item[aria-current='page'], .tabbar-item.is-active { color: var(--color-accent-700); box-shadow: inset 0 3px 0 var(--color-accent); }
a.tabbar-item:hover { color: var(--color-text); }
a.tabbar-item[aria-current='page']:hover { color: var(--color-accent-700); }

/* More sheet */
.scrim { position: fixed; inset: 0; z-index: 35; background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent); overscroll-behavior: contain; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 36; background: var(--color-bg); box-shadow: var(--shadow-lg); padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); border-top: 2px solid var(--color-divider); }
.sheet-head { display: flex; align-items: center; margin-bottom: var(--space-2); }
.sheet-title { font: 800 17px var(--font-heading); }
.sheet-close { margin-left: auto; min-height: 44px; }
.sheet-row {
  appearance: none; border: 0; margin: 0; padding: 0; font: inherit; text-align: inherit; background: transparent; cursor: pointer;
  display: flex; align-items: center; gap: var(--space-3); min-height: 52px;
  border-top: 1px solid var(--color-divider); width: 100%; font-size: 16px; color: var(--color-text); text-decoration: none;
}
.sheet-row .arrow { margin-left: auto; }
.sheet-row[aria-current='page'] { color: var(--color-accent-700); }
a.sheet-row:hover { color: var(--color-text); }

/* buttons: app variants */
.btn-cta { background: var(--color-accent-700); color: var(--color-bg); min-height: 44px; min-width: 180px; justify-content: flex-start; }
.btn-cta:hover { background: var(--color-accent-800); color: var(--color-bg); }
.btn-cta .arrow, .btn-lg .arrow { margin-left: auto; }
.btn-lg { min-height: 44px; }
.btn-ghost-strong { color: var(--color-accent-700); }
.btn-square { width: 40px; height: 40px; padding: 0; justify-content: center; }

/* segmented control built from buttons */
.seg button.seg-opt {
  border: 0; font: inherit; font-size: 13px; font-weight: 400; min-height: 40px; cursor: pointer;
  background: transparent; color: var(--color-text);
}
.seg button.seg-opt[aria-pressed='true'] { background: var(--color-text); color: var(--color-bg); font-weight: 800; }
.seg button.seg-opt:hover { box-shadow: inset 0 -2px 0 var(--color-accent); }
.seg button.seg-opt:focus-visible { outline-offset: -4px; }

/* inputs at touch size (16px stops iOS zoom) */
.input-touch { font-size: 16px; min-height: 44px; }
.input-num { text-align: right; }

/* range slider and switch */
.range { flex: 1; accent-color: var(--color-accent); min-height: 32px; }
.switch { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0; border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; align-self: flex-start; }
.switch-track { position: relative; width: 44px; height: 24px; background: var(--color-neutral-400); transition: background-color var(--dur-switch) ease; flex: none; }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: var(--color-bg); transform: translateX(0); transition: transform var(--dur-switch) var(--ease-switch); }
.switch[aria-checked='true'] .switch-track { background: var(--color-accent-700); }
.switch[aria-checked='true'] .switch-knob { transform: translateX(20px); }
.switch-text { font: 800 15px var(--font-heading); }

/* toast */
.toast-region { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; }
.toast { background: var(--color-text); color: var(--color-bg); padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow-lg); display: flex; gap: 8px; align-items: center; white-space: nowrap; }

/* modal (statement) */
.modal-scrim { z-index: 60; overscroll-behavior: contain; }
.modal { position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain; background: var(--color-bg); box-shadow: var(--shadow-lg); }
.modal-bar { display: flex; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-bottom: 2px solid var(--color-divider); position: sticky; top: 0; background: var(--color-bg); }

/* chips, swatches and meters */
.swatch { display: block; flex: none; width: 10px; height: 10px; background: var(--sw, currentColor); }
.swatch--12 { width: 12px; height: 12px; }
.swatch--8 { width: 8px; height: 8px; }
.meter { display: flex; }
.meter > * { min-width: 0; transform-origin: left; }
.meter--split { gap: 2px; }
.meter > .meter-right { transform-origin: right; }
.meter-seg { flex: var(--flex, 1) 1 0%; background: var(--sw); }

/* labels */
.label-caps { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-800); }
.label-caps--tight { letter-spacing: 0.06em; }
.note { font-size: 12px; color: var(--color-neutral-800); }
.note-13 { font-size: 13px; color: var(--color-neutral-800); }
.num { font-variant-numeric: tabular-nums; }
.kicker-accent { color: var(--color-accent-700); }

/* chart tooltip: a blurred paper pane that follows the pointer (behaviour in charts.js attachChartTooltip) */
.chart-tip {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; width: max-content; max-width: min(300px, calc(100vw - 24px));
  padding: 14px 16px 12px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-bg) 72%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-text) 14%, transparent), 0 18px 48px color-mix(in srgb, var(--color-text) 22%, transparent), 0 2px 8px color-mix(in srgb, var(--color-text) 8%, transparent);
  font: 13px/1.35 var(--font-body); color: var(--color-text); opacity: 0; visibility: hidden; will-change: transform, opacity;
}
.tip-title { font: 800 15px var(--font-heading); letter-spacing: -0.01em; }
.tip-sub { color: var(--color-neutral-700); font-size: 12px; margin-top: 1px; }
.tip-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent); }
.tip-group + .tip-group { margin-top: 12px; }
.tip-gh { display: flex; justify-content: space-between; gap: 24px; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tip-sw { width: 10px; height: 10px; flex: none; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-text) 20%, transparent); }
.tip-label { color: var(--color-neutral-800); flex: 1; }
.tip-num { font-variant-numeric: tabular-nums; }
.tip-val { font-weight: 600; padding-left: 12px; }
