/* ACS brand palette (memory/context/brand-and-formatting.md) */
:root {
  --navy-900: #0b1f35; --navy-800: #12304f; --navy-700: #1a4270; --navy-600: #23558c;
  --gold: #b8892b; --gold-light: #d9a94a; --gold-text: #906000; --warm: #fff7e8;
  --slate-700: #3d4a58; --slate-500: #61707f; --slate-300: #c3ccd5; --slate-100: #eef1f4; --slate-50: #f7f9fb;
  --bg: var(--slate-50); --surface: #fff; --text: var(--slate-700); --muted: var(--slate-500);
  --heading: var(--navy-900); --line: var(--slate-300); --fill: var(--slate-100); --accent: var(--navy-700); --accent-soft: #e8eef6;
  --green: #2e7d4f; --yellow: #c58b00; --red: #b4473a;
  --radius: 4px; --shadow: 0 1px 2px rgba(11, 31, 53, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #08172a; --surface: #0f2340; --text: #d5dde6; --muted: #9aa8b7; --heading: #f2f5f8; --line: #284468; --fill: #15304f;
    --accent: #6fa3dc; --accent-soft: #15304f; --warm: #2a2312; --gold-text: #d9a94a; --green: #5fbf86; --yellow: #e0b04a; --red: #e07b6e;
  }
}
:root[data-theme="dark"] {
  --bg: #08172a; --surface: #0f2340; --text: #d5dde6; --muted: #9aa8b7; --heading: #f2f5f8; --line: #284468; --fill: #15304f;
  --accent: #6fa3dc; --accent-soft: #15304f; --warm: #2a2312; --gold-text: #d9a94a; --green: #5fbf86; --yellow: #e0b04a; --red: #e07b6e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 "Segoe UI", "Helvetica Neue", Arial, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { color: var(--heading); font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: clamp(1.5rem, 3.6vw, 2.1rem); }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small, .mini { font-size: .85rem; }
.mini { color: var(--muted); margin: 4px 0 0; display: block; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--gold-text); margin-bottom: 8px; }
.lead { font-size: 1.08rem; max-width: 48em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 1rem; line-height: 1.2; text-decoration: none; cursor: pointer; padding: 11px 18px; min-height: 44px; border-radius: var(--radius); border: 1px solid transparent; }
.btn-lg { padding: 14px 24px; min-height: 52px; font-size: 1.05rem; }
.btn-sm { padding: 7px 12px; min-height: 36px; font-size: .9rem; }
.btn-primary { background: var(--navy-700); color: #fff; }
.btn-primary:hover { background: var(--navy-800); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--accent); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn:focus-visible, button:focus-visible, .link-btn:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }
.btn:disabled { opacity: .7; cursor: wait; }
.link-btn { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; font-size: .88rem; }
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); width: 36px; height: 36px; border-radius: var(--radius); cursor: pointer; font-size: 1rem; }
.icon-btn:hover { border-color: var(--line); color: var(--red); }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0; }

