/* Practice Books. Same visual language as ExpressPay (Franklin Park Express Care):
   quiet, precise, 8px grid. Green is an accent, not a surface. */
:root {
  --canvas: #f8f7f2;
  --rail: #f1f2ea;
  --surface: #ffffff;
  --ink: #17201b;
  --ink-2: #69716c;
  --ink-3: #9aa09b;
  --hair: #dadcd8;
  --hair-strong: #b9bdb7;
  --green: #375714;
  --green-hover: #27400d;
  --green-soft: #ebf0e1;
  /* No red anywhere (owner's rule). 'red' tokens are a stronger amber for serious warnings. */
  --red: #6b4300;
  --red-soft: #f2e2bf;
  --amber: #7a5410;
  --amber-soft: #f7f0e1;
  --blue: #2f4a6d;
  --blue-soft: #e7edf4;
  --r: 8px;
  --t: 140ms ease;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink);
  background: var(--canvas); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
h1 { font-size: 28px; line-height: 1.2; font-weight: 650; letter-spacing: -0.015em; margin: 0 0 4px; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 600; margin: 40px 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
p { margin: 0 0 8px; }
a { color: var(--green); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 16px; border-radius: var(--r); z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--rail); border-right: 1px solid var(--hair); padding: 24px 12px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; font-size: 14px; font-weight: 650; line-height: 1.25; color: var(--green); text-decoration: none; }
.brand small { display: block; font-weight: 400; color: var(--ink-2); }
.brand svg { flex: none; }
.nav { display: flex; flex-direction: column; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.nav-group + .nav-group { border-top: 1px solid var(--hair); margin-top: 8px; padding-top: 16px; }
.nav-label { font-size: 12px; color: var(--ink-2); padding: 0 12px 4px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; transition: background var(--t);
}
.nav a:hover { background: #e6e9dc; }
.nav a[aria-current="page"] { background: var(--green-soft); color: var(--green); box-shadow: inset 2px 0 0 var(--green); }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--green); color: #fff; font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
.nav-badge.warn { background: var(--amber); }
.rail-foot { margin-top: auto; padding: 16px 12px 0; font-size: 13px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.rail-foot button { align-self: flex-start; }
.topbar { display: none; }

.main { padding: 48px 56px 96px; min-width: 0; outline: none; }
.work { max-width: 880px; }
.work-wide { max-width: 1120px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .lede { color: var(--ink-2); margin: 0; }

/* ---------- Type helpers ---------- */
.eyebrow { font-size: 13px; font-weight: 600; color: var(--green); margin: 0 0 6px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.hint, .muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.num { text-align: right; white-space: nowrap; }
.neg { color: var(--red); }

/* ---------- Controls ---------- */
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); width: 100%; height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r);
  transition: border-color var(--t), box-shadow var(--t);
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--hair-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.field { display: flex; flex-direction: column; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.btn {
  font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--hair); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background var(--t), border-color var(--t);
}
.btn:hover { border-color: var(--hair-strong); background: #fbfbf8; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-hover); border-color: var(--green-hover); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--green); padding: 0 8px; }
.btn-quiet:hover { background: var(--green-soft); border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.seg { display: inline-flex; border: 1px solid var(--hair); border-radius: var(--r); background: var(--surface); padding: 2px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent; color: var(--ink-2); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--green-soft); color: var(--green); font-weight: 600; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); padding: 20px; }
.card + .card { margin-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.card-foot { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--hair); }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 12px; }

.stat { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); padding: 16px 20px; text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--hair-strong); }
.stat-label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; margin-top: 4px; }
.stat-note { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

.list { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); }
.item { display: flex; gap: 16px; align-items: center; padding: 14px 20px; }
.item + .item { border-top: 1px solid var(--hair); }
.item-main { flex: 1 1 auto; min-width: 0; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.item-side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 50%; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 10px 16px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--hair); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--canvas); color: var(--ink-2); border: 1px solid var(--hair); }
.b-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.b-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.b-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.b-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ink-3); flex: none; }
.dot.ok { background: var(--green); } .dot.err { background: #b77a12; } .dot.run { background: var(--amber); }

.callout { border-radius: var(--r); padding: 12px 16px; font-size: 14px; background: var(--amber-soft); color: var(--amber); }
.callout.err { background: var(--red-soft); color: var(--red); border-left: 3px solid #b77a12; }
.callout.err::before, .warn-strong::before { content: '⚠ '; }
.callout.ok { background: var(--green-soft); color: var(--green); }
.callout.info { background: var(--blue-soft); color: var(--blue); }
.empty { color: var(--ink-2); text-align: center; padding: 32px 16px; }
.meter { height: 6px; background: var(--hair); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--green); }
.skeleton { background: linear-gradient(90deg, #eeeee8, #f6f6f1, #eeeee8); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; color: transparent !important; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Dialog + toast ---------- */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(23, 32, 27, .25); color: var(--ink); }
dialog::backdrop { background: rgba(23, 32, 27, .35); }
dialog form { padding: 24px; }
dialog h2 { margin: 0 0 4px; }
dialog .fields { grid-template-columns: 1fr; margin: 16px 0 24px; }
dialog .btns { justify-content: flex-end; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r); font-size: 14px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
.toast.err { background: #6b4300; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--rail); border-bottom: 1px solid var(--hair); position: sticky; top: 0; z-index: 20; }
  .topbar .brand { padding: 0; }
  .rail { position: fixed; inset: 0 30% 0 0; max-width: 300px; z-index: 30; transform: translateX(-100%); transition: transform 180ms ease; height: 100%; box-shadow: none; }
  body.nav-open .rail { transform: none; box-shadow: 0 0 0 100vmax rgba(23, 32, 27, .35); }
  .main { padding: 24px 16px 80px; }
  h1 { font-size: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
  .item { padding: 14px 16px; }
  .list > .item { flex-wrap: wrap; }
  .item-side { max-width: none; justify-content: flex-start; }
  .card { padding: 16px; }
  th, td { padding: 8px 12px; }
}

/* ---------- Decision-first components ---------- */
.hero { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: 28px; }
.hero-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--ink-2); text-transform: uppercase; }
.hero-value { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin: 8px 0 4px; color: var(--green); }
.hero-value.short { color: var(--amber); }
.hero-sub { color: var(--ink-2); }
.calc { margin-top: 20px; border-top: 1px solid var(--hair); padding-top: 12px; }
.calc-row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 15px; }
.calc-row .op { color: var(--ink-2); width: 18px; display: inline-block; }
.calc-row.total { border-top: 1px solid var(--hair-strong); margin-top: 4px; padding-top: 10px; font-weight: 700; }
.calc-row.sub { color: var(--ink-2); font-size: 13px; padding: 2px 0 2px 18px; }
.calc-row .v { font-variant-numeric: tabular-nums; white-space: nowrap; }
details.why { margin-top: 12px; }
details.why summary { cursor: pointer; color: var(--green); font-weight: 600; font-size: 14px; }
details.why ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }

.att-head { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 8px; }
.att { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--hair); border-radius: var(--r); background: var(--surface); }
.att + .att { margin-top: 8px; }
.att .mark { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--ink-3); }
.att.attention .mark { background: #d39b22; }
.att.attention.strong { border-color: #d9b46a; background: #fffaf0; }
.att.good .mark { background: var(--green); }
.att-body { flex: 1; min-width: 0; }
.att-title { font-weight: 600; }
.att-detail { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

.fc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fc-col { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); padding: 16px; }
.fc-col h4 { margin: 0 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.fc-col .calc-row { font-size: 13px; padding: 3px 0; }
.verdict { border-radius: var(--r); padding: 16px 20px; margin-bottom: 12px; }
.verdict.good { background: var(--green-soft); color: var(--green); }
.verdict.attention { background: var(--amber-soft); color: var(--amber); }
.verdict b { display: block; letter-spacing: .06em; font-size: 13px; margin-bottom: 4px; }

.flow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; border: 1px solid var(--hair); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.flow > div { padding: 14px 16px; border-right: 1px solid var(--hair); }
.flow > div:last-child { border-right: 0; background: var(--green-soft); }
.flow .k { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.flow .n { font-size: 20px; font-weight: 700; margin-top: 2px; }
.alloc { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.est-tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--canvas); color: var(--ink-2); border: 1px solid var(--hair); }
.rec-tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--green-soft); color: var(--green); }
.choice { display: flex; flex-wrap: wrap; gap: 8px; }
.choice label { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--hair); border-radius: 999px; padding: 8px 14px; cursor: pointer; background: var(--surface); font-size: 14px; }
.choice input { width: auto; height: auto; margin: 0; }
.choice label:has(input:checked) { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 600; }
@media (max-width: 900px) { .flow { grid-template-columns: repeat(3, minmax(0, 1fr)); } .flow > div:nth-child(3) { border-right: 0; } .alloc { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .fc { grid-template-columns: 1fr; } .hero-value { font-size: 40px; } .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
