/* PlanITAnalytics — hand-written styles.
   Palette: Plan-IT navy (#212934) and orange (#ec671b). The orange is spent in
   three places only — the traffic line, the active marker and primary actions —
   so the numbers stay the loudest thing on the page. Type: Assistant (variable,
   self-hosted; no third-party requests from an analytics tool). */

@font-face {
  font-family: "Assistant";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/static/fonts/assistant-var.woff2") format("woff2");
}

:root {
  --bg: #f4f5f7;            /* page background */
  --bg-elev: #ffffff;       /* cards */
  --bg-muted: #f7f8fa;
  --bg-hover: #eef0f3;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #212934;
  --text-2: #3d4651;
  --muted: #6b7480;
  --muted-2: #9aa3ad;
  --accent: #ec671b;        /* buttons, line, active marker */
  --accent-hover: #d65a12;
  --accent-ink: #c2530e;    /* orange as text on white (AA) */
  --accent-soft: #fdefe6;
  --accent-border: #f6c6a6;
  --accent-text: #ffffff;
  --nav-bg: #212934;
  --nav-text: #ffffff;
  --nav-muted: #aab3bd;
  --nav-hover: rgba(255,255,255,0.08);
  --bar: rgba(33,41,52,0.07);
  --bar-hover: rgba(33,41,52,0.13);
  --green: #1a7f4b; --green-soft: #e3f5ea;
  --red: #c0392b; --red-soft: #fbe9e7;
  --amber: #b7791f; --amber-soft: #fdf3dc;
  --shadow: 0 1px 2px rgba(33,41,52,0.06);
  --shadow-lg: 0 12px 32px rgba(33,41,52,0.16), 0 2px 8px rgba(33,41,52,0.06);
  --radius: 8px;
  --radius-sm: 5px;
  --graph-line: #ec671b;
  --graph-fill-top: rgba(236,103,27,0.20);
  --graph-fill-bottom: rgba(236,103,27,0);
  --graph-compare: #9aa3ad;
  --grid: #eceff2;
  --font: "Assistant", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #161b22;
  --bg-elev: #1d232c;
  --bg-muted: #232a34;
  --bg-hover: #2a323d;
  --border: #2c3540;
  --border-strong: #3b4652;
  --text: #f1f3f5;
  --text-2: #cbd2d9;
  --muted: #98a2ad;
  --muted-2: #6c7682;
  --accent: #f58a45;
  --accent-hover: #ff9d5e;
  --accent-ink: #f58a45;
  --accent-soft: rgba(245,138,69,0.14);
  --accent-border: rgba(245,138,69,0.4);
  --accent-text: #161b22;
  --nav-bg: #11151b;
  --nav-text: #ffffff;
  --nav-muted: #98a2ad;
  --nav-hover: rgba(255,255,255,0.08);
  --bar: rgba(241,243,245,0.08);
  --bar-hover: rgba(241,243,245,0.14);
  --green: #4cc38a; --green-soft: rgba(76,195,138,0.14);
  --red: #f16a5c; --red-soft: rgba(241,106,92,0.14);
  --amber: #e5a53a; --amber-soft: rgba(229,165,58,0.14);
  --shadow: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
  --graph-line: #f58a45;
  --graph-fill-top: rgba(245,138,69,0.22);
  --graph-fill-bottom: rgba(245,138,69,0);
  --graph-compare: #6c7682;
  --grid: #28303a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; min-height: 100vh;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 12px; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--bg-muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
pre { margin: 0; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-all; }
pre code { background: none; border: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accent { color: var(--accent); }
.danger { color: var(--red) !important; }
[hidden] { display: none !important; }

/* ---- Layout ------------------------------------------------------------- */
.page { flex: 1; padding: 24px 16px 40px; overflow-x: clip; min-width: 0; }
.container { max-width: 1100px; margin: 0 auto; }
.container.narrow { max-width: 480px; }
.container.wide { max-width: 1280px; }
.footer { padding: 20px 16px; text-align: center; color: var(--muted-2); font-size: 12px; border-top: 1px solid var(--border); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head-actions { display: flex; gap: 10px; align-items: center; }
.section-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 8px 0 12px; }

/* ---- Top nav (Plan-IT navy, in both themes) ---------------------------- */
.topnav { background: var(--nav-bg); color: var(--nav-text); position: sticky; top: 0; z-index: 30; }
.topnav-inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; height: 54px; display: flex; align-items: center; gap: 10px; }
.topnav-spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: var(--nav-text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.topnav .dropdown-toggle { color: var(--nav-text); }
.topnav .dropdown-toggle:hover, .topnav .dropdown.open .dropdown-toggle { background: var(--nav-hover); }
.topnav .dropdown-toggle .chev { color: var(--nav-muted); }
.topnav .icon-btn { color: var(--nav-muted); }
.topnav .icon-btn:hover { background: var(--nav-hover); color: var(--nav-text); }
.topnav .btn-ghost { color: var(--nav-text); border-color: rgba(255,255,255,0.25); }
.topnav .btn-ghost:hover { background: var(--nav-hover); }
.topnav .site-switcher::before { content: ""; width: 1px; height: 22px; background: rgba(255,255,255,0.18); margin: 0 4px 0 2px; display: inline-block; vertical-align: middle; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.user-name { max-width: 140px; }
.site-switcher .dropdown-toggle { max-width: 260px; }
.site-favicon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; background: var(--nav-bg); color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.topnav .site-favicon { background: rgba(255,255,255,0.14); }
.site-favicon.sm { width: 20px; height: 20px; font-size: 11px; border-radius: 4px; }

/* ---- Buttons ------------------------------------------------------------ */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1.3; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.icon-btn { background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: var(--radius-sm); width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; line-height: 1; padding: 0; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.center { justify-content: center; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

/* ---- Cards -------------------------------------------------------------- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px; }
.card-title { font-size: 17px; margin-bottom: 8px; }
.card-danger { border-color: rgba(220,38,38,0.35); }
.card-highlight { border-color: var(--accent); background: var(--accent-soft); }
.empty-state { padding: 48px 24px; }
.empty-state h2 { margin-bottom: 6px; }

/* ---- Forms -------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.grow { flex: 1; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--red); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
  font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--text); width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-border); outline-offset: 1px; border-color: var(--accent); }
.btn:focus-visible, .icon-btn:focus-visible, .dropdown-toggle:focus-visible, .panel-tab:focus-visible, .top-stat:focus-visible, .bar-row button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[readonly] { background: var(--bg-muted); color: var(--muted); }
.input-sm { padding: 5px 8px; font-size: 13px; width: auto; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.form-inline-field { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.form-inline-field .field { flex: 1; min-width: 200px; }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox input, .radio input { width: auto; }
.radio-row { display: flex; gap: 20px; flex-wrap: wrap; }
.code-input { font-family: var(--mono); font-size: 24px; letter-spacing: 8px; text-align: center; }
.strength-meter { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.strength-meter span { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s, background .2s; }
.strength-meter span.level-2 { background: var(--amber); }
.strength-meter span.level-3, .strength-meter span.level-4 { background: var(--green); }
.auth-page { margin-top: 32px; }
.auth-page .card { padding: 28px 32px 30px; }
.auth-page .card-title { margin-bottom: 18px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 6px; }
.auth-brand h1 { font-size: 26px; margin-bottom: 4px; }
.auth-brand p { color: var(--muted); margin: 0; font-size: 15px; }

/* ---- Alerts / flash / toasts ------------------------------------------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--red-soft); color: var(--red); border-color: rgba(220,38,38,.2); }
.alert-success { background: var(--green-soft); color: var(--green); border-color: rgba(22,163,74,.2); }
.alert-info { background: var(--accent-soft); color: var(--text-2); border-color: var(--accent-border); }
.flash-container { max-width: 1100px; margin: 16px auto -8px; padding: 0 16px; }
.flash { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 8px; transition: opacity .4s; }
.flash.out { opacity: 0; }
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.flash-info { background: var(--accent-soft); color: var(--text-2); }
.flash-close { background: none; border: 0; font-size: 18px; cursor: pointer; color: inherit; line-height: 1; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-lg); transition: opacity .3s, transform .3s; max-width: 360px; }
.toast-error { background: var(--red); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---- Badges / tables ---------------------------------------------------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--bg-muted); color: var(--muted); border: 1px solid var(--border); }
.badge-indigo { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.small td { padding: 6px 10px; }

/* ---- Dropdowns ---------------------------------------------------------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 500; padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.dropdown-toggle:hover { background: var(--bg-hover); }
.dropdown.open .dropdown-toggle { background: var(--bg-hover); }
.dropdown-toggle .chev { color: var(--muted); transition: transform .15s; }
.dropdown.open .dropdown-toggle .chev { transform: rotate(180deg); }
.dropdown-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; max-height: 70vh; overflow: auto; }
.dropdown-menu-right { left: auto; right: 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 5px; color: var(--text); font: inherit; font-size: 14px; background: none; border: 0; cursor: pointer; }
.dropdown-item:hover { background: var(--bg-hover); text-decoration: none; }
.dropdown-item.active { color: var(--accent); font-weight: 600; }
.dropdown-item .kbd { margin-left: auto; }
.dropdown-label { padding: 6px 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-menu form { margin: 0; }
.kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; line-height: 18px; min-width: 20px; text-align: center; }

/* ---- Site grid ---------------------------------------------------------- */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }
.site-card { display: block; color: var(--text); padding: 18px 20px 16px; margin: 0; transition: border-color .12s; position: relative; }
a.site-card:hover { text-decoration: none; border-color: var(--border-strong); }
.site-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.site-domain { font-weight: 600; flex: 1; font-size: 15px; }
.site-card-settings { color: var(--muted); padding: 4px; border-radius: 4px; }
.site-card-settings:hover { color: var(--accent-ink); background: var(--accent-soft); }
.site-card-stat { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.site-card-stat .stat-text { display: flex; flex-direction: column; min-width: 0; }
.site-visitors { font-size: 28px; font-weight: 700; line-height: 1.1; }
.site-card-stat .stat-caption { font-size: 13px; color: var(--muted); }
.sparkline { width: 110px; height: 34px; flex: none; overflow: visible; }
.sparkline path.spark-fill { fill: var(--graph-fill-top); }
.sparkline path.spark-line { fill: none; stroke: var(--graph-line); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.invitation-card .btn-row { margin-top: 10px; }

/* ---- Snippet box -------------------------------------------------------- */
.snippet-box { position: relative; background: var(--bg-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 80px 14px 14px; margin: 12px 0 16px; }
.snippet-box.compact { padding: 6px 70px 6px 10px; margin: 0; font-size: 12px; }
.snippet-box .copy-btn { position: absolute; top: 8px; right: 8px; }
.snippet-box.compact .copy-btn { top: 3px; right: 4px; }
.details-block { margin: 10px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px; }
.details-block summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.details-block > :not(summary) { margin-top: 10px; }
.details-block pre { background: var(--bg-muted); padding: 10px; border-radius: 4px; }

/* ---- Settings layout ---------------------------------------------------- */
.settings-head { margin-bottom: 18px; }
.settings-title { font-size: 22px; margin: 2px 0 0; }
.settings-layout { display: grid; grid-template-columns: 210px 1fr; gap: 24px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 72px; }
.settings-nav-item { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; font-weight: 500; }
.settings-nav-item:hover { background: var(--bg-hover); text-decoration: none; }
.settings-nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.settings-nav-item.danger { color: var(--red); }
.settings-content { min-width: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 12px; font-size: 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }

/* ---- Error page --------------------------------------------------------- */
.error-page { margin-top: 48px; }
.error-status { font-size: 56px; font-weight: 800; color: var(--accent-border); line-height: 1; margin-bottom: 8px; }

/* ---- Skeletons ---------------------------------------------------------- */
.skeleton { display: inline-block; background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-hover) 50%, var(--bg-muted) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
.skeleton-num { width: 48px; height: 22px; vertical-align: middle; }
.skeleton-graph { display: block; width: 100%; height: 280px; border-radius: var(--radius-sm); }
.skeleton-row { display: block; height: 28px; margin: 6px 0; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ======================================================================== */
/* Dashboard                                                                */
/* ======================================================================== */
.dashboard-page { padding-top: 18px; }
.dash-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.dash-topbar-right { display: flex; align-items: center; gap: 6px; justify-self: end; }
.dash-site { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.dash-domain { font-size: 22px; margin: 0; max-width: 420px; font-weight: 700; }
.realtime-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 500; padding: 3px 10px 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); }
.realtime-badge .count { color: var(--text); font-weight: 700; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(26,127,75,.5); animation: pulse 2s infinite; }
.pulse-lg { width: 16px; height: 16px; border-radius: 50%; background: var(--green); margin: 0 auto 16px; animation: pulse 2s infinite; box-shadow: 0 0 0 0 rgba(26,127,75,.5); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(26,127,75,.5); } 70% { box-shadow: 0 0 0 8px rgba(26,127,75,0); } 100% { box-shadow: 0 0 0 0 rgba(26,127,75,0); } }
@media (prefers-reduced-motion: reduce) { .pulse, .pulse-lg, .skeleton { animation: none; } .bar-row .bar-fill { transition: none; } }
.period-nav { display: flex; align-items: center; gap: 2px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.period-nav .icon-btn { width: 30px; height: 30px; }
.period-btn { font-weight: 600; border-color: transparent; }
.period-btn:hover { background: var(--bg-hover); }
.period-menu { min-width: 240px; }
.period-menu .dropdown-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.custom-range { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.custom-range label { display: inline-flex; align-items: center; gap: 6px; }
.custom-range input { width: auto; }

/* Filter bar — its own row under the title */
.filter-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 30px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; max-width: 100%; min-width: 0; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-elev); color: var(--text-2); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 13px; max-width: min(360px, 100%); min-width: 0; cursor: pointer; }
.filter-chip:hover { border-color: var(--accent); }
.filter-chip b { color: var(--text); font-weight: 600; }
.filter-chip .chip-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px; border-radius: 50%; }
.filter-chip .chip-x:hover { color: var(--red); }
.filter-menu { min-width: 300px; padding: 10px; }
.filter-menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.filter-menu-grid .dropdown-item { font-size: 13px; padding: 5px 8px; }
.filter-menu-grid .dropdown-label { grid-column: 1 / -1; }
.filter-form { display: flex; flex-direction: column; gap: 10px; }
.filter-form-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 14px; }
.filter-form-row { display: flex; gap: 8px; }
.filter-form-row select { width: 120px; flex: none; }
.filter-form-row .suggest-wrap { flex: 1; position: relative; }
.suggestions { position: absolute; top: calc(100% + 2px); left: 0; right: 0; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 220px; overflow: auto; z-index: 50; }
.suggestions button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 10px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; }
.suggestions button:hover, .suggestions button.active { background: var(--bg-hover); }
.filter-form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Top stats — a row of figures, no cell borders; the active one is underlined */
.graph-card { padding: 0; overflow: hidden; }
.top-stats { display: flex; flex-wrap: wrap; gap: 0 8px; padding: 10px 14px 0; }
.top-stat { flex: 1 1 140px; padding: 10px 10px 12px; cursor: pointer; position: relative; background: transparent; border: 0; border-bottom: 2px solid transparent; text-align: left; font: inherit; color: var(--text); min-width: 0; border-radius: 0; }
.top-stat:hover .ts-label { color: var(--text); }
.top-stat.active { border-bottom-color: var(--accent); }
.top-stat .ts-value { font-size: 28px; font-weight: 700; line-height: 1.1; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; letter-spacing: -0.01em; }
.top-stat .ts-label { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; margin-top: 4px; }
.top-stat .ts-change { font-size: 13px; font-weight: 600; }
.ts-change.up { color: var(--green); } .ts-change.down { color: var(--red); } .ts-change.flat { color: var(--muted); }
.top-stat .ts-compare { font-size: 12px; color: var(--muted); margin-top: 2px; }
.top-stat.skeleton-stat .ts-value { height: 32px; }

/* Graph */
.graph-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 20px 0; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: -1px; }
.graph-legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); padding-top: 8px; }
.graph-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.graph-legend .lg i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; background: var(--graph-line); }
.graph-legend .lg.compare i { background: repeating-linear-gradient(90deg, var(--graph-compare) 0 4px, transparent 4px 7px); }
.interval-picker { display: flex; gap: 2px; background: var(--bg-muted); border-radius: var(--radius-sm); padding: 2px; margin-top: 8px; }
.interval-picker button { background: none; border: 0; padding: 4px 10px; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); border-radius: 4px; cursor: pointer; }
.interval-picker button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow); }
.interval-picker button:disabled { opacity: .4; cursor: default; }
.graph-wrap { position: relative; padding: 8px 12px 10px; height: 300px; }
.graph-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.graph-wrap .axis text { font-size: 12px; fill: var(--muted); font-family: var(--font); }
.graph-wrap .grid line { stroke: var(--grid); stroke-width: 1; }
.graph-wrap .line { fill: none; stroke: var(--graph-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graph-wrap .line.compare { stroke: var(--graph-compare); stroke-width: 1.5; stroke-dasharray: 5 4; }
.graph-wrap .area { fill: url(#areaGradient); }
.graph-wrap .hover-line { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.graph-wrap .dot { fill: var(--bg-elev); stroke: var(--graph-line); stroke-width: 2.5; }
.graph-wrap .dot.compare { stroke: var(--graph-compare); }
.graph-wrap .bar { fill: var(--graph-line); opacity: .85; }
.graph-wrap .bar:hover { opacity: 1; }
.graph-tooltip { position: absolute; pointer-events: none; background: var(--nav-bg); color: #fff; padding: 8px 12px; border-radius: 6px; font-size: 12px; box-shadow: var(--shadow-lg); z-index: 20; min-width: 150px; }
.graph-tooltip .tt-label { color: var(--nav-muted); margin-bottom: 4px; }
.graph-tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.graph-tooltip .tt-row b { font-size: 14px; }
.graph-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }

/* Panels — sized by their content, aligned to the top of each grid row */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.panel { padding: 14px 20px 10px; margin: 0; display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; min-height: 28px; }
.panel-title { font-size: 15px; font-weight: 700; margin: 0; }
.panel-tabs { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.panel-tab { background: none; border: 0; font: inherit; font-size: 13px; color: var(--muted); padding: 3px 8px; border-radius: 4px; cursor: pointer; font-weight: 500; }
.panel-tab:hover { color: var(--text); background: var(--bg-hover); }
.panel-tab.active { color: var(--text); background: var(--bg-hover); font-weight: 600; }
.panel-tab-select { font-size: 13px; padding: 3px 6px; width: auto; border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.panel-tab-select.active { color: var(--text); font-weight: 600; }
.panel-cols { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 500; padding: 0 8px 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.panel-cols .cols-right { display: flex; gap: 16px; }
.panel-cols .cols-right span { min-width: 56px; text-align: right; }
.panel-body { flex: 1; }
.panel-foot { padding-top: 6px; margin-top: auto; text-align: center; }
.panel-foot .details-link { font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 0; font-family: inherit; cursor: pointer; padding: 4px 10px; border-radius: 4px; }
.panel-foot .details-link:hover { color: var(--accent-ink); background: var(--accent-soft); }
.panel-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 36px 0; }

/* Bar rows (the Plausible list look, with a quiet slate fill) */
.bar-row { display: flex; align-items: center; justify-content: space-between; position: relative; height: 28px; margin: 3px 0; font-size: 14px; border-radius: 3px; }
.bar-row .bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar); border-radius: 3px; transition: width .35s ease; max-width: 100%; }
.bar-row:hover .bar-fill { background: var(--bar-hover); }
.bar-row .bar-label { position: relative; z-index: 1; padding: 0 8px; flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.bar-row .bar-label a, .bar-row .bar-label button { color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; padding: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-label a:hover, .bar-row .bar-label button:hover { text-decoration: underline; }
.bar-row .ext-link { color: var(--muted-2); display: inline-flex; flex: none; }
.bar-row .ext-link:hover { color: var(--accent-ink); }
.bar-row .bar-vals { position: relative; z-index: 1; display: flex; gap: 16px; padding-right: 8px; font-weight: 600; }
.bar-row .bar-vals span { min-width: 56px; text-align: right; }
.bar-row .bar-vals .sub { color: var(--muted); font-weight: 500; }
.flag { font-size: 16px; line-height: 1; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(33,41,52,.55); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow: auto; }
.modal { background: var(--bg-elev); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 900px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 17px; margin: 0; }
.modal-body { padding: 12px 22px 20px; overflow: auto; }
.modal-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.modal-table th { text-align: right; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.modal-table th:first-child { text-align: left; }
.modal-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.modal-table td:first-child { text-align: left; white-space: normal; word-break: break-all; }
.modal-table td:first-child button { background: none; border: 0; font: inherit; color: var(--text); cursor: pointer; padding: 0; text-align: left; }
.modal-table td:first-child button:hover { text-decoration: underline; }
.modal-search { margin-bottom: 10px; }
.modal-foot { display: flex; justify-content: center; padding-top: 14px; }
.kbd-table td { padding: 5px 10px; }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
  .dash-topbar { grid-template-columns: 1fr; }
  .dash-topbar-right { justify-self: start; }
  .user-name { display: none; }
}
@media (max-width: 600px) {
  .page { padding: 16px 12px 32px; }
  .card { padding: 16px; }
  .auth-page .card { padding: 22px; }
  .top-stats { padding: 6px 6px 0; gap: 0; }
  .top-stat { flex-basis: 33.333%; padding: 8px 8px 10px; }
  .top-stat .ts-value { font-size: 20px; }
  .top-stat .ts-label { font-size: 12px; white-space: normal; line-height: 1.2; }
  .top-stat .ts-compare { display: none; }
  .graph-wrap { height: 220px; }
  .dash-domain { font-size: 19px; max-width: 220px; }
  .site-switcher { display: none; }
  .filter-menu-grid { grid-template-columns: 1fr; }
  .filter-menu { min-width: 260px; }
  .site-grid { grid-template-columns: 1fr; }
}
