/* ClickHQ — admin UI */

:root {
  color-scheme: light;
  --page: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --surface-sunken: #f1f1ee;
  --border: rgba(11, 11, 11, 0.08);
  --border-strong: rgba(11, 11, 11, 0.14);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #ecebe6;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --bar: rgba(42, 120, 214, 0.09);
  --good: #006300;
  --good-bg: rgba(12, 163, 12, 0.10);
  --bad: #b42323;
  --bad-bg: rgba(208, 59, 59, 0.10);
  --live: #0ca30c;
  --btn: #0b0b0b;
  --btn-text: #ffffff;
  --focus: 0 0 0 3px rgba(42, 120, 214, 0.28);
  --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.04);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --shadow-pop: 0 12px 40px rgba(11, 11, 11, 0.14), 0 2px 6px rgba(11, 11, 11, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #1f1f1e;
    --surface-sunken: #141413;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --series-1: #3987e5;
    --series-2: #d95926;
    --bar: rgba(57, 135, 229, 0.16);
    --good: #2fbf2f;
    --good-bg: rgba(12, 163, 12, 0.16);
    --bad: #f07272;
    --bad-bg: rgba(208, 59, 59, 0.18);
    --btn: #ffffff;
    --btn-text: #0b0b0b;
    --shadow-sm: none;
    --shadow: none;
    --shadow-pop: 0 16px 48px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
code, pre { font-family: var(--mono); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.secondary { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 28px; height: 60px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: -0.02em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--text); color: var(--page);
}
.brand-mark svg { width: 15px; height: 15px; }
.topbar .divider { width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px; }
.topbar-spacer { flex: 1; }
.nav-link { color: var(--text-2); padding: 7px 10px; border-radius: 8px; font-weight: 500; }
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--surface-sunken); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--btn); color: var(--btn-text); border-color: transparent; }
.btn-primary:hover { background: var(--btn); opacity: .88; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }
.btn-danger { color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; height: 42px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 550; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12.5px; }
.field .error { color: var(--bad); font-size: 12.5px; }
.input, textarea.input, select.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input.has-error { border-color: var(--bad); }
.checkbox { display: inline-flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--text); }

/* ---------- Layout ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 28px 80px; }
.page-narrow { max-width: 760px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 650; line-height: 1.25; }
.page-sub { color: var(--text-2); margin-top: 3px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-title { font-size: 14.5px; font-weight: 620; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin: 34px 0 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Flash ---------- */
.flash {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm);
  margin-bottom: 18px; font-weight: 500; border: 1px solid var(--border);
}
.flash-success { background: var(--good-bg); color: var(--good); border-color: transparent; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* ---------- Popovers / dropdowns ---------- */
.pop { position: relative; }
.pop-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow-pop); padding: 6px; display: none;
}
.pop.open > .pop-panel { display: block; animation: pop-in .12s ease-out; }
.pop-panel.right { left: auto; right: 0; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 0; background: none; text-align: left; cursor: pointer; color: var(--text); font-weight: 500;
}
.pop-item:hover, .pop-item.kbd { background: var(--surface-sunken); }
.pop-item .check { width: 16px; height: 16px; margin-left: auto; color: var(--text); flex: none; }
.pop-item .sub { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.pop-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.pop-search { padding: 4px 4px 6px; }
.pop-search .input { height: 34px; font-size: 13.5px; }
.pop-list { max-height: 340px; overflow: auto; }
.pop-footer { padding: 8px 6px 4px; }

.switcher-btn {
  display: inline-flex; align-items: center; gap: 9px; height: 36px; padding: 0 10px 0 8px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 600; max-width: 320px;
}
.switcher-btn:hover, .pop.open .switcher-btn { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.switcher-btn .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher-btn svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.favicon {
  width: 20px; height: 20px; border-radius: 6px; flex: none; background: var(--surface-sunken);
  display: inline-grid; place-items: center; overflow: hidden; border: 1px solid var(--border);
}
.favicon img { width: 14px; height: 14px; }
.star { color: #eda100; }

/* ---------- Live pill ---------- */
.live-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--surface-sunken); color: var(--text-2); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); position: relative; flex: none; }
.live-pill.is-live .live-dot { background: var(--live); }
.live-pill.is-live .live-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; background: var(--live); opacity: .35;
  animation: pulse 1.8s ease-out infinite;
}
.live-pill.is-live { color: var(--text); }
@keyframes pulse { 0% { transform: scale(.5); opacity: .5; } 100% { transform: scale(1.6); opacity: 0; } }

