/* FairBill — "ledger audit" theme. The product's core act is reading a
   bill line by line and marking what's worth questioning, so the design is
   a calm paper ledger — restrained, high-trust, health/finance-adjacent —
   with a single stamp-ink blue as the one interactive accent, and
   red/green reserved strictly as SEMANTIC flag-state colors (not
   decoration), the same separation CertBridge/LLMFirewall use for their
   own verdict colors. Light on purpose: this is a document a patient needs
   to trust, not a dashboard to feel clever about. */
:root {
  --bg: #f7f5ef;
  --surface: #fffefa;
  --surface-2: #efece0;
  --line: #ddd8c8;
  --line-soft: #e8e4d6;
  --ink: #211f1a;
  --muted: #6b6a5c;
  --muted-dim: #96937f;

  --accent: #33478f;        /* interactive / "auditor's stamp" ink-blue accent */
  --accent-rgb: 51, 71, 143;
  --flag: #b8392f;          /* semantic: line item worth questioning */
  --flag-rgb: 184, 57, 47;
  --ok: #2f7a52;            /* semantic: no structural flags found on this line */
  --ok-rgb: 47, 122, 82;

  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --wrap: 1120px;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; line-height: 1.14; letter-spacing: -0.015em; }
a { color: inherit; }
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 22px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Animated background canvas — the ledger sweep, subtle, sits behind everything. */
#bg-fx {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: -1; pointer-events: none; opacity: 0.5;
}

.pulse {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

/* ---- Header ---- */
header.site { position: sticky; top: 0; z-index: 20;
  background: rgba(247, 245, 239, 0.78); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft); }
.nav { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.logo { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; text-decoration: none; color: var(--ink); }
.logo span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 550; }
.nav-links a:hover { color: var(--ink); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: 0.95rem;
  background: var(--accent); color: #fbf9f2; border: 1px solid var(--accent);
  padding: 12px 20px; border-radius: 10px; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -12px rgba(var(--accent-rgb), 0.55); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid rgba(var(--accent-rgb), 0.4); outline-offset: 2px; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--accent); box-shadow: none; }
.btn.btn-sm { padding: 8px 14px; font-size: 0.88rem; }
.btn.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }

/* ---- Hero ---- */
.hero { padding: 60px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 44px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center;
  font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--muted);
}
.hero h1 { font-size: 2.75rem; font-weight: 800; margin-top: 16px; text-wrap: balance; color: var(--ink); }
.hero .sub { color: var(--muted); font-size: 1.06rem; margin: 18px 0 0; max-width: 36em; }
.hero-copy .sub { line-height: 1.55; }

.detector-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 24px 0 0; }
.detector-chips li {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.cta-row .link-btn { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 0.92rem; align-self: center; }
.cta-row .link-btn:hover { color: var(--accent); }

.privacy-nudge {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 18px;
  font-size: 0.84rem; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; max-width: 40em;
}

/* ---- Live console (the working demo, front and center) ---- */
.console {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 30px 70px -35px rgba(33, 31, 26, 0.28), 0 0 0 1px rgba(var(--accent-rgb), 0.03);
  overflow: hidden;
}
.console-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  background: rgba(33, 31, 26, 0.02);
}
.console-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.console-title { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted-dim); margin-left: 6px; }
.console-live {
  margin-left: auto; font-size: 0.74rem; color: var(--muted);
  display: inline-flex; align-items: center; font-family: var(--font-mono);
}
.console-body { padding: 20px; }
.console-body label { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
#bill-input {
  width: 100%; min-height: 150px; resize: vertical; font: inherit; font-family: var(--font-mono); font-size: 0.86rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; line-height: 1.55;
}
#bill-input::placeholder { color: var(--muted-dim); }
#bill-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16); }
.samples { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip-btn {
  font: inherit; font-size: 0.82rem; font-weight: 550; cursor: pointer;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
  transition: color .12s, border-color .12s;
}
.chip-btn:hover { color: var(--ink); border-color: var(--accent); }
.chip-btn:focus-visible { outline: 2px solid rgba(var(--accent-rgb), 0.45); outline-offset: 2px; }

/* Result panel written by landing.js */
.result { display: none; margin-top: 16px; }
.result.show { display: block; animation: result-in .28s cubic-bezier(.2,.8,.3,1) both; }
@keyframes result-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.disclaimer-banner {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 0.85rem; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
}
.sanitized-note {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 0.82rem; color: var(--accent);
  background: rgba(var(--accent-rgb), 0.07); border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 8px; padding: 9px 12px; margin-bottom: 14px;
}
.arithmetic-banner {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 0.85rem; color: var(--flag);
  background: rgba(var(--flag-rgb), 0.08); border: 1px solid rgba(var(--flag-rgb), 0.3);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
}

.item-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.item-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: start;
  background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 8px; padding: 10px 12px;
}
.item-row.is-flagged { border-left-color: var(--flag); }
.item-row.is-clear { border-left-color: var(--ok); }
.item-main .item-name { font-weight: 650; font-size: 0.94rem; }
.item-main .item-meta { color: var(--muted-dim); font-size: 0.78rem; margin-top: 2px; font-family: var(--font-mono); }
.item-main .item-note { color: var(--muted); font-size: 0.84rem; margin-top: 4px; }
.item-charge { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 650; font-size: 0.94rem; white-space: nowrap; }
.flag-chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.flag-chip {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--flag); background: rgba(var(--flag-rgb), 0.1); border: 1px solid rgba(var(--flag-rgb), 0.32);
}
.clear-badge {
  grid-column: 1 / -1; font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ok); width: fit-content;
}

