/* ============ Tokens ============ */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-muted: #f6f7fb;
  --border: #e6e8f0;
  --border-strong: #d5d8e4;
  --text: #14162b;
  --text-muted: #5d6179;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --accent-contrast: #ffffff;
  --green: #0b7a43;
  --green-soft: #e4f6ec;
  --red: #c93a3a;
  --shadow-sm: 0 1px 2px rgba(20, 22, 43, 0.05);
  --shadow: 0 1px 2px rgba(20, 22, 43, 0.04), 0 8px 24px -8px rgba(20, 22, 43, 0.08);
  --shadow-accent: 0 8px 20px -6px rgba(79, 70, 229, 0.5);
  --radius: 16px;

  /* Chart series, one per connector, validated with the dataviz skill's
     validate_palette.js (light: all pass, with a contrast WARN on series-3
     that's covered by the legend + comparison table's "relief" already on
     screen; dark: all pass outright). Don't add a 5th slot without
     re-running the validator -- see CLAUDE.md. */
  --series-1: #4f46e5; /* Meta */
  --series-2: #e8590c; /* Google */
  --series-3: #1baf7a; /* Facebook */
  --series-4: #6250d6; /* unused -- Instagram removed as its own connector (see CLAUDE.md); reserved for the next connector so this stays validated and ready */
  --gridline: #eceef5;
  --axis-line: #d5d8e4;
  --tooltip-bg: #14162b;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1020;
  --surface: #161933;
  --surface-muted: #1b1f3d;
  --border: #272b4d;
  --border-strong: #353a64;
  --text: #f1f2fb;
  --text-muted: #a2a6c4;
  --accent: #8b87ff;
  --accent-2: #a78bfa;
  --accent-soft: #23275a;
  --accent-contrast: #0e1020;
  --green: #4ade99;
  --green-soft: #12301f;
  --red: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 8px 20px -6px rgba(139, 135, 255, 0.4);

  /* Re-stepped for the dark surface and re-validated (the previous
     #8b87ff/#ff8a4c pair failed the lightness-band check against this
     surface -- too light, not just a taste call). */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #9085e9;
  --gridline: #23274a;
  --axis-line: #353a64;
  --tooltip-bg: #05060f;

  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); font-weight: 800; line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }

p.lead { color: var(--text-muted); max-width: 62ch; margin-top: 8px; }
p.lead.centered { text-align: center; margin: 0; }
.muted, .muted-text { color: var(--text-muted); font-size: 0.85rem; }
.muted-text { font-size: 0.95rem; margin: 6px 0 14px; max-width: 70ch; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

code {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.86em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  min-height: 44px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:disabled { cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; min-height: 38px; font-size: 0.85rem; border-radius: 10px; }
.btn-lg { padding: 14px 26px; font-size: 1rem; border-radius: 14px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.btn-primary:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn-primary:not(:disabled):active { transform: translateY(0); }
.btn-primary:disabled { background: var(--surface-muted); color: var(--text-muted); border-color: var(--border); box-shadow: none; }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:not(:disabled):hover { background: var(--surface-muted); border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.6; }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 12px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
/* Icon names the *current* mode, same as #themeLabel's text -- sun for
   light, moon for dark. Was backwards (moon showing in light mode, sun in
   dark), which fought the text label instead of matching it. */
.i-moon { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
:root[data-theme="dark"] .i-sun { display: none; }

.link-btn {
  background: transparent; border: none; padding: 4px 6px;
  color: var(--accent); font: inherit; font-size: 0.88rem; font-weight: 700; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ============ Brand (sidebar + mobile topbar) ============ */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; min-width: 0; }
.brand .mark {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; box-shadow: var(--shadow-accent);
}
/* Without flex-shrink: 0 above, a cramped flex row (the sidebar's brand
   row, once it also holds the badge and the collapse button) shrinks
   every child including the icon -- real bug hit: the mark visibly
   squished after signing in, where the sidebar's extra controls leave
   less room than the wide, uncluttered landing-page header. The brand
   text truncating instead (min-width: 0 above + ellipsis on its span,
   not the icon) is what should give under pressure, not the logomark. */
.brand > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex-shrink: 0;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}

/* ============ App shell: sidebar nav + main content ============ */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  width: 240px; flex: 0 0 auto; box-sizing: border-box;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px; padding: 20px 16px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 0 4px; }
.sidebar-collapse-btn { width: 28px; height: 28px; margin-left: auto; flex-shrink: 0; }
.sidebar-expand-btn { display: none; }

nav.tabs.sidebar-nav {
  display: flex; flex-direction: column; gap: 2px;
  background: none; border: none; border-radius: 0; padding: 0; margin-left: 0;
}
nav.tabs.sidebar-nav button {
  display: flex; align-items: center; gap: 10px; justify-content: flex-start;
  width: 100%; padding: 10px 12px; border-radius: 10px;
}
nav.tabs.sidebar-nav button.active { background: var(--accent-soft); box-shadow: none; }
nav.tabs.sidebar-nav button svg { flex-shrink: 0; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-muted);
  overflow: hidden;
}
.user-avatar {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 800; text-transform: uppercase;
}
.user-email {
  font-size: 0.82rem; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-footer .icon-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; justify-content: flex-start;
  padding: 8px 12px; border-radius: 10px;
}
.sidebar-footer .icon-btn span { font-size: 0.88rem; font-weight: 600; color: var(--text-muted); }
/* .btn-ghost's border is transparent by design elsewhere (it's meant to
   blend in next to a primary action), but on its own in the sidebar
   footer that made Sign out look like plain unstyled text with no
   visible control boundary at all. */
#signOutBtn { border-color: var(--border); }
#signOutBtn:hover { border-color: var(--border-strong); }

.sidebar-backdrop { display: none; }

.app-main { flex: 1 1 auto; min-width: 0; }

.mobile-topbar {
  display: none; /* shown in the narrow-viewport media query below */
  position: sticky; top: 0; z-index: 20;
  align-items: center; gap: 12px; padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

/* Shared tab button look (used by both the sidebar and, pre-collapse CSS
   below, the old horizontal layout this replaced) */
nav.tabs button {
  background: transparent; border: none; color: var(--text-muted);
  font: inherit; font-size: 0.9rem; font-weight: 600;
  padding: 7px 16px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { color: var(--accent); }

/* ============ Layout ============ */
main { max-width: 1440px; margin: 0 auto; padding: 32px 32px 80px; }
.panel { display: none; }
.panel.active { display: block; animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .panel.active { animation: none; }
  * { transition: none !important; }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head.single { margin-bottom: 24px; }
.eyebrow {
  display: inline-block; margin-bottom: 8px;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent);
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ============ Sync + status ============ */
.sync-block { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hint { font-size: 0.78rem; color: var(--text-muted); }
.hint.ready { color: var(--green); font-weight: 600; }
.sync-icon { flex: none; }
.btn.is-busy .sync-icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status-bar {
  display: none;
  margin: 0 0 16px; padding: 10px 14px;
  background: var(--accent-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 12px; font-size: 0.88rem;
}
.status-bar.show { display: block; }
.status-bar.error { background: color-mix(in srgb, var(--red) 10%, var(--surface)); border-color: color-mix(in srgb, var(--red) 35%, transparent); }

/* ============ Connections ============ */
.connections { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }
.conn-card {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.conn-card-top { display: flex; align-items: center; gap: 14px; min-width: 0; }
.conn-logo {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-muted); border: 1px solid var(--border);
}
.conn-logo svg { width: 24px; height: 24px; }
.conn-info { flex: 1; min-width: 0; }
.conn-name { font-weight: 700; }
.conn-state { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; }
.conn-card.connected .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.conn-card.connected .conn-state { color: var(--green); }
/* Only the main Connect/Reconnect button gets the "connected" green look
   -- Resync/Disconnect stay their normal ghost style, not just .btn
   generically, now that a connected card can have up to three buttons. */
.conn-card.connected .conn-main-btn { background: var(--green-soft); border-color: transparent; color: var(--green); }

/* Actions always sit on their own row below the logo/name, wrapping if
   there isn't room for all of them side by side -- this is what keeps
   Resync/Disconnect/Reconnect from ever overlapping the provider name
   the way a single flex row did once a card had more than one button. */
.conn-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.conn-actions .btn { flex: 1 1 auto; white-space: nowrap; }

/* ============ Empty state ============ */
.empty { text-align: center; padding: 48px 24px; border-style: dashed; box-shadow: none; }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.empty p { color: var(--text-muted); max-width: 46ch; margin: 6px auto 0; }
.empty .btn { margin-top: 18px; }

/* ============ KPIs ============ */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.kpi-value { font-size: clamp(1.4rem, 1.1rem + 0.9vw, 1.85rem); font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 480px) { .kpi-value { font-size: 1.25rem; } }
.kpi-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; margin-right: 6px; vertical-align: baseline; background: var(--swatch-color, var(--text-muted)); }
.kpi-label .swatch { margin-right: 0; }

/* ============ Charts ============ */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.card-head h3 { color: var(--text); }
.chart-box { position: relative; height: 280px; }

/* ============ Table ============ */
.table-card { padding: 20px 0 0; overflow: hidden; }
.table-card .card-head { padding: 0 20px; }
.table-wrap { overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 480px; }
.compare-table th, .compare-table td { padding: 12px 20px; border-top: 1px solid var(--border); text-align: right; white-space: nowrap; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; }
.compare-table th:last-child, .compare-table td:last-child { text-align: right; }
.compare-table thead th {
  background: var(--surface-muted); color: var(--text-muted);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
}
.compare-table tbody tr:hover { background: var(--surface-muted); }
.compare-table td { font-variant-numeric: tabular-nums; }
.compare-table td:first-child { font-weight: 600; }
.compare-table td.win { font-weight: 800; color: var(--text); }
.compare-table td:not(.win):not(:first-child):not(:last-child) { color: var(--text-muted); }
.leader {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--surface-muted); color: var(--text-muted);
}
/* Set --leader-color inline (e.g. var(--series-3)) per winning provider --
   generic so it scales to however many connectors are present, instead of
   one hardcoded CSS class per provider name. */
.leader.win {
  background: color-mix(in srgb, var(--leader-color, var(--accent)) 14%, var(--surface));
  color: var(--leader-color, var(--accent));
}

/* ============ How to use ============ */
.steps { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 14px; position: relative; }
.steps li {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.step-num {
  flex: none; width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-accent);
}
.steps h3 { margin-bottom: 4px; }
.steps p { color: var(--text-muted); font-size: 0.93rem; }
.run-card h2 { margin-bottom: 2px; }
.codeblock {
  margin: 0; padding: 16px 18px; border-radius: 12px; overflow-x: auto;
  background: #14162b; color: #e6e8ff; font-size: 0.88rem; line-height: 1.7;
}
.codeblock code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* ============ About ============ */
.hero {
  padding: 36px 32px; margin-bottom: 20px; border-radius: 20px;
  background:
    radial-gradient(600px 220px at 100% 0%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent),
    var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.hero h1 { max-width: 22ch; }
.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.about-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.about-icon {
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.about-card h3 { margin-bottom: 8px; }
.about-card p { color: var(--text-muted); font-size: 0.93rem; line-height: 1.6; }
.about-card strong { color: var(--text); }
.stack-card h2 { margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px; font-size: 0.84rem; font-weight: 600;
  background: var(--surface-muted); border: 1px solid var(--border); color: var(--text);
}

/* ============ Landing ============ */
.landing-wrap {
  min-height: 100vh; padding: 32px;
  display: flex; flex-direction: column;
  background:
    radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
    radial-gradient(700px 500px at 100% 110%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent),
    var(--bg);
}
.landing-content {
  flex: 1; max-width: 1200px; margin: 0 auto; width: 100%;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center; gap: 48px; padding: 32px 0;
}
.landing-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; margin-bottom: 40px; }
.landing-headline { font-size: clamp(2.1rem, 1.6rem + 2vw, 3.2rem); font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; max-width: 14ch; }
.landing-headline .accent-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.landing-sub { font-size: 1.05rem; color: var(--text-muted); margin: 18px 0 28px; max-width: 46ch; line-height: 1.6; }
.landing-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.landing-trust { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-muted); }
.landing-trust span { display: inline-flex; align-items: center; gap: 6px; }
.landing-trust svg { color: var(--green); flex: none; }

.landing-visual {
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
  box-shadow: var(--shadow); padding: 36px; position: relative; overflow: hidden;
}
.flow-diagram { display: flex; align-items: center; justify-content: center; gap: 28px; }
.flow-col { display: flex; flex-direction: column; gap: 16px; }
.flow-node {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--surface-muted); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
}
.flow-node svg { width: 26px; height: 26px; }
.flow-center {
  width: 72px; height: 72px; border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.4rem; box-shadow: var(--shadow-accent); flex: none;
}
.flow-chart { width: 64px; height: 64px; border-radius: 16px; background: var(--surface-muted); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.flow-chart svg { width: 32px; height: 32px; color: var(--accent); }

/* ============ Sample-data banner ============ */
.sample-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 10px 16px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 12px; font-size: 0.86rem; color: var(--text);
}
.sample-banner strong { color: var(--accent); }

/* ============ Auth ============ */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(700px 400px at 15% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    radial-gradient(600px 400px at 100% 100%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow);
}
.auth-title { font-size: 1.5rem; margin-top: 22px; }
.auth-card .lead { margin: 6px 0 22px; font-size: 0.93rem; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
#googleSignInBtn { display: flex; justify-content: center; }

#authForm { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.field input {
  padding: 11px 14px; min-height: 44px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.95rem; font-weight: 400;
}
.field input::placeholder { color: var(--text-muted); opacity: 0.7; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.auth-toggle { text-align: center; font-size: 0.88rem; color: var(--text-muted); margin-top: 16px; }
.auth-status { min-height: 1.3em; font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; text-align: center; }
.auth-status.error { color: var(--red); }

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .landing-content { grid-template-columns: minmax(0, 1fr); text-align: center; }
  .landing-headline { max-width: none; margin: 0 auto; }
  .landing-sub { margin-left: auto; margin-right: auto; }
  .landing-cta, .landing-trust { justify-content: center; }
  .landing-brand { justify-content: center; }
  .landing-visual { order: -1; max-width: 420px; margin: 0 auto; }
}

/* Below this width the sidebar becomes a slide-in drawer (closed by
   default, toggled by #sidebarToggle in the mobile topbar) instead of a
   permanent column -- there isn't room for both the sidebar and the
   content side by side. */
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 40; height: 100vh;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 30;
    background: color-mix(in srgb, black 40%, transparent);
  }
  .sidebar-backdrop.show { display: block; }
  .mobile-topbar { display: flex; }
  /* The mobile drawer (open/closed via .open above) already covers
     show/hide here -- the desktop collapse button is redundant and would
     have no visible effect at this width (.sidebar-hidden only matters
     in the min-width: 901px block below), so hide it rather than leave a
     non-functional control in the drawer. */
  .sidebar-collapse-btn { display: none; }
}

/* Desktop-only "hide the sidebar entirely" toggle -- independent of the
   mobile drawer above. #sidebarCollapseBtn hides it; the floating
   #sidebarExpandBtn (fixed top-left, only rendered once .sidebar-hidden
   is set) brings it back. Persisted via localStorage the same way the
   theme choice is (see app.js's initSidebarCollapse()). */
@media (min-width: 901px) {
  .app-shell.sidebar-hidden .sidebar { display: none; }
  .app-shell.sidebar-hidden .sidebar-expand-btn {
    display: inline-flex; position: fixed; top: 16px; left: 16px; z-index: 25;
  }
  /* The floating expand button sits at top:16/left:16 (through ~56px),
     which main's own top-left padding (32px) didn't clear -- real bug
     hit: with the sidebar hidden, the button visibly overlapped the
     Dashboard's own "Ad platform comparison" heading. Push content down
     far enough to clear it instead of changing the button's position
     (keeping it in the same place as every other fixed UI chrome). */
  .app-shell.sidebar-hidden main { padding-top: 72px; }
}

@media (max-width: 760px) {
  .badge { display: none; }
  main { padding: 20px 16px 64px; }
  .connections, .about-grid { grid-template-columns: minmax(0, 1fr); }
  .sync-block { align-items: stretch; width: 100%; }
  .sync-block .btn { width: 100%; }
  .hint { text-align: center; }
  .hero { padding: 24px 20px; }
  .chart-box { height: 240px; }
}

@media (max-width: 480px) {
  .compare-table th, .compare-table td { padding: 10px 12px; font-size: 0.85rem; }
  .compare-table { min-width: 0; }
  .table-card .card-head { padding: 0 14px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .conn-card { flex-wrap: wrap; }
  .conn-card .btn { width: 100%; }
  .steps li { padding: 16px; gap: 12px; }
}
