/* Ad Budget Planner - ledger-paper sheet: cool paper, ink-green accent, tabular numbers. */
:root {
  --bg: #f3f6f4; --paper: #ffffff; --ink: #14211b; --muted: #5a6a62; --line: #d5ded9; --line2: #e8eeea;
  --accent: #0b6e4f; --accent-ink: #ffffff; --accent-soft: #dcefe6; --calc: #eef3f0; --calc-ink: #23382e;
  --warn: #9a5b00; --warn-bg: #fff3dc; --bad: #b3261e; --bad-bg: #fde8e6; --good: #11643f; --good-bg: #e1f3e8; --info-bg: #e9eff6; --info: #2b4c6f;
  --focus: #1d7dd8; --shadow: 0 1px 2px rgba(20, 33, 27, .06), 0 4px 18px rgba(20, 33, 27, .05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1613; --paper: #16201c; --ink: #e3ece7; --muted: #95a69d; --line: #2c3a34; --line2: #223029;
  --accent: #3fbf8a; --accent-ink: #06140e; --accent-soft: #173a2c; --calc: #1b2823; --calc-ink: #cfe1d7;
  --warn: #f2b453; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1c1a; --good: #6fdca5; --good-bg: #133022; --info-bg: #17263a; --info: #9cc3ea;
  --focus: #5aa9ff; --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
.hidden { display: none !important; }
.small { font-size: .875rem; }
.muted { color: var(--muted); }
code { font-family: var(--mono); font-size: .9em; }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.back { color: var(--muted); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.session { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.credits { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }
.hero { padding: 26px 0 14px; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0 0 8px; letter-spacing: -.01em; }
.lede { margin: 0 0 12px; color: var(--muted); max-width: 46rem; }
.trust { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.trust li { font-size: .82rem; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.h2 { font-size: 1.1rem; margin: 18px 0 8px; }
h3 { font-size: 1rem; margin: 14px 0 4px; }

.btn { font: inherit; font-size: .95rem; min-height: 40px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.solid { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
.btn.solid:disabled { opacity: .45; cursor: not-allowed; }
.btn.quiet { background: transparent; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: .85rem; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.xtoggle { margin-left: auto; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; min-height: 40px; }
.check input { width: 18px; height: 18px; }
.samples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 4px; }
.sample { font: inherit; font-size: .88rem; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--ink); cursor: pointer; }
.sample[aria-pressed="true"] { border-style: solid; font-weight: 600; }
.note { margin: 8px 0; padding: 8px 12px; border-radius: 8px; background: var(--info-bg); color: var(--info); font-size: .92rem; }
.note.bad { background: var(--warn-bg); color: var(--warn); }
.hint { margin: 8px 0 0; }

/* the sheet */
.gridwrap { scroll-margin-top: 72px; margin-top: 10px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); -webkit-overflow-scrolling: touch; }
.gridwrap.over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.sheet { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 980px; font-variant-numeric: tabular-nums; font-size: .9rem; }
.sheet th, .sheet td { border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2); padding: 0; height: 40px; }
.sheet thead th { position: sticky; top: 0; background: var(--paper); font-size: .76rem; font-weight: 600; color: var(--muted); text-align: left; padding: 6px 8px; line-height: 1.2; height: auto; border-bottom: 2px solid var(--line); vertical-align: bottom; }
.sheet th.calc, .sheet td.calc { background: var(--calc); color: var(--calc-ink); text-align: right; }
.sheet thead th.calc { text-align: right; }
.sheet td.calc { padding: 0 10px; white-space: nowrap; font-family: var(--mono); font-size: .84rem; }
.sheet td.calc.miss { color: var(--warn); font-family: inherit; font-size: .72rem; font-weight: 700; letter-spacing: .03em; }
.sheet td.calc.good { color: var(--good); font-weight: 600; }
.sheet td.calc.poor { color: var(--bad); font-weight: 600; }
.sheet .rn { width: 34px; text-align: center; color: var(--muted); font-size: .75rem; background: var(--paper); }
.sheet .x { display: none; }
.sheet.show-extra .x { display: table-cell; }
.sheet .ai { display: none; }
.sheet.show-ai .ai { display: table-cell; }
.sheet td.ai { padding: 0 8px; white-space: nowrap; font-family: var(--mono); font-size: .84rem; background: var(--accent-soft); }
.sheet thead th.ai { background: var(--accent-soft); color: var(--ink); }
.sheet .act { width: 40px; text-align: center; }
.sheet td.in { background: var(--paper); }
.sheet td.in input, .sheet td.in select { width: 100%; height: 39px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .9rem; padding: 0 8px; border-radius: 0; }
.sheet td.in select { padding-right: 2px; cursor: pointer; }
.sheet td.c-num input { text-align: right; font-family: var(--mono); font-size: .86rem; }
.sheet td.in input:focus, .sheet td.in select:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--paper); }
.sheet td.in input.wrong { background: var(--bad-bg); color: var(--bad); }
.sheet .c-name { min-width: 170px; position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--line); }
.sheet thead th.c-name { z-index: 3; }
.sheet .c-plat { min-width: 128px; }
.sheet .c-role { min-width: 92px; }
.sheet .c-num { min-width: 80px; }
.sheet tr.unused td.calc { background: var(--line2); }
.sheet tfoot td { font-weight: 700; background: var(--paper); border-top: 2px solid var(--ink); border-bottom: 0; padding: 0 10px; white-space: nowrap; }
.sheet tfoot td.calc { font-family: var(--mono); }
.sheet tfoot td.in.c-num { text-align: right; font-family: var(--mono); }
.del { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; border-radius: 6px; cursor: pointer; }
.del:hover { background: var(--bad-bg); color: var(--bad); }
.pill { display: inline-block; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--line2); color: var(--ink); }
.pill.a-raise { background: var(--good-bg); color: var(--good); }
.pill.a-lower, .pill.a-cut { background: var(--bad-bg); color: var(--bad); }
.pill.a-test { background: var(--info-bg); color: var(--info); }

