/* Base tokens and the a11y polish pass (SCOPE-M7 §2 accessibility bullet,
   ADR-M7-e). The beta cohort skews older, so:
     - the default body font is 18px, not 16px;
     - every load-bearing colour token below is checked against its WCAG AA
       target (4.5:1 text, 3:1 borders/icons/focus) by
       tests/unit/test_a11y_css_tokens.py, so lowering a value here fails CI,
       not just review.
   The token block is the SignalDay colour system (light mode only); the rules
   for using it live in the design handoff's color-system.md. Colour only —
   layout and type are unchanged. */

:root {

  /* Brand (Pantone-derived) */
  --brand-forest: #1C3A13;        /* Forest Elf Deep: identity, secondary buttons, links, focus, gains */
  --brand-rocky-road: #5B3F36;    /* Headings */
  --brand-primrose: #F6D155;      /* Primary CTA fill ONLY (conversion actions) */
  --brand-turquoise: #99C5C4;     /* Info fill, badges, chart series. Never text */
  --brand-lime-cream: #D7E8BC;    /* Success fill, selected fill */
  --brand-woodbine: #7B7F32;      /* Spare chart color, not assigned yet */
  --brand-orangeade: #E2552D;     /* Warning icons/borders only */
  --brand-poinsettia: #CB3441;    /* Error icons/borders, destructive button */

  /* Surfaces */
  --surface-page: #EDE6DB;        /* Whisper White */
  --surface-card: #F8F4EE;        /* Whisper Light: default text surface. Needs --line-divider edge */
  --surface-raised: #FFFFFF;      /* Modals, menus, tooltips + --shadow-raised */
  --surface-info: #E6F0EF;        /* Turquoise Mist */
  --surface-success: #EEF4E3;     /* Lime Mist */
  --surface-inverse: #1C3A13;     /* Hero / section bands */
  --surface-footer: #2A1E1A;
  --shadow-raised: 0 8px 24px rgba(42, 30, 26, .12);

  /* Text */
  --text-primary: #2A1E1A;        /* Ink: body, numbers */
  --text-heading: #5B3F36;
  --text-secondary: #6E625A;      /* Ink 2, also placeholder */
  --text-disabled: #9A8E84;       /* WCAG-exempt */
  --text-link: #1C3A13;           /* ALWAYS underlined in body copy */
  --text-link-hover: #3A6B2C;
  --text-link-visited: #5B3F36;   /* Blog/marketing only */
  --text-on-brand: #EDE6DB;       /* On --brand-forest */
  --text-on-brand-soft: #D7E8BC;
  --text-on-cta: #2A1E1A;         /* Never white on Primrose */
  --text-info: #2F6664;
  --text-warning: #A8421F;
  --text-error: #A82B37;          /* Also loss figures */

  /* Lines */
  --line-border: #8C7F75;         /* Inputs, controls (3:1) */
  --line-divider: #D2C8BA;        /* Decorative */
  --line-strong: #1C3A13;         /* 2px: selected, active tab */

  /* Primary CTA (Primrose) */
  --cta-bg: #F6D155;
  --cta-bg-hover: #E8BA2C;
  --cta-bg-pressed: #DDAE22;
  --cta-edge: #9C7A14;            /* 1px border on light surfaces */

  /* Secondary button (outline) */
  --btn2-border: #1C3A13;
  --btn2-text: #1C3A13;
  --btn2-bg-hover: #EEF4E3;
  --btn2-bg-pressed: #D7E8BC;

  /* Destructive */
  --danger-bg: #CB3441;
  --danger-bg-hover: #A82B37;
  --danger-text: #FFFFFF;

  /* Trade */
  --buy-bg: #1C3A13;  --buy-text: #EDE6DB;   /* + icon required */
  --sell-bg: #A82B37; --sell-text: #FFFFFF;  /* − icon required */

  /* States */
  --state-hover: #E4DCCF;         /* Rows/menus on page. On card use --state-hover-card */
  --state-hover-card: #F1EBE1;
  --state-disabled-bg: #E4DCCF;
  --state-disabled-border: #D2C8BA;
  --state-selected-bg: #D7E8BC;   /* + 2px --line-strong border */
  --focus-ring: #1C3A13;          /* 2px, 2px offset */
  --focus-ring-on-brand: #F6D155;
  --focus-link-bg: #F6D155;       /* + Ink text + 3px Ink underline */

  /* Chips */
  --chip-on-target-bg: #EEF4E3;   /* + 1px --brand-forest border + check icon */
  --chip-on-target-text: #1C3A13;

  /* Finance */
  --gain: #1C3A13;                /* Always with + and ▲ */
  --loss: #A82B37;                /* Always with − and ▼ */

  /* Charts: Forest ramp (account: holdings, account return line = forest-1) */
  --chart-forest-1: #1C3A13; --chart-forest-2: #2F5A22; --chart-forest-3: #4A7A36;
  --chart-forest-4: #6E9A55; --chart-forest-5: #9DBF82; --chart-forest-6: #D7E8BC;
  /* Teal ramp (overweight bars in account-vs-signal chart) */
  --chart-teal-1: #1F4847; --chart-teal-2: #2F6664; --chart-teal-3: #4F8886;
  --chart-teal-4: #7AAAA8; --chart-teal-5: #99C5C4; --chart-teal-6: #CFE3E2;
  /* Warm ramp (underweight bars; signal paper return line = warm-3, dashed) */
  --chart-warm-1: #3A2B26; --chart-warm-2: #5B3F36; --chart-warm-3: #7F665B;
  --chart-warm-4: #A89284; --chart-warm-5: #D2C8BA;
  --chart-grid: #D2C8BA;
  --chart-axis: #6E625A;
  --chart-edge: #8C7F75;          /* 1px edge on steps 4+ */

  /* Old names, kept as aliases so anything still using them follows the new
     palette. --paper was white; it is now the page colour. */
  --ink: var(--text-primary);
  --paper: var(--surface-page);
  --rule: var(--line-divider);
  --text: var(--text-primary);
  --link: var(--text-link);
  --link-hover: var(--text-link-hover);
  --disabled: var(--text-disabled);
}

