/* Inter (variable, self-hosted; SIL OFL 1.1 — see fonts/OFL.txt) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/admin_static/fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/admin_static/fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('/admin_static/fonts/inter-latin-wght-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
  --bg: #0f1117;
  --sidebar-bg: #161b27;
  --card-bg: #1c2333;
  --border: #2a3347;
  --accent: #FF6B35;
  --accent-hover: #e85a24;
  --text-1: #e8eaf0;
  --text-2: #9aa4b8;
  --text-3: #8a94a8;
  --green: #22c55e;
  --red: #f87171;
  --yellow: #f59e0b;
  --radius: 10px;
  --sidebar-w: 220px;
  --sidebar-cw: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text-1); min-height: 100vh; font-size: 14px; }

/* ── Login ─────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem 2rem; width: 100%; max-width: 380px; }
.login-logo { display: flex; align-items: center; gap: .6rem; margin-bottom: 2rem; }
.login-logo svg { height: 32px; width: auto; color: var(--text-1); }
.login-logo span { font-size: 1.1rem; font-weight: 700; color: var(--text-1); }
.login-card h1 { font-size: 1.1rem; font-weight: 600; margin-bottom: .3rem; }
.login-card p { color: var(--text-2); font-size: .85rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; color: var(--text-2); margin-bottom: .4rem; font-weight: 500; }
.form-group input { width: 100%; height: 40px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0 .9rem; color: var(--text-1); font-size: .9rem; outline: none; }
.form-group input:focus { border-color: var(--accent); }
.btn-primary { width: 100%; height: 42px; background: var(--accent); color: #0F2247; border: none; border-radius: 8px; font-size: .92rem; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: var(--accent-hover); }
.login-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; border-radius: 8px; padding: .6rem .9rem; font-size: .83rem; margin-bottom: 1rem; }

/* ── Layout ────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  transition: width .2s ease; overflow: hidden;
}
.sidebar-logo { display: flex; align-items: center; gap: .6rem; padding: 1.25rem 1.1rem; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.sidebar-logo svg { height: 28px; width: auto; flex-shrink: 0; color: var(--text-1); }
.sidebar-logo span { font-size: .95rem; font-weight: 700; color: var(--text-1); transition: opacity .15s; }
.sidebar-logo small { font-size: .68rem; color: var(--text-2); margin-left: .2rem; }

/* Toggle button */
.sidebar-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 32px; background: transparent; border: none;
  border-bottom: 1px solid var(--border); cursor: pointer;
  color: var(--text-3); transition: background .15s, color .15s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.04); color: var(--text-2); }
.sidebar-toggle .toggle-icon { width: 16px; height: 16px; transition: transform .2s ease; }

.sidebar-nav { flex: 1; padding: .75rem 0; overflow: hidden; }
.nav-item { display: flex; align-items: center; gap: .65rem; padding: .6rem 1.1rem; color: var(--text-2); text-decoration: none; font-size: .85rem; font-weight: 500; transition: background .15s, color .15s; white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text-1); }
.nav-item.active { background: rgba(255,107,53,.12); color: var(--accent); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-label { transition: opacity .15s; }
.sidebar-footer { padding: .75rem 1.1rem; border-top: 1px solid var(--border); overflow: hidden; }
.sidebar-footer a { display: flex; align-items: center; gap: .55rem; min-height: 28px; color: var(--text-3); font-size: .8rem; text-decoration: none; white-space: nowrap; }
.sidebar-footer a:hover { color: var(--text-2); }
.sidebar-footer .footer-icon { display: none; }

/* ── Sidebar collapsed: instant on load (no transition flash) ─ */
[data-sb="0"] .sidebar { width: var(--sidebar-cw) !important; transition: none !important; }
[data-sb="0"] .main    { margin-left: var(--sidebar-cw) !important; transition: none !important; }
[data-sb="0"] .nav-label,
[data-sb="0"] .sidebar-logo span { opacity: 0 !important; width: 0 !important; overflow: hidden !important; }
[data-sb="0"] .sidebar-logo { justify-content: center !important; padding: 1.25rem 0 !important; }
[data-sb="0"] .nav-item { justify-content: center !important; padding: .6rem 0 !important; }
[data-sb="0"] .sidebar-footer a { justify-content: center !important; padding: 0 !important; }
[data-sb="0"] .sidebar-footer .footer-icon { display: block !important; }
[data-sb="0"] .toggle-icon { transform: rotate(180deg) !important; }

/* ── Collapsed state ───────────────────────────────────────── */
.sidebar.collapsed { width: var(--sidebar-cw); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-logo span { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 1.25rem 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: .6rem 0; }
.sidebar.collapsed .sidebar-footer a { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-footer .footer-icon { display: block; }
.sidebar.collapsed .toggle-icon { transform: rotate(180deg); }

.main { margin-left: var(--sidebar-w); flex: 1; padding: 2rem; transition: margin-left .2s ease; }
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-cw); }
.page-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--text-1); }