/* results */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--calc); }
.tile .tl { display: block; font-size: .75rem; color: var(--muted); }
.tile b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.sumline { margin: 10px 0; }
.targets { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 6px 0 12px; }
.opt { display: flex; flex-direction: column; gap: 3px; }
.lab { font-size: .8rem; color: var(--muted); }
.opt input, .opt select, #aiNote { font: inherit; font-size: .95rem; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.opt input { width: 11rem; }
.opt input.wrong { border-color: var(--bad); background: var(--bad-bg); }
#aiNote { width: 100%; }
.more summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--muted); font-size: .9rem; }
.more[open] { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.exports { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.checks, .flags { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li, .flags li { padding: 8px 12px; border-radius: 8px; border-left: 4px solid var(--line); background: var(--line2); font-size: .93rem; }
.checks li.ok, .flags li.ok { border-left-color: var(--good); background: var(--good-bg); }
.checks li.warn, .flags li.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.checks li.info { border-left-color: var(--info); background: var(--info-bg); }

/* AI review */
.aibox summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; gap: 8px; }
.ai-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
.progress { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.ph { display: flex; justify-content: space-between; }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: .9rem; }
.steps li { color: var(--muted); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.done { color: var(--good); }
.steps li.fail { color: var(--bad); font-weight: 600; }
.verdict-line { margin: 10px 0 4px; }
.verdict { display: inline-block; font-weight: 700; padding: 3px 10px; border-radius: 6px; background: var(--line2); }
.verdict.v-ready-to-launch { background: var(--good-bg); color: var(--good); }
.verdict.v-adjust-first { background: var(--warn-bg); color: var(--warn); }
.verdict.v-missing-data { background: var(--bad-bg); color: var(--bad); }
.proj { color: var(--muted); }
.fhm { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.plain { margin: 0; padding-left: 18px; font-size: .92rem; }
.plain li { margin: 3px 0; }

.saved { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.hist { font: inherit; text-align: left; width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); cursor: pointer; }
.about { max-width: 52rem; margin-top: 26px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 14px 16px 40px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; font-size: .9rem; z-index: 20; max-width: calc(100% - 32px); }

@media (max-width: 760px) {
  h1 { font-size: 1.55rem; }
  .hero { padding-top: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fhm { grid-template-columns: 1fr; }
  .xtoggle { margin-left: 0; }
  .sheet .c-name { min-width: 132px; }
  .back-t { display: none; }
  .opt input { width: 9.5rem; }
}
@media print {
  .top, .bar, .samples, .hint, .aibox .ai-row, #historyCard, .about, .foot, .exports, .del, .act, #ss-overlay, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .gridwrap { overflow: visible; border: 0; }
  .sheet { min-width: 0; font-size: 9pt; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