.letter-box { background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 14px; }
.letter-box h4 { font-size: 0.95rem; margin: 0 0 10px; }
.letter-box pre {
  white-space: pre-wrap; font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  max-height: 280px; overflow-y: auto; margin: 0;
}
.summary-box { color: var(--ink); font-size: 0.92rem; margin: 0 0 16px; line-height: 1.6; }
.result .sub { color: var(--muted); font-size: 0.9rem; margin: 8px 0 0; }
.badge.error { display: inline-flex; font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; color: var(--flag); background: rgba(var(--flag-rgb), 0.1); border: 1px solid rgba(var(--flag-rgb), 0.32); padding: 6px 12px; border-radius: 8px; margin-bottom: 10px; }

/* ---- Stat band ---- */
.stats-band { padding: 20px 0 8px; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px;
}
.tile-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 2rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1;
}
.tile-value.flagged { color: var(--flag); }
.tile-value.accent { color: var(--accent); }
.tile-value.safe { color: var(--ok); }
.tile-label { font-size: 0.86rem; font-weight: 600; margin-top: 10px; }
.tile-note { font-size: 0.76rem; color: var(--muted-dim); margin-top: 3px; }

/* ---- Sections ---- */
section.how, section.feed, section.market, section.signup { padding: 64px 0; }
.how h2, .feed h2, .market h2, .signup h2 { font-size: 1.85rem; font-weight: 780; margin-top: 14px; text-wrap: balance; }
.how .sub, .feed .sub, .market .sub, .signup .sub { color: var(--muted); margin: 12px 0 0; max-width: 46em; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 32px; }
.step-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px;
  position: relative; overflow: hidden;
}
.step-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.step-card .num { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); font-weight: 700; }
.step-card h3 { font-size: 1.1rem; font-weight: 700; margin: 12px 0 8px; }
.step-card p { color: var(--muted); font-size: 0.95rem; margin: 0; }
.how-note { margin-top: 20px; color: var(--muted-dim); font-size: 0.88rem; border-left: 2px solid var(--line); padding-left: 12px; }

/* ---- Live feed table ---- */
.feed-table-wrap { margin-top: 28px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; overflow-x: auto; }
table.dashboard { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.dashboard th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted-dim); font-weight: 700; padding: 12px 18px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
table.dashboard td { padding: 12px 18px; border-bottom: 1px solid var(--line-soft); font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--muted); }
table.dashboard tr:last-child td { border-bottom: none; }
table.dashboard tbody tr { transition: background .12s; }
table.dashboard tbody tr:hover { background: var(--surface-2); }
table.dashboard td.has-flags { color: var(--flag); font-weight: 700; }
table.dashboard td.no-flags { color: var(--ok); font-weight: 700; }
.dashboard-empty { color: var(--muted); margin-top: 18px; font-size: 0.95rem; }

/* ---- Market context ---- */
.market-card {
  margin-top: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 32px; display: flex; gap: 26px; align-items: center; flex-wrap: wrap;
}
.market-stat { font-family: var(--font-mono); font-size: 3rem; font-weight: 800; color: var(--accent); line-height: 1; }
.market-copy { flex: 1; min-width: 240px; }
.market-copy p { margin: 0; color: var(--ink); font-size: 0.98rem; }
.market-copy cite { display: block; margin-top: 8px; color: var(--muted-dim); font-size: 0.8rem; font-style: normal; }
.market-copy cite a { color: var(--muted); }
.market-copy cite a:hover { color: var(--accent); }

/* ---- Signup section ---- */
.signup .btn { margin-top: 24px; }
.signup-ctas { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

/* ---- Footer ---- */
footer.site { border-top: 1px solid var(--line-soft); padding: 28px 0 44px; margin-top: 24px; }
.footer-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 0.88rem; }
.footer-row a { color: var(--muted); text-decoration: none; }
.footer-row a:hover { color: var(--accent); }
.footer-row nav { display: flex; gap: 18px; }

/* ---- Signup modal ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgba(33, 31, 26, 0.5); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; animation: fade-in .18s ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; box-shadow: 0 40px 90px -34px rgba(33, 31, 26, 0.45);
}
.modal h3 { font-size: 1.35rem; font-weight: 780; }
.modal .sub { color: var(--muted); font-size: 0.95rem; margin: 10px 0 20px; }
.modal .close {
  position: absolute; top: 14px; right: 16px; background: none; border: none;
  color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.modal .close:hover { color: var(--ink); }
.modal label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; margin-top: 14px; }
.modal label:first-of-type { margin-top: 0; }
.modal input[type=email], .modal select {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 10px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
}
.modal input:focus-visible, .modal select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.16); }
.consent-row { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; }
.consent-row input { margin-top: 4px; flex-shrink: 0; }
.consent-row label { font-size: 0.82rem; font-weight: 400; color: var(--muted); margin: 0; }
.consent-row a { color: var(--accent); }
.status-msg { font-size: 0.9rem; margin: 12px 0 0; }
.status-msg.success { color: var(--ok); }
.status-msg.error { color: var(--flag); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero h1 { font-size: 2.15rem; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: 1fr; }
  .nav-links a { display: none; }
  .item-row { grid-template-columns: 1fr; }
  .item-charge { justify-self: start; }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  .hero h1 { font-size: 1.85rem; }
  .stat-tiles { grid-template-columns: 1fr 1fr; }
  .market-card { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
  #bg-fx { display: none; }
}
