:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #14181f;
  --ink-soft: #545c6b;
  --line: #e4e7ec;
  --brand: #1f5eff;
  --brand-ink: #0b3fd1;
  --accent: #12b886;
  --danger: #e03131;
  --warn: #f08c00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand-text {
  font-family: 'Barlow Condensed', 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: .2px;
  color: var(--ink);
  margin: 0 0 .3em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand.center { justify-content: center; margin-bottom: 1rem; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--brand); color: #fff;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 1rem;
}
.brand-text { font-size: 1.15rem; color: var(--ink); text-transform: uppercase; letter-spacing: 1px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: .92rem;
  cursor: pointer; transition: .15s; text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 26px; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; text-transform: capitalize;
  background: #eef1f5; color: var(--ink-soft);
}
.badge-trialing, .badge-pending_connection { background: #fff4e6; color: #b3630b; }
.badge-active { background: #e6fcf5; color: #087f5b; }
.badge-past_due, .badge-expired, .badge-canceled { background: #ffe3e3; color: #c92a2a; }

/* Alerts */
.alert { background: #fff0f0; border: 1px solid #ffc9c9; color: #c92a2a;
  padding: 10px 14px; border-radius: 9px; margin-bottom: 1rem; font-size: .9rem; }
.notice { background: #fff9db; border: 1px solid #ffec99; color: #7a5b00;
  padding: 11px 16px; border-radius: 10px; margin-bottom: 1.4rem; font-size: .92rem; }

/* ── Auth ── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.auth-card h1 { text-align: center; }
.auth-lede, .auth-alt { text-align: center; color: var(--ink-soft); font-size: .9rem; }
.auth-alt { margin-top: 1.2rem; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 600; font-size: .85rem; }
.field > span em { color: var(--ink-soft); font-weight: 400; font-style: normal; }
.field input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: .95rem; font-family: inherit; background: #fff;
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,94,255,.12); }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* ── App shell ── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line);
  padding: 1.2rem 1rem; display: flex; flex-direction: column; }
.sidebar .brand { margin-bottom: 1.6rem; padding: 0 .3rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { padding: 9px 12px; border-radius: 8px; color: var(--ink-soft);
  font-weight: 500; font-size: .92rem; }
.nav-item:hover { background: #f1f3f6; color: var(--ink); text-decoration: none; }
.nav-item.is-active { background: #eef3ff; color: var(--brand-ink); font-weight: 600; }
.nav-item.muted { color: var(--ink-soft); }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.ws-chip { display: flex; flex-direction: column; gap: 5px; padding: .4rem .3rem .7rem; }
.ws-name { font-weight: 600; font-size: .88rem; }

.main { padding: 2rem 2.4rem; max-width: 1100px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.6rem; }
.page-head .sub { color: var(--ink-soft); margin: 0; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card, .panel { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; }
.panel { margin-bottom: 1.2rem; }
.panel.narrow { max-width: 560px; }
.site-card-head { display: flex; align-items: center; justify-content: space-between; }
.site-domain { color: var(--ink-soft); font-size: .9rem; margin: .2rem 0 1rem; }

.empty { display: grid; place-items: center; padding: 3rem 1rem; }
.empty-inner { text-align: center; max-width: 420px; }
.empty-inner p { color: var(--ink-soft); margin-bottom: 1.4rem; }

/* Key-value + chips */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: .5rem 1rem; margin: 0; }
.kv dt { color: var(--ink-soft); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 500; }
.limits { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.chip { background: #f1f3f6; border-radius: 20px; padding: 4px 12px; font-size: .8rem; color: var(--ink-soft); }

/* ── Landing ── */
.lp-nav { display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 2rem; max-width: 1100px; margin: 0 auto; }
.lp-nav nav { display: flex; gap: .6rem; }
.lp-hero { max-width: 780px; margin: 4rem auto 3rem; text-align: center; padding: 0 1.5rem; }
.lp-hero h1 { font-size: 3.2rem; line-height: 1.05; }
.lp-lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 620px; margin: 1rem auto 2rem; }
.lp-cta { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.lp-features { max-width: 1000px; margin: 2rem auto 4rem; padding: 0 1.5rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.4rem; }
.lp-feature h3 { color: var(--brand-ink); }
.lp-feature p { color: var(--ink-soft); font-size: .95rem; }
.lp-foot { text-align: center; padding: 2rem; color: var(--ink-soft); border-top: 1px solid var(--line);
  display: flex; gap: 1rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.lp-foot-links { display: inline-flex; gap: 1rem; }
.lp-foot-links a { color: var(--ink-soft); }
.lp-foot-links a:hover { color: var(--brand); }

/* Site dashboard */
.site-head { margin-bottom: .6rem; }
.subnav { display: flex; gap: 1.2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.subnav a { padding: 8px 2px; color: var(--ink-soft); font-weight: 600; font-size: .92rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--ink); text-decoration: none; }
.subnav a.is-active { color: var(--brand-ink); border-bottom-color: var(--brand); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0 1.6rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: 3px; }
.kpi-label { color: var(--ink-soft); font-size: .82rem; }
.kpi-val { font-family: 'Barlow Condensed', sans-serif; font-size: 1.9rem; font-weight: 700; line-height: 1; }
.delta { font-size: .82rem; font-weight: 600; }
.delta.up { color: #087f5b; }
.delta.down { color: #c92a2a; }

.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.chart { height: 260px; width: 100%; }

.tabs, .table-wrap { margin-bottom: 1rem; }
.tabs { display: flex; gap: .5rem; }
.tab { padding: 6px 14px; border-radius: 8px; background: #eef1f5; color: var(--ink-soft); font-weight: 600; font-size: .88rem; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.is-active { background: var(--brand); color: #fff; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data th { color: var(--ink-soft); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.url { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data tbody tr:hover { background: #f8fafc; }

/* Rank tracking (P2) */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1rem 0 .4rem; }
.stat-strip { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: center; font-size: .92rem; }
.stat-strip .up { color: #087f5b; font-weight: 600; }
.stat-strip .down { color: #c92a2a; font-weight: 600; }
.actions { display: flex; gap: .6rem; }
.add-panel { padding: 0; }
.add-panel summary { cursor: pointer; padding: 1rem 1.3rem; font-weight: 600; }
.add-panel .form { padding: 0 1.3rem 1.3rem; }
textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-family: inherit; font-size: .95rem; resize: vertical; }
textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,94,255,.12); }
select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-family: inherit; font-size: .95rem; background: #fff; }
.up { color: #087f5b; } .down { color: #c92a2a; }
.spark { display: block; overflow: visible; }
.spark-cell.up { color: #087f5b; } .spark-cell.muted { color: var(--ink-soft); }
.link-btn { background: none; border: 0; color: var(--ink-soft); cursor: pointer; font-size: .95rem; padding: 2px 6px; }
.link-btn:hover { color: var(--danger); }
table.data td input[type=checkbox] { width: 16px; height: 16px; }

/* Diagnosis (P3) */
.findings { display: flex; flex-direction: column; gap: .8rem; }
.finding { border-left: 3px solid var(--line); padding: .6rem .9rem; background: #fafbfc; border-radius: 0 8px 8px 0; }
.finding.sev-high { border-left-color: var(--danger); }
.finding.sev-medium { border-left-color: var(--warn); }
.finding.sev-low { border-left-color: #adb5bd; }
.finding-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.finding-subject { font-weight: 600; }
.finding-url { display: block; font-size: .82rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finding-action { margin: .3rem 0; font-size: .9rem; }
.finding-ctx { display: flex; flex-wrap: wrap; gap: .4rem; }
.sev-badge-high { background: #ffe3e3; color: #c92a2a; }
.sev-badge-medium { background: #fff4e6; color: #b3630b; }
.sev-badge-low { background: #eef1f5; color: var(--ink-soft); }

/* To-dos (P3) */
.todos { display: flex; flex-direction: column; gap: 1rem; }
.todo { display: grid; grid-template-columns: 1fr 300px; gap: 1.2rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.3rem; }
.todo.status-done { opacity: .72; }
.todo.status-dismissed { opacity: .5; }
.todo-head { display: flex; gap: .4rem; margin-bottom: .4rem; flex-wrap: wrap; }
.todo h4 { margin: .2rem 0; font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: 600; }
.status-badge-open { background: #e7f5ff; color: #1971c2; }
.status-badge-in_progress { background: #fff4e6; color: #b3630b; }
.status-badge-done { background: #e6fcf5; color: #087f5b; }
.status-badge-dismissed { background: #eef1f5; color: var(--ink-soft); }
.impact { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.todo-form { display: flex; flex-direction: column; gap: .5rem; }
.todo-form textarea { width: 100%; font-size: .85rem; }
.todo-actions { display: flex; gap: .5rem; }
.todo-actions select { flex: 1; }
@media (max-width: 760px) { .todo { grid-template-columns: 1fr; } }

/* Reports (P4) */
.report { margin-bottom: 1.2rem; }
.report-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: .6rem; margin-bottom: 1rem; }
.report-body { font-size: .95rem; line-height: 1.65; }
.report-body h2 { font-size: 1.3rem; margin-top: 1.4rem; }
.report-body h3 { font-size: 1.05rem; margin-top: 1.1rem; }
.report-body ul { padding-left: 1.3rem; }
.report-body li { margin: .25rem 0; }
.report-body table { width: 100%; border-collapse: collapse; margin: .8rem 0; font-size: .88rem; }
.report-body th, .report-body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.report-body code { background: #f1f3f6; padding: 1px 5px; border-radius: 4px; font-size: .85em; }

/* ── Billing / plan-state banners ─────────────────────────────── */
.app-banner {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1.4rem;
  font-size: .92rem; border: 1px solid transparent;
}
.app-banner-lock { background: #ffe3e3; color: #c92a2a; border-color: #ffc9c9; }
.app-banner-warn { background: #fff4e6; color: #b3630b; border-color: #ffe8cc; }
.app-banner-ok { background: #e6fcf5; color: #087f5b; border-color: #c3fae8; }
.app-banner .banner-cta { margin-left: auto; font-weight: 600; white-space: nowrap; }

/* ── Legal pages (privacy / terms) ────────────────────────────── */
.legal-nav { display: flex; align-items: center; justify-content: space-between;
  max-width: 820px; margin: 0 auto; padding: 1.4rem 1.5rem; }
.legal { max-width: 820px; margin: 0 auto 4rem; padding: 0 1.5rem; }
.legal h1 { margin-bottom: .2rem; }
.legal .updated { color: var(--ink-soft); font-size: .9rem; margin-bottom: 2rem; }
.legal h2 { font-size: 1.25rem; margin: 2rem 0 .6rem; }
.legal h3 { font-size: 1.02rem; margin: 1.2rem 0 .4rem; }
.legal p, .legal li { color: #2b3240; }
.legal ul { padding-left: 1.2rem; }
.legal li { margin: .3rem 0; }
.legal a { color: var(--brand); }
.legal .callout { background: #f1f5ff; border: 1px solid #d7e2ff; border-radius: var(--radius);
  padding: 1rem 1.2rem; margin: 1rem 0; font-size: .95rem; }

/* ── Admin form controls ──────────────────────────────────────── */
.inline-form { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.input {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,94,255,.12); }

/* ── Pricing grid ─────────────────────────────────────────────── */
.pricing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1rem; }
.price-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.price-card.is-current { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(31,94,255,.15); }
.price-card h3 { margin: 0 0 .3rem; }
.price-card .price { font-family: 'Barlow Condensed', sans-serif; font-size: 2rem; line-height: 1; }
.price-card .price small { font-size: .85rem; color: var(--ink-soft); font-weight: 400; }
.price-card ul { list-style: none; padding: 0; margin: 1rem 0; font-size: .9rem; }
.price-card ul li { padding: .3rem 0; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.price-card .price-foot { margin-top: auto; }
.price-card .current-tag { font-size: .8rem; color: var(--accent); font-weight: 600; text-align: center; }
.usage-bar { height: 6px; background: #eef1f5; border-radius: 4px; overflow: hidden; margin-top: .3rem; }
.usage-bar > span { display: block; height: 100%; background: var(--brand); }

@media (max-width: 820px) { .pricing { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar .brand, .sidebar-foot { margin: 0; border: 0; padding: 0 .5rem; }
  .nav { flex-direction: row; }
  .main { padding: 1.4rem; }
  .lp-hero h1 { font-size: 2.3rem; }
}
