:root {
  --red: #dc2626;
  --red-deep: #a91d1d;
  --red-tint: #fdecec;

  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-faint: #78716c;

  --charcoal: #18181b;

  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f4f2ef;
  --border: #e7e3dd;
  --border-strong: #d6d0c7;

  --amber-bg: #fef3e2;
  --amber-text: #b45309;
  --amber-border: #fbd9a5;

  --slate-bg: #eef0f2;
  --slate-text: #52606d;

  --violet-bg: #f1ecfb;
  --violet-text: #6d3fb0;

  --green-bg: #e7f6ec;
  --green-text: #1c7a3f;

  /* One family carries the whole product surface: Mona Sans, the same
     face as the Seqnc site. */
  --font-head: "Mona Sans", -apple-system, "Segoe UI", sans-serif;
  --font-body: "Mona Sans", -apple-system, "Segoe UI", sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 8px 24px -10px rgba(28, 25, 23, 0.18);
  --shadow-lg: 0 24px 60px -18px rgba(28, 25, 23, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 700; margin: 0; color: var(--ink); }
p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Header ---------- */

.site-header {
  background: var(--charcoal);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.back-link {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  padding: 8px 14px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.back-link:hover { color: #fff; border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.08); }
.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 9px;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-line { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.brand { font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.8rem; color: #d4d4d8; margin-top: 2px; }
.demo-pill {
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  min-height: 40px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-deep); }
.btn-secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- Layout ---------- */

.page { max-width: 1080px; margin: 0 auto; padding: 36px 20px 60px; display: flex; flex-direction: column; gap: 24px; }

.hero { max-width: 640px; margin-bottom: 4px; }
.hero h1 {
  font-family: var(--font-head);
  font-size: 2.25rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin-bottom: 12px;
}
@media (max-width: 640px) { .hero h1 { font-size: 1.7rem; } }
.hero p { color: var(--ink-soft); font-size: 1rem; line-height: 1.6; text-wrap: pretty; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.card-header h2 { font-size: 1.1rem; }
.card-header p { font-size: 0.85rem; color: var(--ink-faint); margin-top: 4px; }
.card-body { padding: 22px; }

/* ---------- Config form ---------- */

.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.config-grid--primary { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.field-label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.input, select.input {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  font-size: 0.9rem; font-family: var(--font-body); color: var(--ink); background: var(--surface);
}
.input:focus-visible, select.input:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red); }
.field-hint { font-size: 0.8rem; color: var(--ink-faint); margin-top: 9px; line-height: 1.5; }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--red); }
.range-value { font-weight: 700; font-size: 0.95rem; min-width: 38px; text-align: right; color: var(--red-deep); }

.field-checkbox { display: flex; flex-direction: column; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong);
  position: relative; flex-shrink: 0; transition: background 0.15s ease;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.15s ease;
}
.switch input:checked + .switch-track { background: var(--red); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--red); outline-offset: 2px; }
.switch-label { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }

.advanced-details { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.advanced-details summary {
  cursor: pointer; font-weight: 600; font-size: 0.88rem; color: var(--ink-soft);
  list-style: none; display: flex; align-items: flex-start; gap: 7px;
}
.advanced-details summary::-webkit-details-marker { display: none; }
.advanced-details summary::before {
  content: ''; width: 7px; height: 7px; margin-top: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s ease; flex-shrink: 0;
}
.advanced-details[open] summary::before { transform: rotate(45deg); margin-top: 4px; }
.advanced-details summary:hover { color: var(--ink); }
.advanced-summary-text { flex: 1; }
.advanced-note { font-weight: 400; color: var(--ink-faint); }

/* ---------- Revenue banner ---------- */

.revenue-banner {
  background: var(--red);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 26px 24px;
  text-align: center;
  color: #fff;
}
.revenue-banner__label {
  font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.82); margin-bottom: 10px;
}
.revenue-banner__value { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.1; }
.revenue-banner__unit { font-size: 0.55em; font-weight: 700; opacity: 0.85; margin-left: 3px; }
.revenue-banner__meta { font-size: 0.85rem; color: rgba(255, 255, 255, 0.85); margin-top: 10px; }
@media (max-width: 480px) { .revenue-banner__value { font-size: 1.9rem; } }

/* ---------- Summary tiles ---------- */

.summary-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-tile__label { font-size: 0.78rem; font-weight: 600; color: var(--ink-faint); margin-bottom: 8px; }
.stat-tile__value { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.stat-tile__value.is-hot { color: var(--red-deep); }
.stat-tile__meta { font-size: 0.78rem; color: var(--ink-faint); margin-top: 4px; }

/* ---------- Table ---------- */

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
  text-align: left; padding: 11px 14px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--ink-faint); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
tr.result-row { cursor: pointer; }
tr.result-row:hover td { background: var(--surface-2); }
tr.result-row.is-expanded td { background: var(--surface-2); }
.row-expand-icon { display: inline-block; width: 9px; height: 9px; color: var(--ink-faint); transition: transform 0.15s ease; }
tr.result-row.is-expanded .row-expand-icon { transform: rotate(90deg); }
.cell-primary { font-weight: 600; }
.cell-sub { font-size: 0.76rem; color: var(--ink-faint); margin-top: 2px; }
.cell-muted { color: var(--ink-faint); }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--radius-pill); padding: 3px 10px;
  font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--hot { background: var(--red-tint); color: var(--red-deep); }
