/* ============================================================
   TheRealOTD — main.css
   Light, editorial consumer-finance look: warm paper, deep
   green ink, amber flags for negotiable lines. Fraunces display
   + Archivo UI. One stylesheet, CSS custom properties, no build.
   ============================================================ */

@font-face {
  font-family: 'Fraunces';
  src: url('/assets/fonts/fraunces-var.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Archivo';
  src: url('/assets/fonts/archivo-var.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* palette */
  --paper: #f7f5ef;
  --paper-raised: #fffdf8;
  --ink: #1c2b22;
  --ink-soft: #4c5a50;
  --ink-faint: #8a917f;
  --line: #e3dfd2;
  --line-strong: #cfc9b8;
  --green: #135c40;
  --green-deep: #0d3f2c;
  --green-tint: #e5efe7;
  --amber: #9a6412;
  --amber-tint: #f7ecd9;
  --blue: #2d5b7a;
  --blue-tint: #e3edf3;
  --red: #a13030;
  --red-tint: #f6e3e3;
  --gold: #8c6d1f;
  --gold-tint: #f5eccb;

  /* type */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-ui: 'Archivo', -apple-system, 'Segoe UI', sans-serif;

  /* rhythm */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(28, 43, 34, .06), 0 8px 24px -12px rgba(28, 43, 34, .18);
  --shadow-soft: 0 1px 3px rgba(28, 43, 34, .08);
  --maxw: 1080px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; color: var(--ink); margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--green-deep); }
small, .muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
strong { font-weight: 600; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* ---------- header / nav ---------- */
.site-topline { height: 4px; background: linear-gradient(90deg, var(--green-deep), var(--green) 40%, var(--gold) 100%); }
.site-header { background: var(--paper-raised); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 28px; min-height: 62px; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; color: var(--green-deep); text-decoration: none; letter-spacing: -.01em; }
.brand .tld { color: var(--gold); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { text-decoration: none; color: var(--ink-soft); padding: 8px 12px; border-radius: var(--radius-sm); font-size: .95rem; font-weight: 500; }
.nav a:hover { background: var(--green-tint); color: var(--green-deep); }
.nav a.nav-cta { background: var(--green); color: #fff; }
.nav a.nav-cta:hover { background: var(--green-deep); }
.nav a.active { color: var(--green-deep); background: var(--green-tint); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 72px; background: var(--paper-raised); }
.site-footer .wrap { padding: 32px 20px 40px; display: flex; flex-wrap: wrap; gap: 32px; justify-content: space-between; font-size: .9rem; }
.site-footer a { color: var(--ink-soft); text-decoration: none; display: block; padding: 2px 0; }
.site-footer a:hover { color: var(--green-deep); }
.footer-col h4 { margin: 0 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.footer-legal { width: 100%; border-top: 1px solid var(--line); padding-top: 16px; color: var(--ink-faint); font-size: .8rem; }

/* ---------- hero ---------- */
.hero { padding: 56px 0 32px; }
.hero .kicker { font-size: .85rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-bottom: 12px; }
.hero p.lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 640px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 40px; align-items: start; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }

/* ---------- cards & sections ---------- */
.card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 24px; }
.card-pad-lg { padding: 32px; }
.section { margin: 56px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-block; font: 600 1rem var(--font-ui); padding: 11px 22px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none; text-align: center; transition: background .15s; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-deep); color: #fff; }
.btn-secondary { background: transparent; color: var(--green-deep); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--green-tint); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-lg { padding: 14px 28px; font-size: 1.1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: span 1; } }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: var(--ink); }
.field .hint { font-size: .78rem; color: var(--ink-faint); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=month], select, textarea {
  width: 100%; padding: 10px 12px; font: 400 1rem var(--font-ui); color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }
.input-prefix > input { padding-left: 26px; }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.checkline input { margin-top: 3px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: .85rem; font-weight: 600; padding: 0 6px; color: var(--ink-soft); }
.honeypot { position: absolute; left: -9999px; height: 1px; overflow: hidden; }

/* segmented radio group */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { padding: 8px 16px; cursor: pointer; font-size: .92rem; font-weight: 500; color: var(--ink-soft); background: #fff; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; }
.seg input:checked + span { color: var(--green-deep); font-weight: 700; }
.seg label:has(input:checked) { background: var(--green-tint); color: var(--green-deep); }

/* ---------- flash messages ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin: 16px 0; font-size: .95rem; border: 1px solid; }
.flash-ok { background: var(--green-tint); border-color: #bcd6c4; color: var(--green-deep); }
.flash-warn { background: var(--amber-tint); border-color: #e4cfa4; color: var(--amber); }
.flash-error { background: var(--red-tint); border-color: #e0b6b6; color: var(--red); }

/* ---------- pills & tags ---------- */
.pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; padding: 3px 10px; border-radius: 100px; text-transform: uppercase; }
.pill-gold { background: var(--gold-tint); color: var(--gold); }
.pill-green { background: var(--green-tint); color: var(--green); }
.pill-gray { background: var(--line); color: var(--ink-soft); }
.pill-red { background: var(--red-tint); color: var(--red); }
.pill-blue { background: var(--blue-tint); color: var(--blue); }

.tag { display: inline-block; font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.tag-gov { background: var(--blue-tint); color: var(--blue); }
.tag-capped { background: var(--green-tint); color: var(--green); }
.tag-negotiable { background: var(--amber-tint); color: var(--amber); }

/* ---------- OTD receipt (calculator output) ---------- */
.receipt { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.receipt-head { padding: 18px 24px; background: var(--green-deep); color: #f2efe6; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.receipt-head h3 { margin: 0; color: #fff; font-size: 1.1rem; }
.receipt-head .jur { font-size: .85rem; opacity: .85; }
.receipt-body { padding: 8px 24px 20px; }
.rline { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .97rem; }
.rline:last-child { border-bottom: 0; }
.rline .lbl { flex: 1; min-width: 0; }
.rline .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.rline.negative .amt { color: var(--green); }
.rline.rline-sub { padding-left: 14px; font-size: .92rem; color: var(--ink-soft); }
.rline.rline-taxable { background: var(--paper); margin: 0 -24px; padding-left: 24px; padding-right: 24px; font-weight: 600; }
.rline .tip { cursor: help; border-bottom: 1px dotted var(--ink-faint); }
.receipt-total { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 24px; background: var(--green-tint); border-top: 2px solid var(--green); }
.receipt-total .lbl { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.receipt-total .amt { font-family: var(--font-display); font-weight: 700; font-size: 1.7rem; font-variant-numeric: tabular-nums; color: var(--green-deep); }
.receipt-cash { padding: 14px 24px; border-top: 1px solid var(--line); background: var(--paper); font-size: .95rem; }
.receipt-cash .rline { border-bottom: 0; padding: 4px 0; }
.receipt-actions { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 24px; border-top: 1px solid var(--line); }
.estimate-note { font-size: .8rem; color: var(--ink-faint); }

/* big number stat */
.stat { text-align: left; }
.stat .num { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--green-deep); font-variant-numeric: tabular-nums; }
.stat .cap { font-size: .8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); }
table.data th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); padding: 10px 14px; border-bottom: 2px solid var(--line-strong); background: var(--paper); }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: #fbfaf4; }

/* ---------- deal cards ---------- */
.deal-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.deal-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); display: block; transition: box-shadow .15s, transform .15s; }
.deal-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.deal-card .veh { font-weight: 700; font-size: 1rem; }
.deal-card .price { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--green-deep); margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.deal-card .meta { font-size: .82rem; color: var(--ink-faint); }