/* ---------- Filter row ---------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); font-weight: 550; cursor: pointer; box-shadow: var(--shadow-sm);
}
.filter-btn:hover { background: var(--surface-2); }
.filter-btn svg { width: 16px; height: 16px; color: var(--muted); }
.filter-btn .chev { margin-left: 2px; }
.filter-btn.active-filter { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.custom-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 4px 2px; }
.custom-range .input { height: 34px; font-size: 13px; padding: 0 8px; }
.custom-range .btn { grid-column: span 2; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; margin-bottom: 16px; overflow: hidden; }
.kpi { padding: 18px 20px 18px; border-right: 1px solid var(--border); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { color: var(--text-2); font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.025em; margin-top: 6px; line-height: 1.15; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 22px; }
.delta {
  display: inline-flex; align-items: center; gap: 3px; height: 21px; padding: 0 7px; border-radius: 6px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.delta svg { width: 12px; height: 12px; }
.delta.good { color: var(--good); background: var(--good-bg); }
.delta.bad { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--muted); background: var(--surface-sunken); }
.kpi-hint { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3n) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-bottom: 1px solid var(--border); }
  .kpi:nth-child(3n) { border-right: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-right: 0; }
}

/* ---------- Charts ---------- */
.chart-card { padding: 18px 20px 8px; margin-bottom: 16px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.legend { display: flex; align-items: center; gap: 16px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-key { width: 14px; height: 2px; border-radius: 2px; background: currentColor; }
.legend-key.s1 { background: var(--series-1); }
.legend-key.s2 { background: var(--series-2); }
.chart { min-height: 300px; margin: 0 -8px; }
.chart.is-mini { min-height: 150px; margin: 0 -6px -6px; }
.chart-table { margin-top: 8px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 6px 0 10px; list-style: none; }
.chart-table summary::-webkit-details-marker { display: none; }
.chart-table summary:hover { color: var(--text-2); }
.chart-table .table-wrap { max-height: 280px; overflow: auto; border-top: 1px solid var(--border); margin-bottom: 10px; }

/* ApexCharts tooltip, restyled */
.apexcharts-tooltip.apexcharts-theme-light,
.apexcharts-tooltip.apexcharts-theme-dark {
  background: var(--surface) !important; color: var(--text) !important;
  border: 1px solid var(--border-strong) !important; border-radius: 10px !important;
  box-shadow: var(--shadow-pop) !important;
}
.chq-tip { padding: 10px 12px; min-width: 170px; font-family: var(--font); }
.chq-tip-title { color: var(--text-2); font-size: 12px; font-weight: 550; margin-bottom: 7px; }
.chq-tip-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; line-height: 1.9; }
.chq-tip-row .k { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.chq-tip-row .v { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); }
.chq-tip-row .n { color: var(--text-2); }
.apexcharts-xcrosshairs.apexcharts-active { opacity: 1 !important; }
.apexcharts-gridline { stroke: var(--grid); }
.apexcharts-xaxistooltip { display: none !important; }

/* ---------- Report cards (tabbed tables) ---------- */
.report-card { display: flex; flex-direction: column; min-height: 300px; }
.report-card .card-header { padding-bottom: 0; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab {
  border: 0; background: none; cursor: pointer; padding: 5px 9px; border-radius: 7px;
  color: var(--muted); font-weight: 550; font-size: 13px;
}
.tab:hover { color: var(--text); background: var(--surface-sunken); }
.tab.active { color: var(--text); background: var(--surface-sunken); }
.tab-panel { padding: 10px 12px 14px; flex: 1; display: flex; flex-direction: column; }
.rtable { width: 100%; border-collapse: separate; border-spacing: 0 2px; table-layout: fixed; }
.rtable th {
  text-align: right; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; padding: 4px 10px 6px; white-space: nowrap;
}
.rtable th:first-child { text-align: left; }
.rtable td { padding: 0 10px; height: 34px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rtable td:first-child { text-align: left; position: relative; }
.rtable .metric-col { width: 84px; }
.rtable tr.row td:first-child::before {
  content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: var(--w, 0%);
  background: var(--bar); border-radius: 6px; z-index: 0; transition: width .4s ease;
}
.rtable tr.row:hover td { background: var(--surface-2); }
.rtable tr.row:hover td:first-child { border-radius: 7px 0 0 7px; }
.rtable tr.row:hover td:last-child { border-radius: 0 7px 7px 0; }
.cell-label { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.cell-label .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-label .flag { font-size: 15px; line-height: 1; }
.cell-label a.ext { color: var(--muted); display: inline-flex; opacity: 0; transition: opacity .1s; }
.rtable tr.row:hover .cell-label a.ext { opacity: 1; }
.cell-label a.ext svg { width: 13px; height: 13px; }
.rtable tr.clickable { cursor: pointer; }
.rtable tr.extra { display: none; }
.tab-panel.expanded tr.extra { display: table-row; }
.show-more { margin-top: auto; padding-top: 8px; }
.empty {
  flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted);
  padding: 40px 16px; font-size: 13px;
}
.empty svg { width: 22px; height: 22px; margin-bottom: 6px; opacity: .6; }
.card-note { color: var(--muted); font-size: 12px; padding: 0 22px 14px; }

/* ---------- Live panel ---------- */
.live-card { margin-bottom: 16px; }
.live-list { list-style: none; margin: 0; padding: 4px 12px 12px; }
.live-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 7px; }
.live-list li:hover { background: var(--surface-2); }
.live-list .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }

/* ---------- Dashboard ---------- */
.prop-card { padding: 18px 20px 0; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.prop-card:hover { border-color: var(--border-strong); }
.prop-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.prop-name { font-size: 15.5px; font-weight: 620; display: flex; align-items: center; gap: 9px; }
.prop-domain { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.prop-stats { display: flex; gap: 28px; margin: 16px 0 4px; }
.prop-stat .v { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.prop-stat .l { color: var(--text-2); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.prop-stat .l .legend-key { width: 10px; }
.prop-list { overflow: hidden; }
.prop-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.prop-row:last-child { border-bottom: 0; }
.prop-row:hover { background: var(--surface-2); }
.prop-row .grow { flex: 1; min-width: 0; }
.hero-empty { text-align: center; padding: 72px 24px; }
.hero-empty h2 { font-size: 20px; margin-bottom: 6px; }
.hero-empty p { color: var(--text-2); margin: 0 auto 20px; max-width: 420px; }

/* ---------- Settings ---------- */
.settings-section { margin-bottom: 20px; }
.settings-section .card-pad > h2 { font-size: 15.5px; font-weight: 620; margin-bottom: 4px; }
.settings-section .lead { color: var(--text-2); margin: 0 0 18px; }
.code-block {
  position: relative; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 46px 16px 14px; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; color: var(--text);
}
.code-block .copy { position: absolute; top: 8px; right: 8px; }
.inline-code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-sunken); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border); }
.seg-table { width: 100%; border-collapse: collapse; }
.seg-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 0 10px 8px; }
.seg-table td { padding: 11px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.seg-table .link-cell { display: flex; align-items: center; gap: 6px; }
.seg-table .link-cell code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; display: inline-block; }
.seg-table td:last-child .btn { padding: 0 8px; }
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: var(--surface-sunken); color: var(--text-2);
}
.badge-code { font-family: var(--mono); letter-spacing: .02em; color: var(--text); }
.seg-form { display: grid; grid-template-columns: 1.2fr 0.8fr 1.4fr auto; gap: 10px; align-items: start; margin-top: 18px; }
.seg-form .field { margin: 0; }
@media (max-width: 800px) { .seg-form { grid-template-columns: 1fr; } }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, var(--border)); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ""; position: absolute; inset: -40% -20% auto; height: 80vh; pointer-events: none;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 70%);
}
.login-card { width: 100%; max-width: 380px; padding: 32px 30px 26px; position: relative; }
.login-card .brand { font-size: 17px; margin-bottom: 26px; }
.login-card .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
.login-card h1 { font-size: 20px; font-weight: 650; margin-bottom: 4px; }
.login-card .lead { color: var(--text-2); margin: 0 0 22px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 11, 11, .32); z-index: 80; display: grid; place-items: center; padding: 24px;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 560px; max-height: 80vh; overflow: auto; box-shadow: var(--shadow-pop); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-body { padding: 8px 12px 16px; }
.modal h4 { margin: 14px 10px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.loading { opacity: .55; transition: opacity .15s; pointer-events: none; }
.error-page { text-align: center; padding: 120px 24px; }
.error-page .code { font-size: 64px; font-weight: 700; letter-spacing: -0.04em; color: var(--muted); }

/* ---------- Property sub-navigation ---------- */
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -6px 0 20px; }
.subnav a {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px 11px; margin-bottom: -1px;
  color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent;
}
.subnav a svg { width: 15px; height: 15px; opacity: .8; }
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--text); border-bottom-color: var(--text); }
.settings-body { max-width: 820px; }