/* Header + tabs */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--navy-900); border-bottom: 3px solid var(--gold); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand img { border-radius: var(--radius); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b { font-size: 1rem; }
.brand-text small { font-size: .74rem; color: var(--slate-300); }
.demo-tag { font-style: normal; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--gold); color: #fff; padding: 2px 6px; border-radius: 3px; vertical-align: 2px; margin-left: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.btn-install { background: var(--gold); color: #fff; min-height: 38px; padding: 8px 14px; font-size: .9rem; }
.seg { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.1); border-radius: var(--radius); padding: 3px; }
.seg button { font: inherit; font-size: .85rem; font-weight: 700; border: 0; background: transparent; color: rgba(255,255,255,.75); padding: 6px 11px; border-radius: 3px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--gold); color: #fff; }
.form-tools .seg { background: var(--fill); }
.form-tools .seg button { color: var(--text); }
.form-tools .seg button[aria-pressed="true"] { background: var(--navy-700); color: #fff; }
.seg-label { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 8px 0 6px; }
.tabs { position: sticky; top: 0; z-index: 10; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { font: inherit; font-size: .92rem; font-weight: 600; white-space: nowrap; cursor: pointer; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 12px 12px 10px; }
.tabs button[aria-selected="true"] { color: var(--heading); border-bottom-color: var(--gold); }
.tabs .tab-full { color: var(--gold-text); }

main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 24px 20px 40px; }
.panel { animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }

/* Start */
.hero { background: var(--navy-900); color: #dbe3ec; border-radius: var(--radius); border-left: 6px solid var(--gold); padding: clamp(26px, 5vw, 50px); margin-bottom: 26px; }
.hero h1 { color: #fff; font-size: clamp(1.8rem, 4.4vw, 2.6rem); max-width: 19em; }
.hero .eyebrow { color: var(--gold-light); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 26px; }
.facts { list-style: none; padding: 20px 0 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; border-top: 1px solid rgba(255,255,255,.15); }
.facts b { display: block; color: #fff; }
.facts span { color: #b9c6d4; font-size: .9rem; }
.show-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.show { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 14px; }
.show b { display: block; color: var(--heading); margin-bottom: 4px; }
.show p { font-size: .88rem; color: var(--muted); margin: 0; }

/* Form */
.form-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.tool-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-card { border-top: 4px solid var(--navy-700); }
.grid1 { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-bottom: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0; }
.period { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.period-chip { display: inline-block; margin: 12px 0 0; background: var(--accent-soft); color: var(--heading); font-weight: 700; padding: 6px 12px; border-radius: 16px; font-size: .92rem; }
.field { display: block; min-width: 0; }
.field.full { margin-top: 4px; }
.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--heading); margin-bottom: 5px; }
.field i, .check i { color: var(--red); font-style: normal; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; min-width: 0; max-width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; min-height: 42px;
}
input[type=date] { -webkit-appearance: none; appearance: none; }
input[readonly] { background: var(--fill); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.locked-field { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; border: 1px dashed var(--line); background: var(--fill); border-radius: var(--radius); padding: 9px 12px; font-size: .92rem; }
.locked-field span { font-weight: 600; color: var(--heading); }
.locked-field small { color: var(--muted); }
.prog { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 4px 0 16px; font-size: .88rem; color: var(--muted); }
.prog-track { flex: 1 1 200px; height: 8px; background: var(--fill); border-radius: 4px; overflow: hidden; }
.prog-fill { height: 100%; width: 0; background: var(--gold); transition: width .3s; }
.save-state { color: var(--green); }

.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
.sec summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; background: var(--navy-900); color: #fff; border-radius: var(--radius); }
.sec[open] summary { border-radius: var(--radius) var(--radius) 0 0; }
.sec summary::-webkit-details-marker { display: none; }
.sec-n { background: var(--gold); color: #fff; font-weight: 700; font-size: .82rem; border-radius: 3px; padding: 2px 8px; }
.sec-t { flex: 1; font-weight: 700; }
.chev { transition: transform .2s; color: var(--slate-300); }
.sec[open] .chev { transform: rotate(180deg); }
.sec-body { padding: 16px; }
.status-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.st { font: inherit; font-weight: 700; font-size: .92rem; padding: 12px 8px; border-radius: var(--radius); border: 2px solid; cursor: pointer; background: var(--surface); }
.st-green { border-color: var(--green); color: var(--green); } .st-green.on { background: var(--green); color: #fff; }
.st-yellow { border-color: var(--yellow); color: var(--yellow); } .st-yellow.on { background: var(--yellow); color: #fff; }
.st-red { border-color: var(--red); color: var(--red); } .st-red.on { background: var(--red); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: .92rem; font-weight: 600; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.chip.on { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.tbl-wrap { overflow-x: auto; }
.dyn { width: 100%; border-collapse: collapse; font-size: .92rem; }
.dyn th { text-align: left; background: var(--fill); color: var(--heading); font-weight: 600; padding: 8px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.dyn td { padding: 6px; vertical-align: top; border-bottom: 1px solid var(--line); }
.dyn td input, .dyn td select, .dyn td textarea { min-width: 110px; font-size: .95rem; }
.dyn td.rm { width: 44px; }
.btn-add { font: inherit; font-weight: 600; font-size: .92rem; width: 100%; margin-top: 8px; padding: 9px; border: 1.5px dashed var(--gold); background: var(--warm); color: var(--heading); border-radius: var(--radius); cursor: pointer; }
.lock-note { margin: 10px 0 0; font-size: .88rem; background: var(--fill); border: 1px dashed var(--line); padding: 8px 12px; border-radius: var(--radius); }
.prio { display: grid; gap: 8px; margin-bottom: 16px; }
.prio-row { display: flex; align-items: center; gap: 10px; }
.prio-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--navy-700); color: #fff; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; }
.sig { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sig-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--fill); font-weight: 600; font-size: .88rem; color: var(--heading); }
.sig canvas { display: block; width: 100%; height: 160px; background: #fff; touch-action: none; cursor: crosshair; }
.sig .mini { padding: 0 12px 8px; }
.errors { background: color-mix(in srgb, var(--red) 9%, var(--surface)); border: 1px solid var(--red); border-left-width: 5px; border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.errors ul { margin: 6px 0 0; padding-left: 20px; }
.submit-bar { margin: 18px 0; }
.submit-bar .btn { width: 100%; }

/* Results */
.res-banner { background: var(--navy-900); color: #dbe3ec; border-radius: var(--radius); border-left: 6px solid var(--gold); padding: 22px 24px; margin-bottom: 16px; }
.res-banner h1 { color: #fff; }
.res-banner p { margin: 0 0 6px; }
.res-id b { color: var(--gold-light); font-variant-numeric: tabular-nums; }
.res-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.res-tabs button { font: inherit; font-weight: 600; font-size: .92rem; white-space: nowrap; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 10px 12px; cursor: pointer; }
.res-tabs button[aria-selected="true"] { color: var(--heading); border-bottom-color: var(--gold); }
.r-doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.r-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; border-bottom: 3px solid var(--gold); padding-bottom: 12px; margin-bottom: 14px; }
.r-head h2 { margin: 0; font-size: 1.35rem; }
.r-co { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-text); }
.r-period { margin: 2px 0 0; font-weight: 600; }
.r-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.r-status { font-weight: 700; font-size: .85rem; padding: 4px 10px; border-radius: 14px; color: #fff; background: var(--slate-500); }
.r-status.st-green { background: var(--green); } .r-status.st-yellow { background: var(--yellow); } .r-status.st-red { background: var(--red); }
.r-id { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.r-sec { margin-bottom: 16px; break-inside: avoid; }
.r-sec h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--navy-700); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 8px; }
.r-sec dl { margin: 0; display: grid; grid-template-columns: minmax(150px, 34%) 1fr; gap: 4px 14px; }
.r-sec dl div { display: contents; }
.r-sec dt { color: var(--muted); font-size: .9rem; }
.r-sec dd { margin: 0; color: var(--heading); font-size: .95rem; white-space: pre-wrap; }
.r-tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.r-tbl th { text-align: left; background: var(--fill); padding: 6px 8px; color: var(--heading); }
.r-tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.r-sig { max-width: 320px; width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.r-foot { margin: 8px 0 0; font-size: .78rem; color: var(--muted); text-align: center; border-top: 1px dashed var(--line); padding-top: 8px; }
.mail { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.mail-head { background: var(--fill); padding: 14px 16px; font-size: .92rem; display: grid; gap: 4px; border-bottom: 1px solid var(--line); }
.mail-head .attach { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; }
.mail-head .attach span { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2px 10px; font-size: .82rem; }
.mail-body { padding: 14px; }
.mail-body .r-doc { box-shadow: none; }
.sheet { margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.sheet-tab { margin: 0; padding: 8px 12px; background: #e7f2ea; color: #1d5c34; font-weight: 700; font-size: .88rem; border-bottom: 1px solid var(--line); }
.sheet.locked { border-style: dashed; background: var(--fill); }
.sheet.locked .sheet-tab { background: var(--fill); color: var(--muted); }
.sheet.locked p.small { padding: 8px 12px; margin: 0; }
.tbl-scroll { overflow-x: auto; }
.x-tbl { border-collapse: collapse; font-size: .82rem; min-width: 100%; }
.x-tbl th { background: #f3f6f4; color: var(--heading); font-weight: 700; padding: 6px 8px; border: 1px solid #d6dfd8; white-space: nowrap; text-align: left; }
.x-tbl td { padding: 6px 8px; border: 1px solid #e1e7e2; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* Full version */
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.feature .ok { color: var(--green); font-weight: 700; }
.feature b { display: block; color: var(--heading); margin: 6px 0 4px; }
.feature p { font-size: .88rem; color: var(--muted); margin: 0; }
.feature.locked { border-style: dashed; background: var(--fill); }
.lead-card { border-top: 4px solid var(--gold); }
.lead-err { color: var(--red); font-weight: 600; margin: 12px 0 0; }
.lead-done { border-top-color: var(--green); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 0; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--navy-700); }
.bot-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.install-dialog { max-width: 460px; width: calc(100% - 32px); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: var(--radius); padding: 24px; background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(11,31,53,.25); }
.install-dialog::backdrop { background: rgba(11,31,53,.55); }
.install-step { background: var(--fill); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.install-step b:first-child { color: var(--heading); }
.install-step p { margin: 4px 0 0; font-size: .95rem; }
.install-dialog form { margin: 16px 0 0; text-align: right; }

.foot { text-align: center; font-size: .82rem; color: var(--muted); padding: 22px 20px 30px; border-top: 1px solid var(--line); }
.foot p { margin: 0 0 4px; }

@media (max-width: 760px) {
  .feature-grid, .show-grid { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: 1fr; }
  .period { grid-template-columns: 1fr 1fr; }
  .period > label:first-child { grid-column: 1 / -1; }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding: 18px 14px 32px; }
  .top { padding: 8px 14px; }
  .brand-text small { display: none; }
  .grid2, .feature-grid, .show-grid { grid-template-columns: 1fr; }
  .status-row { grid-template-columns: 1fr; }
  .hero-cta .btn, .row-btns .btn { width: 100%; }
  .r-sec dl { grid-template-columns: 1fr; gap: 0; }
  .r-sec dd { margin-bottom: 6px; }
  .r-doc { padding: 16px; }
  /* tables become stacked cards on phones */
  .dyn thead { display: none; }
  .dyn, .dyn tbody, .dyn tr, .dyn td { display: block; width: 100%; }
  .dyn tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 10px; position: relative; }
  .dyn td { border: 0; padding: 4px 0; }
  .dyn td[data-label]::before { content: attr(data-label); display: block; font-size: .8rem; font-weight: 600; color: var(--heading); margin-bottom: 3px; }
  .dyn td.rm { position: absolute; top: 4px; right: 4px; width: auto; padding: 0; }
  .dyn td input, .dyn td select, .dyn td textarea { min-width: 0; }
}

/* Print: the formatted report only */
@media print {
  body { background: #fff; display: block; font-size: 10.5pt; }
  .top, .tabs, .foot, .no-print, .res-banner, .install-dialog, #tab-start, #tab-full, #formView { display: none !important; }
  #tab-form, #resultView { display: block !important; }
  main { padding: 0; max-width: none; }
  .panel { animation: none; }
  .r-doc { border: 0; box-shadow: none; padding: 0; }
  .r-sec, tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