body {
  margin: 0 auto;
  padding: 2rem 1.25rem;
  max-width: 40rem;
  /* SCOPE-M7 §2: 18px base, not 16px. Older readers on a 1024px laptop or
     iPad get a comfortable default without pinch-zoom. */
  font: 18px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--surface-page);
}

/* Headings scale proportionally off the 18px base. */
h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.375rem;
}

h1,
h2,
h3 {
  color: var(--text-heading);
}

/* Links are always underlined: forest green is only 1.28:1 from Ink, so the
   underline is what marks a link, not the colour. */
a {
  color: var(--text-link);
  text-decoration: underline;
}

a:hover {
  color: var(--text-link-hover);
  text-decoration-thickness: 2px;
}

a:focus-visible {
  outline: none;
  background: var(--focus-link-bg);
  color: var(--text-on-cta);
  text-decoration-thickness: 3px;
  text-decoration-color: var(--text-primary);
}

/* One focus ring for every control (2px, 2px offset). */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* SCOPE-M7 §2 slice B — 44×44px hit area, per Apple HIG / WCAG 2.5.5 AAA.
   Shared utility applied by templates to standalone buttons, checkbox/radio
   inputs, table-cell actions and any link styled as a button. Never applied
   to inline text links — the 18px body line-height already carries those. */
.tap-target {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.9rem;
  box-sizing: border-box;
  vertical-align: middle;
}

/* Checkbox/radio ship as 13px OS glyphs; give them their own hit-area
   without stretching the glyph itself. The visible tick stays where the
   user expects it. min-width/min-height do the work of enforcing the
   44×44 hit-area; margin adds visual breathing room only (margin does
   not extend a control's click zone in any browser — that was the
   pre-2026-08-24 misreading corrected by the retrospective a11y review). */
input[type="checkbox"].tap-target,
input[type="radio"].tap-target {
  width: 24px;
  height: 24px;
  margin: 10px 8px 10px 0;
  cursor: pointer;
}

header {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.5rem;
}

.messages {
  padding: 0.75rem 1rem;
  border: 1px solid var(--line-divider);
  background: var(--surface-card);
  list-style: none;
}

/* Historical money tables keep their column relationships on small screens.
   Only the named, keyboard-focusable region scrolls; the page stays in view. */
.historical-lines-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.historical-lines-scroll .lines {
  width: 100%;
  border-collapse: collapse;
}

.historical-lines-scroll th,
.historical-lines-scroll td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}

.historical-lines-scroll td {
  white-space: nowrap;
}

.historical-lines-scroll tbody tr:hover {
  background: var(--state-hover);
}

.historical-scroll-hint {
  color: var(--text-secondary);
}

/* ---- Colour system: components -------------------------------------------
   Everything below is colour only. Rules: one Primrose action per screen,
   colour is never the only cue (each state also carries an icon or sign),
   cards always carry a divider border. */

/* Secondary (outline) button: the default for every button. Templates opt in
   to .btn-primary (at most one per screen) or .btn-danger. */
button,
input[type="submit"] {
  font: inherit;
  color: var(--btn2-text);
  background: transparent;
  border: 1.5px solid var(--btn2-border);
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
  background: var(--btn2-bg-hover);
}

button:active,
input[type="submit"]:active {
  background: var(--btn2-bg-pressed);
}

.btn-primary {
  color: var(--text-on-cta);
  background: var(--cta-bg);
  border: 1px solid var(--cta-edge);
}

.btn-primary:hover {
  background: var(--cta-bg-hover);
}

.btn-primary:active {
  background: var(--cta-bg-pressed);
}

.btn-danger {
  color: var(--danger-text);
  background: var(--danger-bg);
  border: 1px solid var(--danger-bg);
}

.btn-danger:hover {
  background: var(--danger-bg-hover);
}

/* A button that reads as an inline link. */
.link-button {
  color: var(--text-link);
  background: none;
  border: 0;
  text-decoration: underline;
}

.link-button:hover {
  background: none;
  color: var(--text-link-hover);
}

button:disabled,
input[type="submit"]:disabled,
.btn-primary:disabled,
.btn-danger:disabled {
  color: var(--text-disabled);
  background: var(--state-disabled-bg);
  border: 1px solid var(--state-disabled-border);
  cursor: not-allowed;
}

/* Form fields. */
input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"], [type="file"]),
select,
textarea {
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-raised);
  border: 1px solid var(--line-border);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--state-disabled-bg);
  border-color: var(--state-disabled-border);
  color: var(--text-disabled);
}

::placeholder {
  color: var(--text-secondary);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand-forest);
}

/* Selected choice: Lime Cream fill plus a 2px strong line. */
.reason-choices li:has(input:checked) {
  background: var(--state-selected-bg);
  outline: 2px solid var(--line-strong);
}

/* Cards: Whisper Light is only 1.13:1 from the page, so the divider border
   is what draws the edge. */
.rebalance-card,
.reconcile-card,
article.account,
.metric {
  background: var(--surface-card);
  border: 1px solid var(--line-divider);
}

/* Rows on a card hover to the card tint; rows on the page use --state-hover. */
.reconcile-card tbody tr:hover,
.checklist-row:hover {
  background: var(--state-hover-card);
}

.freshness,
.prices-as-of,
.hint,
.note,
.caveat,
.unconfirmed {
  color: var(--text-secondary);
}

/* Buy / sell labels on checklist rows. SignalDay does not place trades; these
   are labels, and each carries its sign so colour is never the only cue. */
.side-buy,
.side-sell {
  display: inline-block;
  padding: 0 0.5em;
  font-weight: 600;
}

.side-buy {
  color: var(--buy-text);
  background: var(--buy-bg);
}

.side-buy::before {
  content: "+ ";
}

.side-sell {
  color: var(--sell-text);
  background: var(--sell-bg);
}

.side-sell::before {
  content: "\2212  ";
}

/* On target: its own chip (Lime Mist, forest border, check), never the grey
   disabled look. Used for a line inside its drift band and for a recorded
   trade. */
.verdict-within_band .verdict,
.done,
.confirmed {
  display: inline-block;
  padding: 0 0.5em;
  color: var(--chip-on-target-text);
  background: var(--chip-on-target-bg);
  border: 1px solid var(--brand-forest);
}

.verdict-within_band .verdict::before,
.done::before,
.confirmed::before {
  content: "\2713  ";
}

/* Alerts. Warning and error sit on the card colour with a 1px border; the
   words use the text-warning / text-error tokens and only the icon and border
   use Orangeade / Poinsettia. */
.warning,
.error,
.problem,
.verdict-needs_attention .verdict {
  background: var(--surface-card);
  border: 1px solid var(--brand-orangeade);
  padding: 0.5rem 0.75rem;
  color: var(--text-warning);
}

.error,
.problem {
  border-color: var(--brand-poinsettia);
  color: var(--text-error);
}

.warning::before,
.verdict-needs_attention .verdict::before {
  content: "\26A0\FE0E  ";
  color: var(--brand-orangeade);
}

.error::before,
.problem::before {
  content: "\2297  ";
  color: var(--brand-poinsettia);
}

/* Info and success. */
.sample-banner,
.notice {
  color: var(--text-info);
  background: var(--surface-info);
  padding: 0.5rem 0.75rem;
}

.sample-banner::before,
.notice::before {
  content: "\24D8  ";
}

.settled {
  color: var(--chip-on-target-text);
  background: var(--surface-success);
  padding: 0.5rem 0.75rem;
}

.settled::before {
  content: "\2713  ";
}