/* ---------- Shared bits ---------- */
.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }
.inline-icon { width: 11px; height: 11px; vertical-align: -1px; margin-left: 1px; }
.badge-new { background: var(--accent-soft); color: var(--accent); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.seg-tag { color: var(--text-2); font-weight: 550; }
.live-pill.mini { height: 20px; padding: 0 7px; font-size: 11px; margin-left: 6px; gap: 5px; }
.live-pill.mini .live-dot { width: 6px; height: 6px; }
.crumbs { display: flex; align-items: center; gap: 8px; margin: -8px 0 10px -8px; font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text); font-weight: 550; font-size: 13px; max-width: 360px;
}
.chip svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.chip:hover svg { color: var(--text); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px 16px; border-top: 1px solid var(--border); }

/* Linked labels in report tables */
.cell-label a.drill { color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-label a.drill:hover { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }

/* ---------- Visits table ---------- */
.vtable-wrap { overflow-x: auto; }
.vtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.vtable th {
  text-align: left; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 14px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.vtable td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.vtable tr:last-child td { border-bottom: 0; }
.vtable .r { text-align: right; }
.vtable .vrow { cursor: pointer; transition: background .08s; }
.vtable .vrow:hover td { background: var(--surface-2); }
.vtable .vlink { font-weight: 550; }
.vtable .path-cell { max-width: 260px; }
.vtable .path-cell .mono { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visitor-chip { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 12.5px; margin-right: 6px; }
.visitor-chip:hover { text-decoration: underline; text-underline-offset: 3px; }
.visitor-chip.lg { font-size: 13px; margin: 2px 0 12px; word-break: break-all; }
.avatar {
  width: 18px; height: 18px; border-radius: 50%; flex: none; display: inline-block;
  background: linear-gradient(135deg, hsl(var(--h) 70% 62%), hsl(calc(var(--h) + 40) 70% 48%));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.avatar.lg { width: 30px; height: 30px; }

/* ---------- Visit detail ---------- */
.visit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .visit-grid { grid-template-columns: 1fr; } }
.visit-side { display: grid; gap: 16px; }
.side-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.side-kv { grid-template-columns: 104px minmax(0, 1fr); gap: 7px 12px; font-size: 13px; }
.visit-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.visit-stats > div { padding: 16px 20px; border-right: 1px solid var(--border); }
.visit-stats > div:last-child { border-right: 0; }
.stat-v { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 2px; background: var(--grid); border-radius: 2px; }
.timeline > li { position: relative; padding-left: 30px; }
.tl-dot {
  position: absolute; left: 1px; top: 5px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--series-1); box-shadow: 0 0 0 3px var(--surface);
}
.tl-page .tl-dot { background: var(--series-1); }
.tl-page.is-404 .tl-dot { background: var(--bad); border-color: var(--bad); }
.tl-start .tl-dot, .tl-end .tl-dot { border-color: var(--axis); }
.tl-body { padding: 2px 0 18px; min-width: 0; }
.tl-end .tl-body { padding-bottom: 2px; }
.tl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tl-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-title.mono { font-size: 13.5px; }
.tl-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tl-tags .badge { height: 20px; font-size: 11.5px; font-weight: 550; }
.tl-gap { padding: 0 0 14px 30px !important; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tl-event {
  display: flex; gap: 10px; margin-top: 10px; padding: 9px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.ev-icon { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: color-mix(in srgb, var(--series-2) 14%, transparent); color: var(--series-2); flex: none; }
.ev-icon svg { width: 13px; height: 13px; }
.ev-name { font-weight: 600; font-size: 13px; }
.ev-props { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.prop { font-family: var(--mono); font-size: 11.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
