/* Visitor Story app styles. Plain CSS, no build step. */
:root {
  --bg: #f7f6f2; --surface: #ffffff; --ink: #15191f; --muted: #626b78; --line: #e4e1d8; --line-strong: #cfcabd;
  --accent: #2f4bd6; --accent-ink: #ffffff; --accent-soft: #e9ecfb;
  --good: #15803d; --good-soft: #e3f4e8; --bad: #c2410c; --bad-soft: #fdeadf; --warn: #a16207; --warn-soft: #fbf1d6;
  --critical: #b91c1c; --high: #c2410c; --minor: #6b7280; --opportunity: #15803d;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 24, 31, .05), 0 4px 16px rgba(20, 24, 31, .04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; }

.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 9px; padding: 8px 14px; font-weight: 600; cursor: pointer; font-size: 14px; }
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn-quiet { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-lg { padding: 13px 22px; font-size: 16px; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.inline, .inline-form { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #12161d; color: #c9cfd8; padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 750; font-size: 16px; letter-spacing: -.01em; text-decoration: none !important; display: flex; align-items: center; gap: 8px; }
.brand-mark { color: #8ea2ff; font-size: 18px; }
.site-switch select { width: 100%; background: #1d232d; color: #e7ebf1; border-color: #2c3440; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: #c9cfd8; padding: 7px 10px; border-radius: 8px; text-decoration: none; }
.nav a:hover { background: #1d232d; color: #fff; }
.nav a.on { background: #263043; color: #fff; font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.side-foot a, .side-foot .linkish { color: #9aa4b2; text-align: left; }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.crumb { color: var(--muted); }
.flash p { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; }
.flash .flash-error { background: var(--bad-soft); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.empty, td.empty { color: var(--muted); text-align: center; padding: 36px; }
.narrow { max-width: 520px; }
.form label { display: block; margin: 0 0 12px; font-weight: 550; }
.form label input:not([type=checkbox]), .form label select, .form label textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
.form label.check { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-weight: 500; }
.form h2 { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.form h2:first-of-type { margin-top: 0; padding-top: 0; border: 0; }
.help { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.errors { color: var(--bad); }
.notice { background: var(--warn-soft); padding: 10px 12px; border-radius: 8px; }
.snippet-row { display: flex; gap: 10px; align-items: stretch; }
.snippet-row pre { flex: 1; margin: 0; background: #12161d; color: #e7ebf1; padding: 12px 14px; border-radius: 9px; overflow-x: auto; font: 12px var(--mono); }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table th a { color: inherit; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sessions-table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.session-row { cursor: pointer; }
.session-row:hover td { background: #fbfaf7; }
.count { margin: 4px 0 8px; }
.pager { display: flex; gap: 18px; justify-content: center; padding: 14px; align-items: center; }

.badge { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 999px; margin-right: 3px; white-space: nowrap; background: var(--line); color: var(--ink); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.live { background: var(--accent-soft); color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filters input { width: auto; }
.save-seg { margin-bottom: 14px; color: var(--muted); }
.save-seg form { margin: 8px 0; display: flex; gap: 8px; }
.seg-list { margin: 6px 0; padding-left: 18px; }

/* session page */
.session-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.facts dl, .env { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.facts dt, .env dt { color: var(--muted); }
.facts dd, .env dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.page-list, .ev-list { margin: 0; padding-left: 18px; }
.page-list li, .ev-list li { margin: 3px 0; }
.ev-list .ev-rage, .ev-list .ev-dead, .ev-list .ev-error_click, .ev-list .ev-error { color: var(--bad); font-weight: 600; }
.kv { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.src-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.src-wheel { background: #2f4bd6; } .src-key { background: #a855f7; } .src-touch { background: #0d9488; }
.src-scrollbar { background: #f59e0b; } .src-programmatic { background: #9ca3af; } .src-unknown { background: #d1d5db; }

/* auth + landing */
.auth-wrap { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.auth-wrap .brand { color: var(--ink); margin-bottom: 18px; }
.auth-card form p { margin: 0 0 12px; }
.auth-card input:not([type=checkbox]) { width: 100%; }
.auth-card button[type=submit] { background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px; font-weight: 600; cursor: pointer; }
.landing { background: #0f131a; color: #e7ebf1; }
.hero-wrap { max-width: 980px; margin: 0 auto; padding: 24px; }
.land-top { display: flex; justify-content: space-between; align-items: center; }
.land-top a { color: #c9cfd8; margin-left: 14px; }
.land-top .btn { color: #fff; }
.land-hero { padding: 14vh 0 10vh; }
.land-hero h1 { font-size: clamp(30px, 5vw, 52px); line-height: 1.08; letter-spacing: -.025em; max-width: 20ch; }
.lede { font-size: 18px; color: #aab3c0; max-width: 56ch; margin: 18px 0 30px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .session-grid { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 40px; }
}

/* reports */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi b { font-size: 24px; letter-spacing: -.02em; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.chart { height: 280px; }
.small-chart { height: 200px; }
.heat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.heat-card { padding: 10px; overflow: auto; max-height: 82vh; }
.heatmap { position: relative; }
@media (max-width: 900px) { .heat-layout, .grid-2 { grid-template-columns: 1fr; } }

/* dashboard + findings */
.dash-head { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-bottom: 18px; }
.health { display: flex; align-items: baseline; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; box-shadow: var(--shadow); cursor: help; }
.health-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 6px; }
.health-score { font-size: 40px; letter-spacing: -.03em; line-height: 1; }
.health-score.good { color: var(--good); } .health-score.warn { color: var(--warn); } .health-score.bad { color: var(--bad); } .health-score.na { color: var(--muted); }
.health-trend { width: 140px; height: 40px; margin-left: 12px; }
.live { color: var(--muted); } .live .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.tabs { margin-left: auto; display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs a { padding: 7px 14px; color: var(--ink); } .tabs a.on { background: var(--accent); color: #fff; text-decoration: none; }
.delta { display: block; font-style: normal; font-size: 12px; color: var(--muted); } .delta.up { color: var(--good); } .delta.down { color: var(--bad); }
.must-fix { margin: 8px 0 20px; }
.section-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 18px; }
.streak { margin-left: auto; background: var(--good-soft); color: var(--good); border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cards.list { grid-template-columns: 1fr; }
.finding { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--minor); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.finding.sev-critical { border-left-color: var(--critical); } .finding.sev-high { border-left-color: var(--high); } .finding.sev-opportunity { border-left-color: var(--opportunity); }
.finding header { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.finding .sev { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sev-critical .sev { color: var(--critical); } .sev-high .sev { color: var(--high); } .sev-opportunity .sev { color: var(--opportunity); }
.finding-title { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0; }
.metric-line, .impact { margin: 0; } .impact { font-weight: 600; }
.finding footer { margin-top: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spark { height: 36px; }
.stamp { background: var(--good-soft); color: var(--good); }
.narr { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; margin: 6px 0; }
.narr dt { color: var(--muted); } .narr dd { margin: 0; }
.deep { margin-top: 10px; padding: 10px 14px; background: #f7f8fe; border-radius: 10px; }
.section-gap { margin-top: 26px; }
.htmx-indicator { display: none; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.meter { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.meter-fill { height: 100%; background: var(--accent); max-width: 100%; } .meter-fill.warn { background: var(--warn); } .meter-fill.bad { background: var(--bad); }
