/* ============ CSS Variables: themes ============ */
:root {
  --bg: #f4f5fa;
  --bg-elev: #ffffff;
  --bg-soft: #eef0f7;
  --bg-hover: #f7f8fc;
  --border: #e3e6ef;
  --border-strong: #d1d5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --brand: #e11d74;
  --brand-soft: #fce7f3;
  --brand-2: #8b5cf6;
  --brand-3: #0ea5e9;

  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #e0f2fe;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 64px;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --chart-grid: rgba(15, 23, 42, 0.06);
  --chart-axis: #94a3b8;
  --chart-text: #475569;
}

:root[data-theme="dark"] {
  --bg: #0a0f1f;
  --bg-elev: #111832;
  --bg-soft: #161e3a;
  --bg-hover: #1a234a;
  --border: #263055;
  --border-strong: #344273;
  --text: #eef2ff;
  --text-muted: #a3aed0;
  --text-dim: #6b769d;

  --brand: #f472b6;
  --brand-soft: rgba(244, 114, 182, 0.15);
  --brand-2: #a78bfa;
  --brand-3: #38bdf8;

  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);

  --chart-grid: rgba(148, 163, 184, 0.12);
  --chart-axis: #6b769d;
  --chart-text: #a3aed0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ============ App layout ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
.app.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ============ Sidebar ============ */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}
.sb-brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sb-brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-collapse {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 7px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.sb-collapse:hover { background: var(--bg-soft); color: var(--text); }
.sb-collapse svg { width: 16px; height: 16px; transition: transform 0.2s; }
.app.sidebar-collapsed .sb-collapse svg { transform: rotate(180deg); }

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}
.sb-group-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 12px 6px;
}
.sb-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.sb-link:hover { background: var(--bg-soft); color: var(--text); }
.sb-link.active {
  background: var(--brand-soft);
  color: var(--brand);
}
.sb-link.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.sb-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sb-link-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.app.sidebar-collapsed .sb-link-label,
.app.sidebar-collapsed .sb-brand > div:not(.sb-brand-mark),
.app.sidebar-collapsed .sb-group-title { display: none; }
.app.sidebar-collapsed .sb-link { justify-content: center; padding: 10px; }
.app.sidebar-collapsed .sb-link.active::before { display: none; }

.sb-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-foot a { color: var(--brand); font-weight: 600; }
.app.sidebar-collapsed .sb-foot { display: none; }

