/* GetAhead house stylesheet
   The design system in Docs/design-system.md, made real. Read off the deal page (index.html),
   which remains the reference implementation until it is switched over to this file.

   Contains only system-level rules - nothing that knows about budgets, deals or listings.
   Page-specific layers sit in their own file and may extend these classes. */

:root {
  /* Surfaces and ink */
  --paper:#FBFAF6;
  --panel:#FFFFFF;
  --ink:#16191F;
  --muted:#6A7079;
  --line:#E7E2D8;
  --line-strong:#D8D2C4;

  /* Named from usage on the deal page, where they were raw hex */
  --field:#FEFEFC;        /* input backgrounds */
  --highlight:#F7F4EC;    /* emphasised column or cell */
  --zebra:#FCFBF8;        /* alternating rows, pill backgrounds */
  --placeholder:#F2EFE7;  /* image placeholders */
  --ink-2:#33383f;        /* long-form copy */
  --ink-3:#3a3f47;        /* secondary / indented rows */
  --ink-soft:#5a544b;     /* column headings, straplines */

  /* Meaning. There is no blue: a text affordance is green, a filled one is ink. */
  --pos:#0F7A5A;
  --neg:#C24A34;
  --ring:#16191F;

  --shadow: 0 1px 2px rgba(20,25,31,.04), 0 8px 24px rgba(20,25,31,.05);

  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Profile theme: every page reads these instead of the raw tokens above for the five surfaces
     a user can recolour (see /profile.html, web/js/theme.js). Defaults just alias the existing
     palette, so a user who has never set a theme sees the site exactly as before - theme.js only
     ever overrides these as inline styles on an already-signed-in page, never edits this file. */
  --theme-bg: var(--paper);
  --theme-tile: var(--panel);
  --theme-emphasis: var(--highlight);
  --theme-toggle: var(--ink);
  --theme-appbar: #1f2430;
}

/* ===== base ===== */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--theme-bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1440px; margin: 0 auto; padding: 28px 26px 80px; }

/* ===== masthead and labels ===== */
header.masthead {
  display: flex; align-items: baseline; gap: 16px;
  border-bottom: 1px solid var(--line-strong); padding-bottom: 16px; margin-bottom: 20px;
}
.mark {
  font-family: var(--mono); font-weight: 700; font-size: 20px; letter-spacing: -.02em;
  padding: 4px 10px; border: 1.5px solid var(--ink); border-radius: 6px;
}
.masthead h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.masthead .sub { color: var(--muted); font-size: 13px; margin-left: auto; }

/* Label tier 1: top of a column or major block. Sits outside the card it introduces. */
.col-head {
  font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-soft); margin: 2px 2px 12px; display: flex; align-items: baseline; gap: 10px;
}
/* Label tier 2: a section within a column. */
.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px;
}
.col-head .sub, .section-label .hint {
  font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--muted); font-size: 12px; margin-left: auto;
}

/* ===== surfaces ===== */
.card {
  background: var(--theme-tile); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; box-shadow: var(--shadow);
}
.card-sm {
  background: var(--theme-tile); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.card-mini { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
/* A horizontal strip of controls - the deal page's saved-deals bar. */
.bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--theme-tile); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.popover {
  background: var(--theme-tile); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(20,25,31,.22); padding: 14px 16px 15px;
}
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,25,31,.4); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 20; overflow: auto;
}
.modal { background: var(--paper); border-radius: 14px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line-strong);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 8px 22px 24px; overflow-x: auto; }
/* The only divider used inside a card. */
.rule-dashed { border-top: 1px dashed var(--line-strong); }
footer.foot {
  margin-top: 30px; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--line); padding-top: 14px;
}
footer.foot code { font-family: var(--mono); }

/* ===== layout ===== */
.split { display: grid; grid-template-columns: 1.42fr 1fr; gap: 26px; align-items: start; }
.lower { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: start; margin-bottom: 26px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 26px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }

@media (max-width: 1040px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 620px)  { .lower { grid-template-columns: 1fr; } .strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px)  { .tiles { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }

/* ===== figures ===== */
/* Every number in the app: mono, tabular, so columns stay true regardless of digit count. */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }

.cap { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.cap-sm { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
/* Mono figures of 17px and up take the tightening; smaller ones never do. */
.fig    { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.fig-lg { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.fig-sm { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.fig small, .fig-lg small, .fig-sm small { font-size: 12px; color: var(--muted); font-weight: 500; }
.copy { font-size: 13px; line-height: 1.5; color: var(--ink-2); }

/* ===== tables ===== */
/* Statement - read row by row. Rules only at header, subtotal and total; never a vertical. */
table.stmt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stmt th, table.stmt td {
  padding: 6px 10px; text-align: right;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
table.stmt th.lbl, table.stmt td.lbl { text-align: left; font-family: var(--sans); }
table.stmt thead th { font-family: var(--sans); font-weight: 700; font-size: 12px; border-bottom: 1.5px solid var(--line-strong); }
/* A group row is a label by nature, so it opts out of the mono/right default without needing .lbl
   in the markup (the deal page relies on the class being there). */
table.stmt tr.grp td {
  font-family: var(--sans); text-align: left; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); font-weight: 700; padding-top: 12px;
}
table.stmt td.indent { padding-left: 20px; color: var(--ink-3); }
table.stmt tr.sub td { border-top: 1px solid var(--line); font-weight: 600; }
table.stmt tr.sub td.lbl { font-weight: 700; }
/* The strongest mark in the system. Once per table. */
table.stmt tr.total td {
  border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
  font-weight: 700; font-size: 14px;
}
/* Emphasis on a column is a tint, never a border. */
table.stmt th.base, table.stmt td.base { background: var(--theme-emphasis); }

/* Comparison - read column by column, so every row is ruled. */
table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
table.cmp th, table.cmp td {
  text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
table.cmp thead th { font-family: var(--sans); font-size: 13px; font-weight: 700; border-bottom: 1.5px solid var(--line-strong); }
table.cmp th.metric, table.cmp td.metric { text-align: left; font-family: var(--sans); color: var(--muted); font-weight: 600; }

/* Dense - many rows, scrolled, zebra-striped, sticky header. */
.tablewrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; }
table.dense { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.dense th, table.dense td {
  padding: 6px 10px; text-align: right; white-space: nowrap;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
table.dense th {
  font-family: var(--sans); font-weight: 700; font-size: 10.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1.5px solid var(--line-strong);
  position: sticky; top: 0; background: var(--panel);
}
table.dense td.lbl, table.dense th.lbl { text-align: left; }
table.dense tbody tr:nth-child(even) { background: var(--zebra); }

/* ===== controls ===== */
input[type="text"], input[type="number"], input[type="url"], input[type="email"], select, textarea {
  font-family: var(--sans); font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--field); color: var(--ink);
}
input.num, input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.field-label { font-size: 11px; color: var(--muted); font-weight: 600; }

.btn {
  font-family: var(--sans); font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 7px 12px; border-radius: 6px;
  border: 1px solid var(--ink); background: var(--theme-toggle); color: #fff;
}
.btn-ghost { background: transparent; color: var(--ink); }
/* A text affordance is green - the house has no link blue. */
.btn-text {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 700; color: var(--pos);
}
a { color: var(--pos); text-decoration: none; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  padding: 5px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.seg button.on, .seg button[aria-selected="true"] { background: var(--theme-toggle); color: #fff; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto;
  border: 1px solid var(--line-strong); border-radius: 20px;
  padding: 5px 6px 5px 12px; background: var(--zebra);
}
.badge {
  font-size: 9px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700;
  background: var(--ink); color: #fff; padding: 2px 7px; border-radius: 20px;
}
.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: transparent; color: var(--muted); font-size: 10px; font-weight: 700;
  cursor: pointer; margin-left: 3px; padding: 0; line-height: 1;
  vertical-align: middle; font-family: var(--sans);
}
.help:hover { border-color: var(--ink); color: var(--ink); }
input[type="range"], input[type="checkbox"] { accent-color: var(--ink); }

/* ===== states ===== */
/* Focus is the ink ring, everywhere, never a hue. */
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ring); outline-offset: 1px; border-color: var(--ring); }
.btn:focus-visible, .seg button:focus-visible, .help:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
/* Selection is an ink hairline, optionally with a lift. */
.is-selected { border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring); }
.is-selected-strong { border-color: var(--ring); box-shadow: 0 0 0 1.5px var(--ring), var(--shadow); transform: translateY(-3px); }
.is-dim { opacity: .7; }
.is-dim.on, .is-dim:hover { opacity: 1; }
[disabled], .is-disabled { opacity: .4; cursor: not-allowed; }
.danger-hover:hover { color: var(--neg); }

/* ===== motion ===== */
/* The only transition in the app. Transform only, 120ms. */
.lift { transition: transform .12s ease; }