/* ---------- wizard ---------- */
.steps { display: flex; gap: 0; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 100px; overflow: hidden; background: var(--paper-raised); }
.steps .step { flex: 1; text-align: center; font-size: .82rem; font-weight: 600; padding: 9px 6px; color: var(--ink-faint); border-right: 1px solid var(--line); }
.steps .step:last-child { border-right: 0; }
.steps .step.on { background: var(--green); color: #fff; }
.steps .step.done { background: var(--green-tint); color: var(--green-deep); }
.wizard-step { display: none; }
.wizard-step.on { display: block; }
.rowline { display: grid; grid-template-columns: 1fr 140px 40px; gap: 10px; margin-bottom: 8px; }

/* ---------- notes / callouts ---------- */
.callout { border-left: 4px solid var(--green); background: var(--paper-raised); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 14px 18px; margin: 14px 0; font-size: .95rem; }
.callout-amber { border-left-color: var(--amber); }
.callout-blue { border-left-color: var(--blue); }
.callout h4 { margin: 0 0 4px; font-size: .95rem; }
ul.rule-notes { padding-left: 20px; }
ul.rule-notes li { margin-bottom: 8px; }

/* ---------- admin ---------- */
.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 28px; align-items: start; margin-top: 24px; }
@media (max-width: 800px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-nav { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 16px; }
.admin-nav a { display: block; padding: 8px 12px; text-decoration: none; color: var(--ink-soft); border-radius: var(--radius-sm); font-size: .92rem; }
.admin-nav a:hover { background: var(--green-tint); color: var(--green-deep); }
.admin-nav a.active { background: var(--green); color: #fff; }
.banner-error { background: var(--red-tint); border: 1px solid #e0b6b6; color: var(--red); padding: 12px 16px; border-radius: var(--radius-sm); margin: 16px 0; font-weight: 600; }
textarea.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .82rem; line-height: 1.5; min-height: 420px; }

/* ---------- tooltips (CSS-only, title fallback) ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 30;
  width: min(320px, 80vw); padding: 10px 12px;
  background: var(--ink); color: var(--paper); font-size: .8rem; line-height: 1.45;
  border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 400; white-space: normal;
}

/* ---------- utility ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
@media (max-width: 800px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 24px; } .mt4 { margin-top: 40px; }
.mb2 { margin-bottom: 16px; } .mb3 { margin-bottom: 24px; }
.tr { text-align: right; } .tc { text-align: center; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.hide { display: none !important; }

/* ---------- print worksheet ---------- */
@media print {
  .site-header, .site-footer, .site-topline, .receipt-actions, .nav, .no-print, .flash { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .receipt { box-shadow: none; border: 1px solid #999; }
  .receipt-head { background: #fff !important; color: #000; border-bottom: 2px solid #000; }
  .receipt-head h3 { color: #000; }
  .receipt-total { background: #fff; border-top: 2px solid #000; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
