:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #5b6577;
  --line: #dfe4ec;
  --brand: #635bff;
  --brand-dark: #4b44d6;
  --warn-bg: #fff4d6;
  --warn-text: #7a5600;
  --ok: #0f7b4b;
  --bad: #b42318;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.test-banner {
  background: var(--warn-bg);
  color: var(--warn-text);
  text-align: center;
  font-weight: 600;
  padding: 10px 16px;
  border-bottom: 1px solid #f0d58a;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 20px; }

h1 { font-size: 2rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

button, .button {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--brand-dark); }
button:disabled { opacity: 0.6; cursor: wait; }
button.secondary, .button.secondary-link { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.button.secondary-link:hover { background: #f3f2ff; }

.error { color: var(--bad); min-height: 1.5em; }

/* Landing */
.hero { max-width: 760px; margin-bottom: 28px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.step { display: inline-block; font-size: 0.8rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.how { margin-bottom: 20px; }
.how .flow { margin: 12px 0; }
.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 28px 0;
  font-size: 0.95rem;
}
.flow span { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.flow b { color: var(--muted); font-weight: 400; }

/* Chat page */
.layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

.chat { display: flex; flex-direction: column; height: 70vh; min-height: 420px; padding: 0; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; }
.msg.assistant { align-self: flex-start; background: #eef1f6; }
.msg .meta { display: block; margin-top: 6px; font-size: 0.75rem; color: var(--muted); }
.composer { display: flex; gap: 8px; border-top: 1px solid var(--line); padding: 12px; }
.composer input {
  flex: 1;
  padding: 11px 12px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat:last-of-type { border-bottom: 0; }
.stat b { font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #eef1f6; border-radius: 999px; overflow: hidden; margin: 6px 0 14px; }
.bar div { height: 100%; background: var(--brand); width: 0; transition: width 0.4s; }
.status-paid { color: var(--ok); }
.status-payment_failed, .status-canceled { color: var(--bad); }
.panel-actions { margin-top: 16px; display: grid; gap: 8px; }
.panel-actions.inline { display: flex; flex-wrap: wrap; gap: 10px; }

/* Sample account page */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 20px 0; }
.tile { display: flex; flex-direction: column; gap: 4px; }
.tile b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.chart-card { margin-bottom: 20px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .seg-input { fill: var(--brand); }
.chart .seg-output { fill: #e8710a; }
.legend { display: flex; gap: 6px 16px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -2px; }
.legend .key-input { background: var(--brand); }
.legend .key-output { background: #e8710a; }

/* Navigation, tabs, lab */
.topnav { display: flex; gap: 18px; align-items: center; padding-top: 14px; padding-bottom: 0; flex-wrap: wrap; }
.topnav a { color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.topnav a:first-child { margin-right: auto; }
.topnav a[aria-current="page"] { color: var(--brand); }
.topnav .nav-cta { color: var(--brand); border: 1px solid var(--brand); border-radius: 8px; padding: 6px 12px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 4px; }
.tab { background: #fff; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.tab:hover { background: #f3f2ff; }
.tab[aria-selected="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.profile { margin: 12px 0 0; color: var(--muted); }
tr.current td { background: #fafaff; }
tr.live td { background: #f5f4ff; }
td.neg, .neg { color: var(--bad); }
.badge { display: inline-block; background: var(--brand); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; vertical-align: middle; }
.findings { margin: 20px 0; }
.findings ol { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.lab { margin-bottom: 20px; }
td { white-space: normal; }
th { white-space: nowrap; }
.chart .bar.in-progress { fill: #fff; stroke: var(--brand); stroke-width: 2; stroke-dasharray: 4 3; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: rgba(99, 91, 255, 0.06); }
.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 8px;
  z-index: 10;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.links a { margin-right: 10px; }
.status-open, .status-draft { color: var(--muted); }