.badge--warm { background: var(--amber-bg); color: var(--amber-text); }
.badge--cold { background: var(--slate-bg); color: var(--slate-text); }
.badge--suppressed { background: var(--surface-2); color: var(--ink-faint); border: 1px solid var(--border-strong); }
.badge--consent { background: var(--violet-bg); color: var(--violet-text); }
.badge--holdout { background: var(--charcoal); color: #fff; }
.badge--not-lapsed { background: var(--green-bg); color: var(--green-text); }
.badge--risk { background: var(--amber-bg); color: var(--amber-text); border: 1px dashed var(--amber-border); }

/* ---------- Sequence chips ---------- */

.seq-list { display: flex; flex-wrap: wrap; gap: 5px; }
.seq-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 600; padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-soft);
}
.seq-chip svg { width: 11px; height: 11px; flex-shrink: 0; }
.seq-empty { color: var(--ink-faint); font-size: 0.8rem; }

/* ---------- Score bar ---------- */

.score-wrap { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.score-track { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.score-fill { height: 100%; border-radius: 999px; background: var(--ink-faint); }
.score-fill.tier-hot { background: var(--red); }
.score-fill.tier-warm { background: #d97706; }
.score-fill.tier-cold { background: var(--slate-text); }
.score-num { font-weight: 700; font-size: 0.86rem; min-width: 22px; text-align: right; }

/* ---------- Detail panel (expanded row) ---------- */

.detail-row td { background: #fbfaf8; padding: 0; }
.detail-panel { padding: 20px 22px 24px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; }
@media (max-width: 760px) { .detail-panel { grid-template-columns: 1fr; } }
.detail-block h4 { font-size: 0.78rem; font-weight: 700; color: var(--ink); margin-bottom: 12px; }
.reasoning-text { font-size: 0.9rem; color: var(--ink-soft); line-height: 1.65; margin-bottom: 16px; }
.breakdown-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 0.82rem; }
.breakdown-label { width: 130px; flex-shrink: 0; color: var(--ink-soft); }
.breakdown-track { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.breakdown-fill { height: 100%; background: var(--red); border-radius: 999px; }
.breakdown-val { width: 34px; text-align: right; font-weight: 700; }
.visit-history-list { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.visit-history-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 0.8rem; border-bottom: 1px solid var(--border); }
.visit-history-list li:last-child { border-bottom: none; }
.visit-history-list .vh-amount { color: var(--ink-faint); }

/* ---------- Mobile cards ---------- */

.result-cards { display: none; padding: 12px; }
.result-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px; margin-bottom: 10px; cursor: pointer;
}
.result-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.result-card .seq-list { margin-top: 10px; }
@media (max-width: 780px) {
  .table-wrap table.data-table { display: none; }
  .result-cards { display: block; }
}

/* ---------- Footer ---------- */

.demo-footer {
  max-width: 1080px; margin: 10px auto 0; padding: 18px 20px 50px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.footer-note { font-size: 0.8rem; color: var(--ink-faint); max-width: 560px; }