/* ============ Main area ============ */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============ Topbar (global filters) ============ */
.topbar {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.tb-row-1 {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  min-height: var(--topbar-h);
}
.tb-row-2 {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px 10px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
  row-gap: 6px;
}
.tb-title {
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.tb-title small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
}
.tb-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tb-filters .popover-wrap { flex-shrink: 0; }
.tb-spacer { flex: 1; }
.tb-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.filter-btn svg { width: 14px; height: 14px; color: var(--text-muted); }
.filter-btn .tag {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 7px;
  font-weight: 600;
  margin-left: 4px;
}

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: all 0.15s;
  border: 1px solid transparent;
  position: relative;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* Theme toggle: show current-state icon (sun in light mode, moon in dark mode) */
:root[data-theme="light"] #themeToggle .icon-moon { display: none; }
:root[data-theme="dark"]  #themeToggle .icon-sun  { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.user-chip .nm { font-size: 12.5px; font-weight: 600; }
.user-chip .rl { font-size: 11px; color: var(--text-muted); }

/* ============ Content ============ */
.page {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 24px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  font-weight: 700;
}
.page-header .ph-desc {
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 720px;
}
.page-header .ph-actions {
  display: flex; align-items: center; gap: 8px;
}

/* ============ Cards ============ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card.tight { padding: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.card-title small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}
.card-actions { display: flex; gap: 6px; align-items: center; }
.card-sub { color: var(--text-muted); font-size: 12px; }

/* Grid helpers */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1400px) {
  .grid.cols-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  .grid.cols-5 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4, .grid.cols-5, .grid.cols-6 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-5, .grid.cols-6 { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4 { grid-column: span 1; }
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

/* ============ KPI cards ============ */
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-label .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.1;
}
.kpi-value .unit {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 500;
}
.kpi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.kpi-trend.up { color: var(--ok); background: var(--ok-soft); }
.kpi-trend.down { color: var(--bad); background: var(--bad-soft); }
.kpi-trend.flat { color: var(--text-muted); background: var(--bg-soft); }
.kpi-trend svg { width: 10px; height: 10px; }

.kpi-spark {
  height: 36px;
  margin-top: 4px;
}

.kpi.accent-brand .kpi-label .dot { background: var(--brand); }
.kpi.accent-ok .kpi-label .dot { background: var(--ok); }
.kpi.accent-warn .kpi-label .dot { background: var(--warn); }
.kpi.accent-bad .kpi-label .dot { background: var(--bad); }
.kpi.accent-info .kpi-label .dot { background: var(--info); }
.kpi.accent-violet .kpi-label .dot { background: var(--brand-2); }

/* ============ Tables ============ */
.tbl-wrap {
  overflow-x: auto;
  margin: 0 -20px -20px;
  padding: 0 20px 20px;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg-hover); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.center, .tbl th.center { text-align: center; }
.tbl .muted { color: var(--text-muted); }
.tbl .bold { font-weight: 600; }
.tbl tfoot td {
  font-weight: 600;
  background: var(--bg-soft);
  border-top: 2px solid var(--border-strong);
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge.neutral { background: var(--bg-soft); color: var(--text-muted); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.plain::before { display: none; }

/* Progress bar */
.bar {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  transition: width 0.3s ease;
}
.bar-fill.ok { background: linear-gradient(90deg, #10b981, #4ade80); }
.bar-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-fill.bad { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ============ Chart containers ============ */
.chart {
  width: 100%;
  height: 300px;
}
.chart.sm { height: 220px; }
.chart.md { height: 300px; }
.chart.lg { height: 380px; }
.chart.xl { height: 480px; }

/* ============ Funnel row (custom) ============ */
.funnel-stage {
  display: grid;
  grid-template-columns: 200px 1fr 180px;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.funnel-stage:last-child { border-bottom: 0; }
.funnel-stage .fs-name {
  font-weight: 600;
  font-size: 13px;
}
.funnel-stage .fs-name small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  margin-top: 2px;
}
.funnel-stage .fs-bar {
  height: 24px;
  background: var(--bg-soft);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}
.funnel-stage .fs-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  min-width: 60px;
}
.funnel-stage .fs-stats {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--text-muted);
}
.funnel-stage .fs-stats b { color: var(--text); font-weight: 600; }

@media (max-width: 700px) {
  .funnel-stage { grid-template-columns: 1fr; gap: 4px; }
  .funnel-stage .fs-stats { justify-content: flex-start; }
}

/* ============ List with score ============ */
.list-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.list-row:last-child { border-bottom: 0; }
.list-row .rank {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
}
.list-row.top-1 .rank { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #7c2d12; }
.list-row.top-2 .rank { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #1f2937; }
.list-row.top-3 .rank { background: linear-gradient(135deg, #fecaca, #ea580c); color: #7c2d12; }
.list-row .name { font-weight: 600; }
.list-row .sub { font-size: 11.5px; color: var(--text-muted); }
.list-row .val { font-weight: 600; text-align: right; }
.list-row .val small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; }

/* ============ Alerts ============ */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: var(--bg-elev);
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item .alert-ico {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.alert-item.sev-critical { background: color-mix(in srgb, var(--bad) 6%, var(--bg-elev)); border-color: color-mix(in srgb, var(--bad) 30%, var(--border)); }
.alert-item.sev-critical .alert-ico { background: var(--bad-soft); color: var(--bad); }
.alert-item.sev-warning { background: color-mix(in srgb, var(--warn) 6%, var(--bg-elev)); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.alert-item.sev-warning .alert-ico { background: var(--warn-soft); color: var(--warn); }
.alert-item.sev-info .alert-ico { background: var(--info-soft); color: var(--info); }
.alert-item.sev-info { background: color-mix(in srgb, var(--info) 4%, var(--bg-elev)); }
.alert-item .alert-body { flex: 1; min-width: 0; }
.alert-item .alert-title { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.alert-item .alert-msg { font-size: 12.5px; color: var(--text-muted); }
.alert-item .alert-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.alert-item .alert-ico svg { width: 16px; height: 16px; }

/* ============ Generic small helpers ============ */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-3 { margin-top: 12px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.text-brand { color: var(--brand); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.bold { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ============ Inputs ============ */
.input, .select {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  transition: all 0.15s;
  outline: none;
  min-width: 0;
}
.input:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; flex: 1; min-width: 120px; }
.search svg { width: 14px; height: 14px; color: var(--text-muted); }

/* ============ Tabs ============ */
.tabs {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 9px;
  gap: 2px;
}
.tabs button {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.15s;
}
.tabs button.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ============ Map placeholder ============ */
.map-stub {
  width: 100%;
  height: 360px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, var(--bg-soft) 0%, var(--bg-hover) 100%);
  border: 1px dashed var(--border-strong);
}
.map-stub .map-dot {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: 3px solid var(--bg-elev);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 20%, transparent);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform 0.2s;
}
.map-stub .map-dot:hover { transform: translate(-50%, -50%) scale(1.3); }
.map-stub .map-label {
  position: absolute;
  transform: translate(10px, -50%);
  background: var(--bg-elev);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 11.5px;
  white-space: nowrap;
  pointer-events: none;
}
.map-stub::after {
  content: "Карта городов Казахстана · схематично";
  position: absolute;
  bottom: 12px; right: 14px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ============ Avatar ============ */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* ============ Dropdown menu ============ */
.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  display: none;
}
.menu.open { display: block; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.1s;
}
.menu-item:hover { background: var(--bg-soft); }
.menu-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.menu-item .check { margin-left: auto; opacity: 0; }
.menu-item.active .check { opacity: 1; }

.popover-wrap { position: relative; }

/* Mobile sidebar */
@media (max-width: 900px) {
  .app { grid-template-columns: 0 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-w);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .app.mobile-sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app.sidebar-collapsed { grid-template-columns: 0 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
