/* National Income Practice: a page from a statistical abstract. Cool grey ground, white sheet, a navy band over every
   table head (as government statistics tables print them), figures in tabular numerals, and a turmeric accent for the
   problem numbers and the one button that matters. Square corners, thin rules, a strong left edge. On paper: black
   rules on white, no dark bands. */
:root {
  --bg: #eceff3;
  --paper: #ffffff;
  --ink: #18222e;
  --muted: #4c5866;
  --line: #cdd4dd;
  --band: #1f3a5a;
  --band-ink: #ffffff;
  --rule: #1f3a5a;
  --accent: #9a4a07;
  --accent-ink: #ffffff;
  --accent-soft: #f6e8d8;
  --link: #1d4f86;
  --wash: #f4f6f9;
  --stripe: #f7f8fa;
  --ok: #1b6a3a;
  --ok-soft: #ddf0e3;
  --close: #7a5300;
  --close-soft: #f6ead0;
  --bad: #a3271f;
  --bad-soft: #f9e2de;
  --focus: #1b5fd0;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --head: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --paper: #18202a;
    --ink: #e4e9ef;
    --muted: #a9b4c1;
    --line: #2e3a48;
    --band: #2b4a70;
    --band-ink: #f2f6fb;
    --rule: #7fa6d6;
    --accent: #f0a65a;
    --accent-ink: #1a1006;
    --accent-soft: #3a2a17;
    --link: #8fbaf0;
    --wash: #1d2631;
    --stripe: #1b232d;
    --ok: #8fd8a3;
    --ok-soft: #15301d;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #8ab8ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); font-variant-numeric: tabular-nums; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
a { color: var(--link); text-underline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- hero and setup ---------- */
.hero { padding: 20px 0 8px; }
h1 { font-family: var(--head); font-weight: 700; font-size: clamp(1.55rem, 4.4vw, 2.35rem); line-height: 1.15; margin: 0 0 6px; max-width: 26ch; }
.lede { margin: 0 0 10px; color: var(--muted); max-width: 66ch; }
.setup { display: grid; gap: 10px; margin-bottom: 14px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: 0.92rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.seg { display: flex; flex-wrap: wrap; border: 1px solid var(--band); background: var(--paper); width: fit-content; max-width: 100%; }
.sg { position: relative; display: flex; }
.sg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sg span { display: flex; align-items: center; min-height: 44px; padding: 6px 14px; font-size: 0.95rem; border-right: 1px solid var(--line); cursor: pointer; white-space: nowrap; }
.sg:last-child span { border-right: 0; }
.sg input:checked + span { background: var(--band); color: var(--band-ink); font-weight: 600; }
.sg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.setrow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
.field { display: grid; gap: 2px; font-size: 0.92rem; font-weight: 600; color: var(--muted); }
.task-f select { min-width: 13em; }
.taskdesc { margin: 0; font-size: 0.93rem; color: var(--muted); max-width: 70ch; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--band); border-radius: 0; }
select { min-height: 44px; padding: 4px 8px; font-weight: 400; }
.btn { font: inherit; font-size: 0.97rem; min-height: 44px; padding: 8px 16px; border: 1px solid var(--band); background: var(--paper); color: var(--band); cursor: pointer; border-radius: 0; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn { color: var(--rule); border-color: var(--rule); } }
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { min-height: 40px; padding: 6px 14px; }
.link { font: inherit; background: none; border: 0; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; padding: 10px 4px; min-height: 44px; }

/* ---------- notes ---------- */
.note { overflow-wrap: anywhere; padding: 10px 12px; background: var(--bad-soft); border: 1px solid var(--bad); margin: 0 0 12px; }
.note.info { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- the sheet ---------- */
.sheet { background: var(--paper); border: 1px solid var(--line); padding: 14px 18px 16px; outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; border-bottom: 2px solid var(--rule); padding-bottom: 8px; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-family: var(--head); font-size: 1.3rem; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.06em; }
.sline { margin: 0; color: var(--muted); font-size: 0.95rem; }
.score { margin: 0 0 0 auto; font-size: 0.95rem; font-weight: 600; }
.rules { margin: 2px 0 6px; font-size: 0.95rem; }
.rules summary, .work summary, .recent summary, .faq summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--link); font-weight: 600; }
.rules ul { margin: 4px 0 8px; padding-left: 20px; color: var(--muted); }
.qs { list-style: none; margin: 0; padding: 0; }
.q { padding: 8px 0 18px; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q h3 { font-family: var(--head); font-size: 1.15rem; margin: 8px 0 4px; display: flex; gap: 10px; align-items: baseline; }
.qn { display: inline-flex; min-width: 1.7em; height: 1.7em; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-ink); font-size: 0.9rem; flex: none; }
.scen { margin: 0 0 8px; max-width: 75ch; font-weight: 500; }
.qnote { margin: 4px 0 0; font-size: 0.92rem; color: var(--muted); }

/* ---------- the given table ---------- */
.twrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; }
.dt { font-size: 0.95rem; background: var(--paper); border-bottom: 2px solid var(--rule); }
.dt.given { min-width: min(100%, 560px); }
.dt th, .dt td { padding: 4px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.dt thead th { background: var(--band); color: var(--band-ink); font-weight: 600; font-size: 0.88rem; vertical-align: bottom; }
.dt tbody tr:nth-child(even) { background: var(--stripe); }
.dt tbody th { font-weight: 400; }
.dt .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dt .sno { color: var(--muted); white-space: nowrap; width: 3.4em; }
.dt thead th.sno { color: var(--band-ink); }
.dt.goods th.yr { text-align: center; border-left: 1px solid var(--band-ink); }
.dt.goods .per { color: var(--muted); font-size: 0.85em; }
.dt.inex { width: 100%; }
.dt.inex th.txt { min-width: 12em; }
.dt.inex .rn { color: var(--muted); }
.dt.inex td.ch { white-space: nowrap; width: 1%; }
.dt.inex .why { display: block; font-size: 0.9rem; color: var(--muted); margin-top: 2px; }

/* ---------- answer lines ---------- */
.answers { margin-top: 12px; display: grid; gap: 12px; }
@media (min-width: 820px) { .q-two .answers { grid-template-columns: 1fr 1fr; align-items: start; } .q-two .agrp:nth-child(3) { grid-column: 1 / -1; } }
.agrp { border-left: 3px solid var(--line); padding-left: 12px; }
.gname { margin: 0 0 4px; font-family: var(--head); font-size: 1rem; }
.arow { margin: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 4px 0; border-bottom: 1px dotted var(--line); max-width: 640px; }
.arow label, .arow .alab { font-size: 0.95rem; flex: 1 1 14em; }
.aval { display: inline-flex; align-items: center; gap: 6px; }
.cu, .un { color: var(--muted); font-size: 0.92rem; }
.cell { width: 9.5em; min-height: 44px; padding: 4px 8px; text-align: right; font-size: 16px; border: 1px solid var(--line); border-bottom: 2px solid var(--band); background: var(--wash); font-variant-numeric: tabular-nums; }
.pick { min-height: 44px; border: 1px solid var(--line); border-bottom: 2px solid var(--band); background: var(--wash); }
.cell:focus, .pick:focus { background: var(--paper); outline: 2px solid var(--focus); outline-offset: 0; }
.cell.is-right, .pick.is-right { border-color: var(--ok); background: var(--ok-soft); }
.cell.is-wrong, .cell.is-unread, .pick.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.cell.is-close { border-color: var(--close); background: var(--close-soft); }
.wline { display: inline-block; width: 34mm; border-bottom: 1px solid #000; height: 1.3em; }

/* ---------- feedback, key ---------- */
.fbwrap { margin-top: 8px; }
.fb { margin: 4px 0; padding: 6px 10px; font-size: 1rem; border: 1px solid var(--line); background: var(--wash); max-width: 80ch; }
.fb.right { border-color: var(--ok); background: var(--ok-soft); }
.fb.wrong, .fb.unread { border-color: var(--bad); background: var(--bad-soft); }
.fb.close { border-color: var(--close); background: var(--close-soft); }
.qfoot { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.work { margin-top: 6px; }
.keyfig { margin-top: 4px; }
.kv { font-variant-numeric: tabular-nums; }
.steps { margin: 10px 0 0; padding-left: 20px; font-size: 0.95rem; max-width: 80ch; }
.steps li { margin: 4px 0; }
.unused { font-size: 0.92rem; color: var(--muted); max-width: 80ch; }

/* ---------- share, recent ---------- */
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; }
.confirm { margin: 0; flex-basis: 100%; padding: 10px 12px; background: var(--bad-soft); border: 1px solid var(--bad); }
.share { margin: 16px 0 6px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.print-row label { display: inline-flex; align-items: center; gap: 8px; }
.share-out label { display: grid; gap: 4px; font-size: 0.95rem; }
.share-out input { width: 100%; min-height: 44px; padding: 6px 8px; }
.recent ul { list-style: none; padding: 0; margin: 4px 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 4px 0; }
.recent small { display: block; color: var(--muted); }
.hint { font-size: 0.9rem; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); background: var(--ink); color: var(--bg); padding: 10px 16px; max-width: min(92vw, 520px); font-size: 0.95rem; transition: transform 0.2s; z-index: 20; pointer-events: none; }
.toast.on { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- content and footer ---------- */
.content { max-width: 75ch; padding: 20px 0 10px; }
.content h2 { font-family: var(--head); font-size: 1.35rem; margin: 26px 0 6px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq details p { margin: 0 0 12px; }
.sources { font-size: 0.92rem; color: var(--muted); margin-top: 22px; }
footer { border-top: 2px solid var(--rule); margin-top: 20px; padding: 14px 0 26px; font-size: 0.92rem; color: var(--muted); }
.indep { margin: 0 0 8px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.9; }
.sb-more a, .sb-credit a { color: var(--link); }

/* ---------- phones ---------- */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .sheet { padding: 10px 10px 14px; margin: 0 -8px; border-left: 0; border-right: 0; }
  .seg { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .seg .sg span { width: 100%; justify-content: center; padding: 6px 6px; font-size: 0.88rem; white-space: normal; text-align: center; line-height: 1.2; }
  .setrow { display: grid; grid-template-columns: 1fr auto; }
  .setrow .btn { grid-column: 1 / -1; }
  .task-f select { min-width: 0; width: 100%; }
  .score { margin-left: 0; flex-basis: 100%; }
  .dt { font-size: 0.88rem; }
  .dt th, .dt td { padding: 4px 6px; }
  .dt.given { width: 100%; }
  .dt .sno { width: 2.6em; padding-right: 2px; }
  .dt.inex th.txt { min-width: 0; }
  /* the goods table has five columns: tighter cells so it fits 320 px without scrolling inside its box */
  .dt.goods { width: 100%; font-size: 0.78rem; }
  .dt.goods th, .dt.goods td { padding: 4px 2px; }
  .dt.goods thead th { font-size: 0.72rem; }
  .dt.goods .per { display: block; }
  .agrp { padding-left: 8px; }
  .arow label, .arow .alab { flex-basis: 100%; }
  .aval { margin-left: auto; }
  .cell { width: 8.6em; }
}

/* ---------- print ---------- */
.print-root { display: none; }
@page { margin: 13mm 12mm; }
@media print {
  body { background: #fff; color: #000; font: 10.5pt/1.4 var(--sans); }
  main, footer, .skip, .toast { display: none !important; }
  .print-root { display: block; }
  :root { --paper: #fff; --ink: #000; --muted: #333; --line: #999; --rule: #000; --band: #fff; --band-ink: #000; --wash: #fff; --stripe: #fff; }
  .pt { width: 100%; border-collapse: collapse; }
  .pt > thead td.prun { font-size: 8pt; color: #444; padding-bottom: 4px; text-align: right; }
  .psheet, .pkey { break-after: page; }
  .pkey:last-child { break-after: auto; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #000; margin-bottom: 4px; }
  .ph h2 { font-family: var(--head); font-size: 15pt; margin: 0; }
  .ph p { margin: 0; font-size: 9.5pt; }
  .pmeta { display: flex; justify-content: space-between; margin: 6px 0; font-size: 10pt; }
  .plabel { font-size: 9pt; margin: 0 0 6px; }
  .pq, .pk { list-style: none; padding: 0; margin: 0; }
  /* a problem never splits across pages, on the worksheet or in the key (a continued key page would open on working
     lines with no heading) */
  .pq > li, .pk > li { padding: 4px 0 8px; border-bottom: 0.6pt solid #999; break-inside: avoid; }
  /* both methods: (a) and (b) side by side on paper, so problem 2 can share page 1 */
  .pq-two .answers, .pk-two .answers { display: grid; grid-template-columns: 1fr 1fr; gap: 0 6mm; }
  .pq-two .agrp:nth-child(3), .pk-two .agrp:nth-child(3) { grid-column: 1 / -1; }
  .pq-two .arow, .pk-two .arow { grid-template-columns: minmax(0, 1fr) auto; }
  .pq-two .wline { width: 24mm; }
  .pq > li:last-child, .pk > li:last-child { border-bottom: 0; }
  .pq h3, .pk h3 { font-family: var(--head); font-size: 11.5pt; margin: 2px 0 2px; }
  .pscen { margin: 0 0 4px; }
  .twrap { overflow: visible; }
  .dt { font-size: 9.5pt; border-top: 1.2pt solid #000; border-bottom: 1.2pt solid #000; }
  .dt.given { min-width: 0; width: 120mm; }
  .gsplit { display: grid; grid-template-columns: 1fr 1fr; gap: 0 5mm; align-items: start; }
  .gsplit .dt.given { width: 100%; }
  .dt.inex { width: 100%; }
  .dt th, .dt td { padding: 1pt 4pt; border-bottom: 0.5pt solid #999; color: #000; }
  .dt thead th { background: #fff; color: #000; border-bottom: 1pt solid #000; font-size: 9pt; }
  .dt.goods th.yr { border-left: 0.5pt solid #999; }
  .dt tbody tr { break-inside: avoid; }
  .dt.inex .why { font-size: 8.5pt; color: #000; }
  .pchoice { font-size: 9pt; white-space: nowrap; }
  .rline { display: block; margin-top: 6pt; padding-top: 8pt; border-bottom: 0.6pt dotted #000; font-size: 8.5pt; color: #333; }
  .dt.inex thead th.ch { white-space: nowrap; }
  .qnote { font-size: 9pt; color: #000; }
  .answers { display: block; margin-top: 6px; }
  .agrp { border-left: 0; padding-left: 0; margin-bottom: 4px; break-inside: avoid; }
  .gname { font-size: 10pt; margin: 4px 0 0; }
  /* a fixed label column, so a long label (GVAmp) wraps inside it and every ₹ value lines up */
  .arow { display: grid; grid-template-columns: 92mm auto; align-items: baseline; gap: 0 4mm; max-width: none; border-bottom: 0; padding: 3pt 0; }
  .arow .alab { min-width: 0; }
  .aval { margin-left: 0; }
  .cu, .un { color: #000; }
  .steps { font-size: 9.5pt; padding-left: 14px; margin-top: 4px; }
  .steps li { margin: 1.5pt 0; }
  .unused { font-size: 9pt; color: #000; margin: 4px 0 0; }
}