/* ── Stats grid ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.stat-label { font-size: .75rem; color: var(--text-2); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--text-1); line-height: 1; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green); }

/* ── Live bar ──────────────────────────────────────────────── */
.live-bar { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.75rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); flex-shrink: 0; }
.live-dot.busy { background: var(--red); box-shadow: 0 0 6px var(--red); }
.live-label { font-size: .85rem; color: var(--text-2); }
.live-label strong { color: var(--text-1); }
.live-slots { display: flex; gap: .35rem; margin-left: auto; }
.slot { width: 22px; height: 22px; border-radius: 5px; background: var(--border); }
.slot.active { background: var(--green); }

/* ── Chart ─────────────────────────────────────────────────── */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.75rem; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.card-title { font-size: .8rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 1rem; }
.bar-chart { display: flex; align-items: flex-end; gap: .4rem; height: 80px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; height: 100%; justify-content: flex-end; }
.bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; transition: height .3s; }
.bar-lbl { font-size: .65rem; color: var(--text-2); white-space: nowrap; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header { padding: .85rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.table-header .card-title { margin: 0; }
table { width: 100%; border-collapse: collapse; }
th { padding: .65rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.02); }
td { padding: .7rem 1rem; font-size: .83rem; border-bottom: 1px solid var(--border); color: var(--text-1); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 5px; font-size: .72rem; font-weight: 600; }
.badge.used { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge.unused { background: rgba(34,197,94,.12); color: #86efac; }
.badge.demo { background: rgba(245,158,11,.12); color: #fcd34d; }
.badge.paid { background: rgba(34,197,94,.12); color: #86efac; }
.mono { font-family: 'Courier New', monospace; font-size: .8rem; }
.text-2 { color: var(--text-2); }
.text-xs { font-size: .75rem; }

/* ── Actions ───────────────────────────────────────────────── */
.btn-sm { display: inline-flex; align-items: center; gap: .3rem; height: 28px; padding: 0 .7rem; border-radius: 6px; font-size: .76rem; font-weight: 600; border: none; cursor: pointer; }
.btn-sm.danger { background: rgba(239,68,68,.15); color: #fca5a5; }
.btn-sm.danger:hover { background: rgba(239,68,68,.25); }
.btn-sm.warn { background: rgba(245,158,11,.12); color: #fcd34d; }
.btn-sm.warn:hover { background: rgba(245,158,11,.22); }
.btn-sm.ok { background: rgba(34,197,94,.12); color: #86efac; }
.btn-sm.ok:hover { background: rgba(34,197,94,.22); }
.btn-accent { background: var(--accent); color: #0F2247; height: 36px; padding: 0 1rem; border-radius: 8px; font-size: .85rem; font-weight: 600; border: none; cursor: pointer; }
.btn-accent:hover { background: var(--accent-hover); }

/* ── Generate form ─────────────────────────────────────────── */
.gen-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.gen-form .fg { display: flex; flex-direction: column; gap: .3rem; }
.gen-form label { font-size: .75rem; color: var(--text-2); font-weight: 500; }
.gen-form input { height: 36px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0 .8rem; color: var(--text-1); font-size: .85rem; outline: none; min-width: 200px; }
.gen-form input:focus { border-color: var(--accent); }

/* ── Filter tabs ───────────────────────────────────────────── */
.filter-tabs { display: flex; gap: .4rem; }
.filter-tab { padding: .3rem .75rem; border-radius: 6px; font-size: .78rem; font-weight: 500; text-decoration: none; color: var(--text-2); background: transparent; border: 1px solid transparent; }
.filter-tab:hover { color: var(--text-1); background: rgba(255,255,255,.04); }
.filter-tab.active { background: rgba(255,107,53,.12); color: var(--accent); border-color: rgba(255,107,53,.2); }

/* ── Flash ─────────────────────────────────────────────────── */
.flash { padding: .7rem 1.2rem; border-radius: 8px; margin-bottom: 1.25rem; font-size: .85rem; }
.flash.ok { background: rgba(34,197,94,.12); color: #86efac; border: 1px solid rgba(34,197,94,.2); }
.flash.err { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }

/* ── Empty state ───────────────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-2); font-size: .88rem; }

/* ═══════════════════════════════════════════════════════════════
   ANALYTICS DASHBOARD — new classes (added for redesign)
   ═══════════════════════════════════════════════════════════════ */

/* Live pulse animation */
@keyframes livepulse { 0%,100%{opacity:1;transform:scale(1);} 50%{opacity:.4;transform:scale(.85);} }
@keyframes feedIn    { from{opacity:0;transform:translateY(-4px);} to{opacity:1;transform:none;} }
@keyframes countUp   { from{opacity:0;transform:translateY(6px);} to{opacity:1;transform:none;} }

/* Analytics header */
.analytics-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem; margin-bottom: 1.4rem;
}
.analytics-header .page-title { margin-bottom: .2rem; }
.analytics-subtitle { color: var(--text-2); font-size: .82rem; }
.analytics-header-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* Live badge */
.live-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.2);
  color: #22c55e; border-radius: 20px; padding: .28rem .8rem;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.live-pulse {
  width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  flex-shrink: 0; animation: livepulse 1.4s infinite; display: inline-block;
}

/* Period tabs */
.period-tabs { display: flex; gap: .25rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: .2rem; }
.period-tab {
  padding: .28rem .75rem; border-radius: 6px; font-size: .76rem;
  font-weight: 600; border: none; background: transparent; color: var(--text-2);
  cursor: pointer; transition: background .12s, color .12s;
}
.period-tab.active { background: var(--accent); color: #0F2247; }
.period-tab:hover:not(.active) { color: var(--text-1); }

/* KPI Spark Row */
.kpi-spark-row {
  display: grid; grid-template-columns: repeat(6,1fr);
  gap: .75rem; margin-bottom: 1rem;
}
@media (max-width: 1380px) { .kpi-spark-row { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 740px)  { .kpi-spark-row { grid-template-columns: repeat(2,1fr); } }

/* KPI card */
.kpi-spark-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1rem .7rem;
  min-width: 0; overflow: hidden; position: relative;
  transition: border-color .2s, box-shadow .2s;
  border-left: 3px solid transparent;
}
.kpi-spark-card:hover {
  border-color: rgba(255,107,53,.3);
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
}
.ksc-orange { border-left-color: var(--accent) !important; }
.ksc-green  { border-left-color: var(--green)  !important; }
.ksc-blue   { border-left-color: #818cf8 !important; }
.ksc-yellow { border-left-color: #f59e0b !important; }
.ksc-teal   { border-left-color: #14b8a6 !important; }

/* KPI icon badge */
.kpi-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-icon-orange { background: rgba(255,107,53,.15); color: var(--accent); }
.kpi-icon-green  { background: rgba(34,197,94,.12);  color: #22c55e; }
.kpi-icon-blue   { background: rgba(129,140,248,.12); color: #818cf8; }
.kpi-icon-yellow { background: rgba(245,158,11,.12);  color: #f59e0b; }
.kpi-icon-teal   { background: rgba(20,184,166,.12);  color: #14b8a6; }
.kpi-icon-live   { background: rgba(34,197,94,.1);    color: #22c55e; }

/* KPI text */
.kpi-label {
  font-size: .68rem; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .35rem;
}
.kpi-val { font-size: 1.5rem; font-weight: 800; color: var(--text-1); line-height: 1; animation: countUp .4s ease; }
.kpi-val.kpi-orange { color: var(--accent); }
.kpi-val.kpi-green  { color: var(--green); }
.kpi-val.kpi-blue   { color: #818cf8; }
.kpi-sub { font-size: .7rem; color: var(--text-2); margin-top: .3rem; }

/* Trend badge */
.trend-badge {
  display: inline-flex; align-items: center; gap: .18rem;
  padding: .16rem .48rem; border-radius: 20px;
  font-size: .67rem; font-weight: 700; letter-spacing: .01em; flex-shrink: 0;
}
.trend-badge.up   { background: rgba(34,197,94,.12);  color: #22c55e; }
.trend-badge.down { background: rgba(239,68,68,.12);   color: #f87171; }
.trend-badge.flat { background: rgba(122,132,153,.1);  color: #7a8499; }

/* Sparkline at bottom edge of card (full-width) */
.kpi-spark-bottom { margin: .55rem -1rem -.7rem; overflow: hidden; }
.kpi-spark-bottom svg { display: block; width: 100%; }

/* Dashboard grid rows */
.dash-row-2     { display: grid; grid-template-columns: 65fr 35fr; gap: 1rem; margin-bottom: 1rem; }
.dash-row-2-rev { display: grid; grid-template-columns: 35fr 65fr; gap: 1rem; margin-bottom: 1rem; }
.dash-row-3     { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.dash-row-4     { display: grid; grid-template-columns: 3fr 2fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1100px) {
  .dash-row-2, .dash-row-2-rev, .dash-row-4 { grid-template-columns: 1fr; }
  .dash-row-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) { .dash-row-3 { grid-template-columns: 1fr; } }

/* Data card */
.t-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem; min-width: 0;
  transition: border-color .2s, box-shadow .2s;
}
.t-card:hover {
  border-color: rgba(255,107,53,.2);
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
}
.t-card-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .85rem; gap: .5rem; flex-wrap: wrap;
}
.t-card-title {
  font-size: .72rem; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em;
}

/* Chart legend */
.chart-legend { display: flex; gap: .9rem; }
.leg-item { display: flex; align-items: center; gap: .3rem; font-size: .72rem; color: var(--text-2); }
.leg-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Chart SVG wrapper */
.chart-wrap { width: 100%; overflow: hidden; position: relative; }
.chart-wrap svg { display: block; width: 100%; }

/* Funnel */
.funnel-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .55rem; }
.funnel-icon {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.funnel-icon svg { width: 13px; height: 13px; }
.funnel-lbl {
  width: 115px; font-size: .73rem; color: var(--text-2);
  flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.funnel-track { flex: 1; background: var(--border); border-radius: 5px; height: 20px; overflow: hidden; min-width: 0; }
.funnel-fill {
  height: 100%; border-radius: 5px; display: flex; align-items: center;
  padding: 0 7px; transition: width .5s cubic-bezier(.25,.46,.45,.94);
}
.funnel-fill span { font-size: .69rem; font-weight: 700; color: #fff; background: rgba(10,12,20,.55); padding: .05rem .4rem; border-radius: 4px; white-space: nowrap; }
.funnel-pct  { width: 38px; font-size: .68rem; color: var(--text-2); text-align: right; flex-shrink: 0; }
.funnel-note { font-size: .7rem; color: var(--text-3); margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--border); }

/* Traffic sources */
.source-row {
  position: relative; padding: .32rem .55rem; border-radius: 6px;
  overflow: hidden; margin-bottom: .35rem; transition: background .12s;
}
.source-row:hover { background: rgba(255,255,255,.04); }
.source-bg    { position: absolute; inset: 0; border-radius: 6px; transition: width .5s cubic-bezier(.25,.46,.45,.94); }
.source-inner { position: relative; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.source-host  { font-size: .78rem; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-cnt   { font-size: .76rem; color: var(--text-2); flex-shrink: 0; font-weight: 600; }

/* Donut chart */
.donut-wrap     { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding-top: .2rem; }
.donut-legend   { display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.donut-leg-item { display: flex; align-items: center; gap: .45rem; font-size: .76rem; }
.donut-leg-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-leg-label{ color: var(--text-2); flex: 1; }
.donut-leg-val  { font-weight: 700; color: var(--text-1); min-width: 2.5rem; text-align: right; }
.donut-center-label {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut-center-val { font-size: .85rem; font-weight: 800; color: var(--text-1); line-height: 1; }
.donut-center-sub { font-size: .52rem; color: var(--text-2); margin-top: 2px; }

/* Health */
.health-status { display: flex; align-items: center; gap: .55rem; }
.health-dot    { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; transition: background .3s, box-shadow .3s; }
.health-val    { font-size: 1.4rem; font-weight: 800; color: var(--text-1); }

/* Quick stats */
.quick-stats { display: flex; flex-direction: column; }
.qs-row { display: flex; align-items: center; justify-content: space-between; padding: .52rem 0; border-bottom: 1px solid var(--border); }
.qs-row:last-child { border-bottom: none; }
.qs-label { font-size: .8rem; color: var(--text-2); display: flex; align-items: center; gap: .4rem; }
.qs-val   { font-size: .95rem; font-weight: 700; color: var(--text-1); }
.qs-val.qs-orange { color: var(--accent); }
.qs-val.qs-green  { color: var(--green); }

/* Top events */
.event-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .48rem 0; border-bottom: 1px solid var(--border);
}
.event-row:last-child { border-bottom: none; }
.event-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.event-icon svg { width: 14px; height: 14px; }
.event-label { font-size: .8rem; color: var(--text-1); font-weight: 500; flex: 1; }
.event-count { font-size: .85rem; font-weight: 700; color: var(--text-1); }

/* Live events feed */
.live-feed { max-height: 190px; overflow-y: auto; }
.live-feed::-webkit-scrollbar { width: 3px; }
.live-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.feed-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .38rem 0; border-bottom: 1px solid rgba(42,51,71,.5);
  animation: feedIn .25s ease;
}
.feed-row:last-child { border-bottom: none; }
.feed-dot  { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.feed-label{ font-size: .76rem; color: var(--text-2); flex: 1; }
.feed-time { font-size: .67rem; color: var(--text-3); flex-shrink: 0; }

/* Traffic page 3-col bottom */
.t-bottom3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .t-bottom3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .t-bottom3 { grid-template-columns: 1fr; } }
.badge.refunded { background: rgba(168,85,247,.16); color: #d8b4fe; }

/* ── Support nav badge, toasts, install/notify buttons ─────────────────── */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #dc2626; color: #fff; font-size: .7rem; font-weight: 700; display: inline-grid; place-items: center; }
.nav-badge[hidden] { display: none; }
.footer-btn { display: flex; align-items: center; gap: .55rem; width: 100%; background: none; border: 0; color: var(--text-2); font: inherit; font-size: .8rem; padding: .3rem 0 .6rem; cursor: pointer; text-align: left; white-space: nowrap; }
.footer-btn:hover { color: var(--text-1); }
.footer-btn[hidden] { display: none; }
.footer-btn:disabled { opacity: .6; cursor: default; }
.toast-host { position: fixed; top: 14px; right: 14px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 28px)); }
.toast { display: flex; flex-direction: column; gap: 2px; background: var(--card-bg); color: var(--text-1); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; text-decoration: none; box-shadow: 0 10px 30px rgba(0,0,0,.45); transition: opacity .3s, transform .3s; }
.toast strong { font-size: .86rem; }
.toast span { font-size: .8rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.out { opacity: 0; transform: translateY(-6px); }

/* ── Phone layout: the sidebar becomes a bottom tab bar (installed PWA) ──── */
@media (max-width: 820px) {
  .sidebar { top: auto; bottom: 0; width: 100% !important; height: calc(58px + env(safe-area-inset-bottom)); flex-direction: row; border-right: 0; border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 1500; }
  .sidebar-logo, .sidebar-toggle, .sidebar-footer { display: none; }
  .sidebar-nav { display: flex; flex: 1; padding: 0; overflow-x: auto; }
  .nav-item { flex: 1; flex-direction: column; justify-content: center; gap: .15rem; padding: .35rem .2rem; font-size: .66rem; position: relative; min-width: 62px; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-badge { position: absolute; top: 4px; left: 52%; margin: 0; }
  .main, .sidebar.collapsed ~ .main { margin-left: 0 !important; padding: 1rem 1rem calc(78px + env(safe-area-inset-bottom)); }
  [data-sb="0"] .main { margin-left: 0 !important; }
  [data-sb="0"] .sidebar { width: 100% !important; }
  .toast-host { top: calc(10px + env(safe-area-inset-top)); }
}

/* ── Support inbox ─────────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.main:has(.sp) { padding: 0; }
.sp { display: grid; grid-template-columns: 320px minmax(0,1fr); height: 100vh; }
.sp.client-open { grid-template-columns: 300px minmax(0,1fr) 320px; }
.sp button, .sp input, .sp textarea, .sp select, .sp-dialog button, .sp-dialog input, .sp-dialog textarea { font: inherit; }
.sp-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--sidebar-bg); }
.sp-list-head { padding: 1rem 1rem .6rem; display: flex; flex-direction: column; gap: .7rem; }
.sp-title-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sp-title { font-size: 1.1rem; margin: 0; color: var(--text-1); }
.sp-presence { display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem; color: var(--text-2); }
.sp-presence i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.sp-presence.offline i { background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.sp-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: .4rem; }
.sp-stats div { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .5rem; display: flex; flex-direction: column; }
.sp-stats b { font-size: 1rem; color: var(--text-1); }
.sp-stats span { font-size: .66rem; color: var(--text-2); }
.sp-tabs { display: flex; gap: .3rem; }
.sp-tabs button { flex: 1; background: transparent; color: var(--text-2); border: 1px solid var(--border); border-radius: 8px; padding: .4rem; font-size: .78rem; cursor: pointer; }
.sp-tabs button.active { background: var(--accent); border-color: var(--accent); color: #0F2247; }
.sp-search, .sp-inline input, .sp-canned-form input, .sp-canned-form textarea, #clNotes, #spInput, #spCanned { width: 100%; background: var(--bg); color: var(--text-1); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; font-size: .85rem; }
.sp-search:focus, .sp-inline input:focus, #clNotes:focus, #spInput:focus, #spCanned:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sp-items { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.sp-item { width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--border); padding: .75rem 1rem; cursor: pointer; color: var(--text-1); display: block; }
.sp-item:hover, .sp-item.active { background: var(--card-bg); }
.sp-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sp-item-top, .sp-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sp-item-top strong { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item.unread strong { color: #fff; }
.sp-item-top time { font-size: .68rem; color: var(--text-2); flex-shrink: 0; }
.sp-item-bottom span:first-child { font-size: .78rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sp-item.unread .sp-item-bottom span:first-child { color: var(--text-1); }
.sp-dot { background: #dc2626; color: #fff; font-size: .66rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; }
.sp-chip { font-size: .66rem; padding: .1rem .45rem; border-radius: 999px; background: rgba(148,163,184,.15); color: var(--text-2); white-space: nowrap; }
.sp-chip.used { background: rgba(34,197,94,.12); color: #86efac; }
.sp-chip.unused { background: rgba(245,158,11,.12); color: #fcd34d; }
.sp-chip.refunded, .sp-chip.partially-refunded { background: rgba(239,68,68,.15); color: #fca5a5; }
.sp-empty, .sp-muted { color: var(--text-2); font-size: .8rem; }
.sp-empty { padding: 1.2rem 1rem; }
.sp-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; }
.sp-placeholder { margin: auto; text-align: center; color: var(--text-2); }
.sp-conv { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sp-conv[hidden], .sp-placeholder[hidden], .sp-client[hidden] { display: none; }
.sp-conv-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.sp-conv-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sp-conv-who strong { color: var(--text-1); }
.sp-conv-who span { font-size: .74rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-conv-actions { display: flex; gap: .4rem; }
.sp-conv-actions .btn-sm:not(.warn):not(.danger):not(.ok), .sp-canned-row .btn-sm, .sp-dialog .btn-sm { background: var(--card-bg); color: var(--text-1); border: 1px solid var(--border); }
.sp-back { display: none; background: none; border: 0; color: var(--text-1); font-size: 1.3rem; cursor: pointer; }
.sp-msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.sp-msg { max-width: min(560px, 82%); display: flex; flex-direction: column; gap: 2px; }
.sp-msg.visitor { align-self: flex-start; }
.sp-msg.admin { align-self: flex-end; align-items: flex-end; }
.sp-msg.system { align-self: center; max-width: 90%; }
.sp-bubble { padding: .55rem .8rem; border-radius: 14px; font-size: .88rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.sp-msg.visitor .sp-bubble { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-1); border-bottom-left-radius: 4px; }
.sp-msg.admin .sp-bubble { background: var(--accent); color: #0F2247; border-bottom-right-radius: 4px; }
.sp-msg.system .sp-bubble { background: transparent; color: var(--text-2); font-size: .78rem; text-align: center; }
.sp-meta { font-size: .66rem; color: var(--text-2); }
.sp-typing { padding: 0 1rem .4rem; font-size: .76rem; color: var(--text-2); }
.sp-composer { border-top: 1px solid var(--border); padding: .7rem 1rem calc(.8rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .5rem; }
.sp-canned-row { display: flex; gap: .5rem; }
.sp-canned-row select { flex: 1; }
.sp-compose-row { display: flex; gap: .6rem; align-items: flex-end; }
.sp-compose-row textarea { resize: none; flex: 1; }
.sp-compose-row .btn-primary, .sp-canned-form .btn-primary { width: auto; padding: 0 1.4rem; }
.sp-error { color: #fca5a5; font-size: .8rem; margin: 0; }
.sp-error[hidden] { display: none; }
.sp-client { border-left: 1px solid var(--border); padding: 1rem; overflow-y: auto; height: 100vh; background: var(--sidebar-bg); position: relative; }
.sp-client h2 { font-size: 1rem; margin: 0 0 .6rem; color: var(--text-1); }
.sp-client h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 1.1rem 0 .4rem; }
.sp-client h3 small { text-transform: none; letter-spacing: 0; }
.sp-client-close { position: absolute; top: .6rem; right: .7rem; background: none; border: 0; color: var(--text-2); font-size: 1.4rem; cursor: pointer; }
.sp-dl { display: grid; grid-template-columns: 90px 1fr; gap: .3rem .6rem; margin: 0; font-size: .8rem; }
.sp-dl dt { color: var(--text-2); }
.sp-dl dd { margin: 0; color: var(--text-1); overflow-wrap: anywhere; }
.sp-orders, .sp-pages, .sp-prev, .sp-canned-list { list-style: none; margin: 0; padding: 0; font-size: .8rem; display: flex; flex-direction: column; gap: .45rem; color: var(--text-1); }
.sp-order { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; }
.sp-order-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.sp-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font-size: .78rem; }
.sp-link:hover { text-decoration: underline; }
.sp-inline { display: flex; gap: .4rem; margin-top: .5rem; }
.sp-issue { margin-top: .5rem; }
#clNotes { resize: vertical; }
.sp-dialog { background: var(--card-bg); color: var(--text-1); border: 1px solid var(--border); border-radius: 12px; padding: 1.2rem; width: min(560px, calc(100vw - 2rem)); max-height: 85vh; }
.sp-dialog::backdrop { background: rgba(0,0,0,.6); }
.sp-dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.sp-dialog-head h2 { margin: 0; font-size: 1.05rem; }
.sp-canned-list li { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; }
.sp-canned-list p { margin: .2rem 0 .5rem; white-space: pre-wrap; }
.sp-row { display: flex; gap: .4rem; }
.sp-canned-form { display: flex; flex-direction: column; gap: .4rem; margin-top: 1rem; }
.sp-canned-form label { font-size: .78rem; color: var(--text-2); }
.sp-dialog-actions { display: flex; gap: .5rem; margin-top: .4rem; }

@media (max-width: 1180px) {
  .sp.client-open { grid-template-columns: 280px minmax(0,1fr); }
  .sp-client { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); z-index: 1600; box-shadow: -10px 0 30px rgba(0,0,0,.5); }
}
@media (max-width: 820px) {
  .sp, .sp.client-open { grid-template-columns: 1fr; height: calc(100dvh - 58px - env(safe-area-inset-bottom)); }
  .sp-list, .sp-thread { height: 100%; }
  .sp .sp-thread { display: none; }
  .sp.conv-open .sp-list { display: none; }
  .sp.conv-open .sp-thread { display: flex; }
  .sp-back { display: inline-block; }
  .sp-client { height: auto; }
}
.sp-msg.system { align-items: center; }
.sp-msg.system .sp-meta { display: none; }

/* ── Support: muted, spam, banners ─────────────────────────────────────── */
.nav-badge.spam { margin-left: 4px; background: #b45309; }
.sp-tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #b45309; color: #fff; font-size: .68rem; font-weight: 700; }
.sp-tab-count[hidden] { display: none; }
.sp-tabs button { padding: .4rem .2rem; font-size: .74rem; }
.sp-dot.quiet { background: #64748b; }
.sp-item.muted .sp-item-top strong { opacity: .7; }
.sp-chip.spam { background: rgba(245,158,11,.15); color: #fcd34d; }
.sp-banner { padding: .5rem 1rem; font-size: .8rem; color: var(--text-2); background: var(--card-bg); border-bottom: 1px solid var(--border); }
.sp-banner.spam { color: #fcd34d; background: rgba(245,158,11,.08); }
.sp-banner[hidden] { display: none; }
.sp-conv-actions { flex-wrap: wrap; justify-content: flex-end; }

/* ── Notification banner (all screen sizes) ───────────────────────────── */
.push-banner { position: fixed; right: 16px; bottom: 16px; z-index: 2500; width: min(380px, calc(100vw - 32px)); background: var(--card-bg); color: var(--text-1); border: 2px solid var(--accent); border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 10px; font-size: .86rem; line-height: 1.45; }
.push-banner[hidden] { display: none; }
.push-banner-actions { display: flex; gap: 8px; }
.push-banner button { font: inherit; font-weight: 700; border-radius: 8px; min-height: 40px; padding: 0 14px; cursor: pointer; }
.push-go { background: var(--accent); color: #0F2247; border: 0; flex: 1; }
.push-later { background: transparent; color: var(--text-1); border: 1px solid var(--border); }
@media (max-width: 820px) { .push-banner { left: 12px; right: 12px; width: auto; bottom: calc(70px + env(safe-area-inset-bottom)); } }

/* iOS zooms into any field whose text is smaller than 16px: keep fields at 16px on touch screens */
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }
