/* ═══════════════════════════════════════════════════════════════
   Cardinal Admin — brand design system
   Fonts: Organetto (display), Anonymous Pro (mono)
   Palette: violet #7B2FF2, dark #0B0B10, grid + radial glow
   ═══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Organetto';
  src: url('/ui/fonts/organetto-bold-exp.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Anonymous Pro';
  src: url('/ui/fonts/AnonymousPro-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Anonymous Pro';
  src: url('/ui/fonts/AnonymousPro-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: #0B0B10;
  --panel: rgba(14, 12, 22, 0.80);
  --panel-solid: #0e0c16;
  --bg-elev: rgba(255, 255, 255, 0.03);
  --elev-2: rgba(20, 22, 26, 0.5);

  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --separator: rgba(255, 255, 255, 0.07);
  --separator-strong: rgba(255, 255, 255, 0.14);

  --text: #e4e4e7;
  --text-secondary: #8a8a94;
  --text-tertiary: #5a5a60;
  --muted: #5a5a60;
  --dim: #1e1c28;

  --control-bg: rgba(255, 255, 255, 0.04);
  --control-bg-hover: rgba(255, 255, 255, 0.08);
  --control-bg-active: rgba(255, 255, 255, 0.12);
  --control-stroke: rgba(255, 255, 255, 0.1);

  --accent: #7B2FF2;
  --accent-hover: #9B50FF;
  --accent-fill: rgba(123, 47, 242, 0.15);
  --accent-dim: rgba(123, 47, 242, 0.15);
  --selection: rgba(123, 47, 242, 0.35);

  --high: #ff3355;
  --high-dim: rgba(255, 51, 85, 0.12);
  --mid: #ffaa00;
  --mid-dim: rgba(255, 170, 0, 0.12);
  --low: #9B6DFF;
  --low-dim: rgba(155, 109, 255, 0.12);
  --violet: #a855f7;

  /* Semantic (kept for existing class names) */
  --green: #00ff88;
  --red: #ff3355;
  --orange: #ffaa00;
  --yellow: #ffaa00;
  --purple: #a855f7;
  --pink: #ff2d70;

  --sidebar-w: 232px;
  --titlebar-h: 52px;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-panel: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px rgba(0,0,0,0.28);
  --shadow-popover: 0 0 0 1px var(--border-strong), 0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow-accent: 0 0 0 1px rgba(123,47,242,0.4), 0 6px 18px rgba(123,47,242,0.25);

  --mono: 'Anonymous Pro', ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  --display: 'Organetto', 'Anonymous Pro', system-ui, sans-serif;
  --font: var(--mono);
  --font-mono: var(--mono);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 50% 40%, rgba(123, 47, 242, 0.055) 0%, transparent 55%),
    radial-gradient(circle at 15% 85%, rgba(168, 85, 247, 0.035) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 90%);
}

#loginSection,
#appSection {
  position: relative;
  z-index: 1;
}

/* ── Keyframes ──────────────────────────────────────────────── */

@keyframes pulse-mark {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.88); }
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

@keyframes slide-in {
  0%   { transform: translateY(4px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

/* ── Layout ─────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.app-layout[hidden] { display: none; }

/* ── Lead export menu ───────────────────────────────────── */
.lead-export-wrap { position: relative; }
.lead-export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popover);
  z-index: 200;
  min-width: 180px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.lead-export-menu[hidden] { display: none; }
.lead-export-menu button {
  background: transparent;
  color: var(--text);
  border: none;
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.02em;
  height: auto;
}
.lead-export-menu button:hover { background: var(--accent-fill); color: var(--accent); }

/* ── Subscription / trial management buttons ────────────── */
.sub-manage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .sub-manage-grid { grid-template-columns: 1fr; }
}
.sub-manage-block label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  display: block;
}
.sub-manage-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sub-manage-plus,
.sub-manage-minus {
  height: 32px;
  padding: 4px 12px;
  font-size: 11px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  border: 1px solid;
  background: transparent;
}
.sub-manage-plus {
  color: #00c97a;
  border-color: rgba(0, 201, 122, 0.35);
  background: rgba(0, 201, 122, 0.06);
}
.sub-manage-plus:hover {
  background: rgba(0, 201, 122, 0.18);
  border-color: rgba(0, 201, 122, 0.6);
}
.sub-manage-minus {
  color: #ffaa00;
  border-color: rgba(255, 170, 0, 0.35);
  background: rgba(255, 170, 0, 0.06);
}
.sub-manage-minus:hover {
  background: rgba(255, 170, 0, 0.18);
  border-color: rgba(255, 170, 0, 0.6);
}
.sub-manage-cancel {
  height: 32px;
  padding: 4px 12px;
  font-size: 11px;
  color: #ff6b6b;
  border-color: rgba(255, 90, 90, 0.35);
  background: rgba(255, 90, 90, 0.06);
}
.sub-manage-cancel:hover {
  background: rgba(255, 90, 90, 0.18);
  border-color: rgba(255, 90, 90, 0.6);
}

[data-theme="light"] .sub-manage-plus {
  color: #059669;
  background: rgba(5, 150, 105, 0.06);
  border-color: rgba(5, 150, 105, 0.35);
}
[data-theme="light"] .sub-manage-plus:hover {
  background: rgba(5, 150, 105, 0.18);
}
[data-theme="light"] .sub-manage-minus {
  color: #c2410c;
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.35);
}
[data-theme="light"] .sub-manage-minus:hover {
  background: rgba(217, 119, 6, 0.18);
}
[data-theme="light"] .sub-manage-cancel {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.35);
}
[data-theme="light"] .sub-manage-cancel:hover {
  background: rgba(220, 38, 38, 0.18);
}

/* ── Sidebar ────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: rgba(11, 9, 20, 0.72);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  z-index: 10;
  user-select: none;
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}

/* Brand block (replaces traffic lights) */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.brand-mark {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 3px;
  box-shadow: 0 0 12px var(--accent), 0 0 28px var(--accent-dim);
  animation: pulse-mark 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-name {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
  line-height: 1;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--muted);
  line-height: 1;
  text-transform: uppercase;
}

.sidebar-logo {
  padding: 4px 18px 8px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo::before {
  content: '';
  width: 3px;
  height: 10px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 10px;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: default;
  outline: none;
  border: 1px solid transparent;
}

.sidebar-icon-tile {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  background: var(--control-bg);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}
.sidebar-link:hover .sidebar-icon-tile {
  color: var(--accent);
  border-color: rgba(123, 47, 242, 0.35);
}

.sidebar-link.active {
  background: var(--accent-fill);
  color: var(--text);
  border-color: rgba(123, 47, 242, 0.35);
}
.sidebar-link.active .sidebar-icon-tile {
  color: var(--accent);
  background: rgba(123, 47, 242, 0.18);
  border-color: rgba(123, 47, 242, 0.4);
  box-shadow: 0 0 8px rgba(123, 47, 242, 0.3);
}

/* ── Main content ───────────────────────────────────────────── */

.main-content {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  background: transparent;
}

/* ── Titlebar / toolbar ─────────────────────────────────────── */

.header {
  height: var(--titlebar-h);
  padding: 0 24px;
  background: rgba(11, 9, 20, 0.58);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
}

.header-title::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: dot-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

.header-title > div {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  overflow: hidden;
}

.header h1 {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header .muted {
  margin: 0;
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
}

/* ── Page body padding ──────────────────────────────────────── */

#err { margin: 14px 28px 0; }
.page { padding: 18px 28px 48px; }

/* ── Login ──────────────────────────────────────────────────── */

.login-panel {
  max-width: 360px;
  margin: 14vh auto;
  background: linear-gradient(135deg, rgba(20, 16, 38, 0.92) 0%, rgba(10, 8, 20, 0.96) 100%);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  padding: 30px 28px 26px;
  border-radius: var(--radius-xl);
  box-shadow: 0 0 40px rgba(123, 47, 242, 0.18), 0 0 100px rgba(123, 47, 242, 0.06);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.login-panel h1 {
  font-family: var(--display);
  font-size: 19px;
  margin: 0 0 18px;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 0 12px rgba(123, 47, 242, 0.4);
}

.login-panel form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-panel label { margin-bottom: 4px; }

.login-panel button {
  margin-top: 10px;
  width: 100%;
  height: 36px;
  font-size: 12px;
}

/* ── Panels ─────────────────────────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
  z-index: 1;
}

/* Lift any panel that hosts an open popover (dropdown/multi-select) above
   sibling panels, since backdrop-filter on panels creates stacking contexts. */
.panel:has(.time-range-dropdown:not([hidden])),
.panel:has(.multi-select-dropdown:not([hidden])),
.panel.popover-open {
  z-index: 60;
}

.panel h2 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel h2::before {
  content: '';
  width: 3px;
  height: 12px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}

.panel h3 {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

label {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ── Inputs ─────────────────────────────────────────────────── */

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"] {
  flex: 1;
  min-width: 120px;
  height: 32px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus {
  outline: none;
  border-color: rgba(123, 47, 242, 0.55);
  background: rgba(123, 47, 242, 0.05);
  box-shadow: 0 0 0 3px rgba(123, 47, 242, 0.15);
}

input[type="date"],
input[type="datetime-local"] {
  flex: 0 0 auto;
  min-width: 160px;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5) sepia(1) hue-rotate(245deg) saturate(3);
  opacity: 0.75;
  cursor: default;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.5;
}

input::placeholder { color: var(--muted); }

/* ── Buttons ────────────────────────────────────────────────── */

button {
  padding: 7px 16px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid rgba(123, 47, 242, 0.4);
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: default;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(123, 47, 242, 0.22);
}

button:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px rgba(123, 47, 242, 0.38), 0 0 0 1px rgba(123, 47, 242, 0.5);
  filter: none;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(123, 47, 242, 0.25);
  filter: none;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.linkish,
.toolbar-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
  height: 28px;
  padding: 4px 12px;
  letter-spacing: 0.1em;
}

.linkish:hover,
.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(123, 47, 242, 0.4);
  box-shadow: none;
}

/* ── Errors ─────────────────────────────────────────────────── */

.error {
  background: var(--high-dim);
  border: 1px solid rgba(255, 51, 85, 0.35);
  color: var(--high);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

/* ── Tables ─────────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
}

.table thead tr {
  background: rgba(255, 255, 255, 0.025);
}

.table th {
  text-align: left;
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  border-bottom: 1px solid var(--border-strong);
  border-top: 1px solid var(--border);
  position: relative;
}

.table th + th { border-left: 1px solid var(--border); }

.table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}

.table tbody tr {
  cursor: default;
  transition: background 0.08s ease;
}

.table tbody tr:hover {
  background: rgba(123, 47, 242, 0.06);
}

.table tbody tr:hover td:first-child {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.mono { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

/* ── Muted / hints ──────────────────────────────────────────── */

.muted {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.hint { margin: 8px 0 0; font-size: 10px; letter-spacing: 0.06em; }

/* ── Trace / timeline ───────────────────────────────────────── */

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.summary {
  font-family: var(--display);
  font-size: 14px;
  margin: 6px 0;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.timeline {
  position: relative;
  margin: 16px 0;
  padding-left: 24px;
  border-left: 2px solid var(--border-strong);
}

.timeline-item {
  position: relative;
  margin-bottom: 14px;
  padding-left: 6px;
  animation: slide-in 0.35s ease-out;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent), 0 0 0 3px var(--bg);
}

.timeline-item.status-error::before { background: var(--red); box-shadow: 0 0 6px var(--red), 0 0 0 3px var(--bg); }
.timeline-item.status-filtered::before,
.timeline-item.status-skipped::before { background: var(--orange); box-shadow: 0 0 6px var(--orange), 0 0 0 3px var(--bg); }
.timeline-item.status-ok::before { background: var(--green); box-shadow: 0 0 6px var(--green), 0 0 0 3px var(--bg); }

.ev-title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

.ev-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.08em;
}

.ev-detail {
  margin-top: 8px;
  font-size: 11px;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 11rem;
  overflow: auto;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius);
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.source-text {
  max-width: 220px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-text-block {
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 11.5px;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 15rem;
  overflow: auto;
  margin: 10px 0;
  color: var(--text);
  border: 1px solid var(--border);
}

.raw { margin-top: 16px; }

.raw summary {
  cursor: default;
  font-size: 10px;
  color: var(--muted);
  padding: 5px 0;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.raw summary:hover { color: var(--text); }

.raw pre {
  background: rgba(0, 0, 0, 0.45);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow: auto;
  font-size: 10.5px;
  max-height: 360px;
  font-family: var(--mono);
  margin: 8px 0 0;
  border: 1px solid var(--border);
}

/* ── Tooltip ────────────────────────────────────────────────── */

.has-tooltip { position: relative; }

.has-tooltip .tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  z-index: 200;
  bottom: calc(100% + 8px);
  left: 0;
  max-width: 420px;
  min-width: 220px;
  background: rgba(14, 12, 22, 0.98);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 11.5px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 0 0 1px var(--border-strong), 0 12px 32px rgba(0, 0, 0, 0.6);
  transition: opacity 0.12s ease, visibility 0.12s ease;
  pointer-events: none;
  backdrop-filter: blur(16px);
}

.has-tooltip:hover .tooltip-text { visibility: visible; opacity: 1; }

/* ── Badges ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.badge-active {
  color: var(--green);
  background: rgba(0, 255, 136, 0.12);
  border: 1px solid rgba(0, 255, 136, 0.3);
}

.badge-expired {
  color: var(--high);
  background: var(--high-dim);
  border: 1px solid rgba(255, 51, 85, 0.3);
}

.badge-none {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

/* ── Tabs → segmented control ───────────────────────────────── */

.tabs {
  display: inline-flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.03);
  padding: 3px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.tab {
  padding: 5px 16px;
  height: 26px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 7px;
  cursor: default;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: all 0.15s ease;
  box-shadow: none;
}

.tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  box-shadow: none;
}

.tab.active {
  background: var(--accent-fill);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(123, 47, 242, 0.4);
}

/* ── Filters & date presets (segmented) ─────────────────────── */

.filters-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.date-presets {
  display: inline-flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.03);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.preset-btn {
  padding: 3px 11px;
  height: 24px;
  font-size: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 6px;
  cursor: default;
  box-shadow: none;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.preset-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  box-shadow: none;
}

.preset-btn.active {
  background: var(--accent-fill);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(123, 47, 242, 0.4);
}

/* ── Stats cards (big numbers in display font) ──────────────── */

.stats-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
@media (max-width: 1280px) {
  .stats-cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

.stat-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  opacity: 0.6;
}

.stat-label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-label-with-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-card-wide {
  grid-column: span 3;
  min-width: 0;
}

.stat-card-wide-2 {
  grid-column: span 2;
  min-width: 0;
}

@media (max-width: 960px) {
  .stat-card-wide { grid-column: span 2; }
}

@media (max-width: 900px) {
  .stat-card-wide { grid-column: 1 / -1; }
  .stat-card-wide-2 { grid-column: 1 / -1; }
}

.stat-split {
  display: flex;
  align-items: stretch;
  gap: 18px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.stat-split-main {
  flex: 1 1 180px;
  min-width: 0;
}

.stat-split-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
}

.stat-sub {
  flex: 1 1 140px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-sublabel {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-subvalue {
  color: var(--text);
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.stat-subhint {
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-inline-btn {
  height: 22px;
  padding: 2px 10px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  border-radius: var(--radius);
  border: 1px solid rgba(123, 47, 242, 0.35);
  background: rgba(123, 47, 242, 0.08);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.stat-inline-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.stat-revenue {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #00c97a;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  text-shadow: 0 0 10px rgba(0, 201, 122, 0.25);
}
[data-theme="light"] .stat-revenue {
  color: #059669;
  text-shadow: none;
}

.stat-filter-select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 55%;
  height: 22px;
  padding: 2px 22px 2px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239aa0a8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
    no-repeat right 6px center;
  color: var(--text);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: none;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.stat-filter-select:hover {
  border-color: rgba(123, 47, 242, 0.45);
}

.stat-filter-select:focus {
  outline: none;
  border-color: rgba(123, 47, 242, 0.55);
  box-shadow: 0 0 0 2px rgba(123, 47, 242, 0.15);
}

.stat-filter-select option {
  background: #15171b;
  color: var(--text);
}

.stat-value {
  color: var(--accent);
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(123, 47, 242, 0.35);
  line-height: 1.05;
}

/* ── Multi-select ───────────────────────────────────────────── */

.multi-select {
  position: relative;
  min-width: 220px;
}

.multi-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  height: 32px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  color: var(--text);
  cursor: default;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.multi-select-trigger svg { color: var(--accent); flex-shrink: 0; }

.multi-select-trigger:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(123, 47, 242, 0.4);
}

.multi-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popover);
  z-index: 300;
  max-height: 420px;
  min-width: 360px;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
}
.multi-select-dropdown[hidden] { display: none; }

.bcast-dropdown-head {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.bcast-dropdown-head input {
  width: 100%;
  height: 30px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--control-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.multi-select-dropdown #bcastTaskOptions {
  overflow-y: auto;
  flex: 1;
  padding: 4px;
}

.bcast-task-group { margin-bottom: 2px; }
.bcast-task-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 11.5px;
  transition: background 0.12s ease;
}
.bcast-task-group-head:hover { background: var(--accent-fill); }
.bcast-task-group.open .bcast-task-group-head { background: rgba(123, 47, 242, 0.08); }
[data-theme="light"] .bcast-task-group.open .bcast-task-group-head { background: rgba(103, 34, 214, 0.08); }

.bcast-task-group-caret {
  width: 12px; height: 12px;
  color: var(--muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.bcast-task-group.open .bcast-task-group-caret {
  transform: rotate(90deg);
  color: var(--accent);
}
.bcast-task-group-name {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bcast-task-group-count {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.bcast-task-group-all {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--accent-fill);
  color: var(--accent);
  border: 1px solid rgba(123, 47, 242, 0.3);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.bcast-task-group-all:hover { background: var(--accent); color: #fff; }
.bcast-task-group-all.removing {
  background: rgba(255, 51, 85, 0.1);
  color: #ff6b6b;
  border-color: rgba(255, 51, 85, 0.35);
}
.bcast-task-group-all.removing:hover {
  background: rgba(255, 51, 85, 0.25);
  color: #fff;
  border-color: rgba(255, 51, 85, 0.65);
}
[data-theme="light"] .bcast-task-group-all.removing {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.3);
}
[data-theme="light"] .bcast-task-group-all.removing:hover {
  background: #dc2626;
  color: #fff;
}

.bcast-task-group.has-selected .bcast-task-group-name { color: var(--accent); }
.bcast-task-group-tick {
  display: inline-block;
  margin-left: 4px;
  color: #00c97a;
  font-size: 11px;
}
[data-theme="light"] .bcast-task-group-tick { color: #059669; }
.bcast-task-group-items {
  display: none;
  flex-direction: column;
  padding: 2px 0 4px 22px;
}
.bcast-task-group.open .bcast-task-group-items { display: flex; }

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: default;
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.02em;
}

.multi-select-option:hover {
  background: var(--accent-fill);
}

.multi-select-option input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: default;
  flex-shrink: 0;
}

/* ── Lead status icons ──────────────────────────────────────── */

.lead-status {
  font-size: 14px;
  text-align: center;
  font-weight: 700;
}
.lead-accepted { color: var(--green); text-shadow: 0 0 6px rgba(0, 255, 136, 0.45); }
.lead-declined { color: var(--high); text-shadow: 0 0 6px rgba(255, 51, 85, 0.45); }
.lead-pending  { color: var(--mid);  text-shadow: 0 0 6px rgba(255, 170, 0, 0.45); }

/* ── Modal (sheet) ──────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 500;
  padding: 64px 20px 20px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: linear-gradient(135deg, rgba(20, 16, 38, 0.96) 0%, rgba(10, 8, 20, 0.98) 100%);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 660px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(123, 47, 242, 0.18), 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: sheet-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal-close {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 18px;
  height: 28px;
  width: 28px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
  font-weight: 400;
  border: 1px solid transparent;
}

.modal-close:hover {
  background: rgba(255, 51, 85, 0.12);
  border-color: rgba(255, 51, 85, 0.35);
  color: var(--high);
  box-shadow: none;
}

.modal-body { padding: 20px 22px; }

.modal-field { margin-bottom: 16px; }

.modal-field label {
  font-size: 9.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.modal-field-value {
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ── Pagination ─────────────────────────────────────────────── */

.pagination {
  display: flex;
  gap: 3px;
  justify-content: center;
  padding: 14px 0 4px;
}

.pagination button {
  padding: 3px 10px;
  height: 26px;
  min-width: 30px;
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: none;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.pagination button:hover:not(:disabled):not(.active) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(123, 47, 242, 0.4);
  box-shadow: none;
}

.pagination button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(123, 47, 242, 0.35);
}

.pagination button:disabled { opacity: 0.3; }

/* ── User card ──────────────────────────────────────────────── */

.user-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
}

.card-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-field-label {
  font-size: 9.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
}

.card-field-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* ── Tasks accordion ────────────────────────────────────────── */

.task-list { margin-top: 16px; }

.task-item {
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: default;
  transition: background 0.1s ease;
}

.task-header:hover { background: rgba(123, 47, 242, 0.06); }

.task-title {
  font-weight: 500;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.03em;
  color: var(--text);
}

.task-active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.task-active-dot.active   { background: var(--green); box-shadow: 0 0 6px var(--green); }
.task-active-dot.inactive { background: var(--high);  box-shadow: 0 0 6px var(--high); }

.task-body {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  background: rgba(0, 0, 0, 0.25);
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.task-tag {
  padding: 2px 10px;
  background: var(--accent-fill);
  border: 1px solid rgba(123, 47, 242, 0.3);
  border-radius: 10px;
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ── Payment status colors ──────────────────────────────────── */

.pay-completed { color: var(--green); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.pay-pending   { color: var(--mid);   font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.pay-failed    { color: var(--high);  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.pay-timeout   { color: var(--muted); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

/* ── Time range picker (Grafana-like) ──────────────────────── */

.time-range-picker {
  position: relative;
  display: inline-block;
}

.stats-range-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.stats-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.stats-refresh-btn svg { color: var(--accent); flex-shrink: 0; transition: transform 0.6s ease; }

.stats-refresh-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(123, 47, 242, 0.4);
}

.stats-refresh-btn.is-refreshing svg {
  animation: stats-refresh-spin 0.8s linear infinite;
}

.stats-refresh-btn:disabled {
  opacity: 0.7;
  cursor: progress;
}

@keyframes stats-refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.time-range-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  height: 32px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  cursor: default;
  min-width: 230px;
  justify-content: flex-start;
  letter-spacing: 0.04em;
  text-transform: none;
  box-shadow: none;
}

.time-range-trigger span {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-range-trigger svg { color: var(--accent); flex-shrink: 0; }

.time-range-trigger:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(123, 47, 242, 0.4);
  box-shadow: none;
}

.time-range-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 320px;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  z-index: 350;
  padding: 8px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: sheet-in 0.14s ease-out;
  max-height: 75vh;
  overflow-y: auto;
}

.time-range-section + .time-range-section {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.time-range-header {
  padding: 6px 10px 4px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-range-header::before {
  content: '';
  width: 3px;
  height: 10px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.time-range-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.time-range-option {
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 6px 12px;
  height: 28px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.03em;
  box-shadow: none;
  border: none;
  text-transform: none;
}

.time-range-option:hover {
  background: rgba(123, 47, 242, 0.12);
  box-shadow: none;
}

.time-range-option.active {
  background: var(--accent-fill);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(123, 47, 242, 0.4);
}

.time-range-custom {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 8px 10px 4px;
}

.time-range-custom label {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.16em;
}

.time-range-custom input[type="datetime-local"] {
  height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 11.5px;
  width: 100%;
  font-family: var(--mono);
}

.time-range-custom button {
  grid-column: 1 / -1;
  margin-top: 6px;
  height: 30px;
}

/* ── Professions (heat-map list) ────────────────────────────── */

.professions-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.professions-head h2 { margin: 0; }

.professions-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.professions-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.professions-list.collapsed > .profession-row:nth-child(n+11) { display: none; }
.professions-list.collapsed > .profession-category:nth-child(n+11) { display: none; }

.profession-category {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.profession-category.active { border-color: rgba(123, 47, 242, 0.5); }
[data-theme="light"] .profession-category {
  background: #fff;
  border-color: var(--border);
}

.profession-category-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  background: rgba(123, 47, 242, 0.05);
  border-bottom: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.profession-category-head:hover {
  background: rgba(123, 47, 242, 0.10);
}
.profession-category.open .profession-category-head {
  border-bottom-color: var(--border);
  background: rgba(123, 47, 242, 0.08);
}
[data-theme="light"] .profession-category-head { background: rgba(103, 34, 214, 0.05); }
[data-theme="light"] .profession-category-head:hover { background: rgba(103, 34, 214, 0.10); }
[data-theme="light"] .profession-category.open .profession-category-head { background: rgba(103, 34, 214, 0.08); }

.profession-category-caret {
  width: 14px; height: 14px;
  color: var(--muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.profession-category.open .profession-category-caret { transform: rotate(90deg); color: var(--accent); }

.profession-category-name {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.profession-category-counts {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
.profession-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-weight: 600;
  font-size: 10.5px;
}
.profession-category-percent {
  color: var(--accent);
  font-weight: 600;
}

.profession-category-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 10px 10px;
}
.profession-category-titles .profession-row {
  padding: 7px 12px;
  font-size: 11.5px;
}

.profession-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  overflow: hidden;
  font-size: 12px;
  cursor: default;
  transition: all 0.12s ease;
}

.profession-row:hover {
  border-color: currentColor;
  box-shadow: 0 0 0 1px currentColor, 0 4px 12px rgba(0, 0, 0, 0.25);
}

.profession-row:active { transform: scale(0.996); }

.profession-row.active {
  border-color: currentColor;
  box-shadow: 0 0 0 1px currentColor, 0 0 0 4px color-mix(in srgb, currentColor 22%, transparent);
}

.profession-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  background: currentColor;
  opacity: 0.22;
  transition: width 0.3s ease;
}

.profession-title,
.profession-stats { position: relative; z-index: 1; }

.profession-title {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  letter-spacing: 0.03em;
}

.profession-rank {
  display: inline-block;
  width: 28px;
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.profession-stats {
  display: flex;
  align-items: baseline;
  gap: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.profession-count {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  color: currentColor;
  letter-spacing: 0.04em;
}

.profession-percent {
  font-size: 10px;
  color: var(--muted);
  min-width: 48px;
  text-align: right;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Popularity buckets — row tint via currentColor */
.profession-row.pop-hot     { color: var(--high); }
.profession-row.pop-warm    { color: var(--mid); }
.profession-row.pop-medium  { color: var(--yellow); }
.profession-row.pop-mild    { color: var(--green); }
.profession-row.pop-cold    { color: var(--accent); }
.profession-row.pop-chill   { color: var(--violet); }

.professions-empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.professions-toggle-wrap {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

/* ── Filter chips ───────────────────────────────────────────── */

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 12px;
  height: 26px;
  background: var(--accent-fill);
  color: var(--accent);
  border: 1px solid rgba(123, 47, 242, 0.4);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.filter-chip-label { line-height: 1.5; }
.filter-chip-label strong { font-weight: 700; color: var(--accent); }

.filter-chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  color: var(--accent);
  border: none;
  border-radius: 50%;
  box-shadow: none;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

.filter-chip-close:hover {
  background: rgba(123, 47, 242, 0.25);
  box-shadow: none;
}

/* ── Profession pills inside users table ────────────────────── */

.profession-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 320px;
}

.profession-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--accent-fill);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(123, 47, 242, 0.3);
}

/* ── Broadcasts ─────────────────────────────────────────────── */

.bcast-textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  resize: vertical;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.bcast-textarea:focus {
  outline: none;
  border-color: rgba(123, 47, 242, 0.55);
  box-shadow: 0 0 0 3px rgba(123, 47, 242, 0.14);
}

.bcast-counter {
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-align: right;
}

.bcast-preview {
  padding: 12px 14px;
  background: rgba(123, 47, 242, 0.07);
  border: 1px solid rgba(123, 47, 242, 0.3);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  position: relative;
}

.bcast-preview-bot {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.bcast-preview-text {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.bcast-target-info {
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.04em;
}
.bcast-target-info strong {
  font-family: var(--display);
  font-size: 16px;
  color: var(--accent);
  margin: 0 4px;
}

/* Recipients block (chips + search) */
.bcast-recipients {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bcast-user-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  height: 32px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bcast-user-search:focus-within {
  border-color: rgba(123, 47, 242, 0.55);
  box-shadow: 0 0 0 3px rgba(123, 47, 242, 0.14);
}

.bcast-user-search svg { color: var(--muted); flex-shrink: 0; }

.bcast-user-search input {
  flex: 1;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  height: 100%;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: 0.02em;
  min-width: 0;
}

.bcast-user-search input:focus {
  outline: none;
  box-shadow: none;
}

.bcast-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popover);
  z-index: 60;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
  backdrop-filter: blur(20px);
}

.bcast-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: default;
  color: var(--text);
  font-size: 12px;
}

.bcast-search-result:hover { background: rgba(123, 47, 242, 0.12); }

.bcast-search-result-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcast-search-result-meta { color: var(--muted); font-size: 10px; letter-spacing: 0.06em; }
.bcast-search-result.added { opacity: 0.45; }

.bcast-search-empty {
  padding: 14px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bcast-task-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.bcast-task-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.bcast-task-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--accent-fill);
  border: 1px solid rgba(123,47,242,0.35);
  border-radius: 14px;
  font-size: 11.5px;
  color: var(--accent);
  max-width: 260px;
}
.bcast-task-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.bcast-task-chip-close {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}
.bcast-task-chip-close:hover { opacity: 1; }

.bcast-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
}

.bcast-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 9px;
  height: 22px;
  background: var(--accent-fill);
  color: var(--accent);
  border: 1px solid rgba(123, 47, 242, 0.3);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  max-width: 220px;
  overflow: hidden;
}

.bcast-chip.manual {
  background: rgba(0, 255, 136, 0.1);
  color: var(--green);
  border-color: rgba(0, 255, 136, 0.3);
}

.bcast-chip-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bcast-chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  background: transparent;
  color: inherit;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: none;
}

.bcast-chip-close:hover {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.bcast-chip-more {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  padding: 4px 8px;
  align-self: center;
}

.bcast-chip-empty {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  padding: 4px 0;
}

.bcast-recipients-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.bcast-recipients-spacer { flex: 1; }

/* Active broadcast panel */
.bcast-active-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.bcast-progress-wrap {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}

.bcast-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent) 0%, var(--violet) 100%);
  box-shadow: 0 0 8px var(--accent);
  transition: width 0.4s ease;
}

.bcast-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.bcast-stats > div {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bcast-stats span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.bcast-stats strong {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Status badges in history table */
.bcast-status {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bcast-status.running   { color: var(--accent); background: var(--accent-fill); border: 1px solid rgba(123, 47, 242, 0.4); }
.bcast-status.done      { color: var(--green);  background: rgba(0, 255, 136, 0.12); border: 1px solid rgba(0, 255, 136, 0.3); }
.bcast-status.cancelled { color: var(--muted);  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); }
.bcast-status.failed    { color: var(--high);   background: var(--high-dim); border: 1px solid rgba(255, 51, 85, 0.3); }
.bcast-status.pending   { color: var(--mid);    background: var(--mid-dim);  border: 1px solid rgba(255, 170, 0, 0.3); }

/* Per-target status */
.bcast-target-status-sent    { color: var(--green); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; }
.bcast-target-status-blocked { color: var(--high);  font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; }
.bcast-target-status-failed  { color: var(--mid);   font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; }
.bcast-target-status-pending { color: var(--muted); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; }

.bcast-detail-body {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ── Stat deltas ────────────────────────────────────────────── */

.stat-delta {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 14px;
  letter-spacing: 0.06em;
}

.stat-delta-up   { color: var(--green); }
.stat-delta-down { color: var(--high); }
.stat-delta-zero { color: var(--muted); }
.stat-delta-na   { color: var(--text-tertiary); font-style: italic; }

/* ── Scrollbars ─────────────────────────────────────────────── */

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(123, 47, 242, 0.3);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(123, 47, 242, 0.5);
  background-clip: content-box;
}
*::-webkit-scrollbar-corner { background: transparent; }

/* ── Selection ──────────────────────────────────────────────── */

::selection {
  background: rgba(123, 47, 242, 0.4);
  color: #fff;
}

/* ── Analytics dashboard ────────────────────────────────────── */

.analytics-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
}

.analytics-refresh { min-width: 180px; }

/* KPI grid uses flex so tiles have equal height within a row (stretch),
   while each tile's width adapts to its content (flex-basis: auto). */
.an-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
}

.an-grid-kpi {
  /* No extra rules — flex defaults handle it */
}

.an-tile {
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  min-width: 180px;
  /* flex: grow to share row width, shrink to fit, basis auto (content-sized) */
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  transition: flex-basis 0.2s ease, min-width 0.2s ease;
  /* Accent strip on the left drawn as inset box-shadow so it respects border-radius */
  box-shadow: inset 3px 0 0 rgba(123, 47, 242, 0.55);
}

.an-tile.wide {
  min-width: 360px;
  flex-basis: 360px;
  flex-grow: 2;
}

.an-tile.wide-3 {
  min-width: 560px;
  flex-basis: 560px;
  flex-grow: 3;
}

@media (max-width: 600px) {
  .an-tile {
    min-width: 100%;
    flex-basis: 100%;
  }
  .an-tile.wide, .an-tile.wide-3 {
    min-width: 100%;
    flex-basis: 100%;
  }
}

/* Drag handle on right edge for resizing */
.an-tile-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 6px;
  cursor: ew-resize;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.12s ease;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(123, 47, 242, 0.35)
  );
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.an-tile:hover .an-tile-resize-handle,
.an-tile.an-resizing .an-tile-resize-handle { opacity: 1; }

.an-tile.an-resizing {
  outline: 1px dashed rgba(123, 47, 242, 0.5);
  outline-offset: -2px;
}

@media (max-width: 600px) {
  .an-tile-resize-handle { display: none; }
}

/* Accent strip is now drawn via inset box-shadow on .an-tile (see above),
   so it respects border-radius and never bleeds past the rounded corners. */

.an-tile-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.an-tile-value {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.05;
  text-shadow: 0 0 14px rgba(123, 47, 242, 0.28);
  word-break: break-word;
  overflow-wrap: break-word;
}

.an-tile-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.an-tile-delta {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-height: 14px;
}

.an-tile-delta.up   { color: var(--green); }
.an-tile-delta.down { color: var(--high); }

.an-sparkline {
  width: 100% !important;
  height: 32px !important;
  margin-top: 8px;
  display: block;
}

/* Tooltip (?) */
.an-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: help;
  background: rgba(255, 255, 255, 0.04);
  position: relative;
  flex-shrink: 0;
  letter-spacing: 0;
  font-family: var(--mono);
  font-weight: 700;
  transition: color 0.1s ease, border-color 0.1s ease;
}

.an-help:hover {
  color: var(--accent);
  border-color: rgba(123, 47, 242, 0.5);
}

/* Floating tooltip (positioned in JS, sits at body level to escape stacking contexts) */
.an-tooltip-float {
  position: fixed;
  background: rgba(14, 12, 22, 0.98);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  max-width: 320px;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 0 0 1px var(--border-strong), 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 9999;
  pointer-events: none;
  text-transform: none;
  font-weight: 400;
  font-family: var(--mono);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: an-tt-in 0.12s ease-out;
}

@keyframes an-tt-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Toggle switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 2px 4px;
}

.toggle-switch input {
  appearance: none;
  width: 28px;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  position: relative;
  cursor: default;
  transition: background 0.15s ease;
  margin: 0;
}

.toggle-switch input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle-switch input:checked {
  background: rgba(123, 47, 242, 0.35);
}

.toggle-switch input:checked::before {
  transform: translateX(12px);
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.toggle-switch:has(input:checked) .toggle-label { color: var(--accent); }

/* Chart wrapper */
.an-chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}

.an-chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Funnel (overview) */
.an-funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.an-funnel-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.an-funnel-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, rgba(123, 47, 242, 0.28), rgba(123, 47, 242, 0.08));
  transition: width 0.35s ease;
  z-index: 0;
}

.an-funnel-label, .an-funnel-stats { position: relative; z-index: 1; }

.an-funnel-label {
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--text);
  flex: 1;
}

.an-funnel-stats {
  display: flex;
  gap: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.an-funnel-count {
  font-family: var(--display);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.an-funnel-conv {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Cohort matrix */
.an-cohort-wrap {
  display: grid;
  gap: 2px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.an-cohort-row {
  display: grid;
  grid-template-columns: 110px repeat(var(--cohort-weeks, 12), 42px);
  gap: 2px;
  align-items: center;
}

.an-cohort-cell {
  height: 30px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  color: var(--text);
  background: rgba(123, 47, 242, 0.08);
  letter-spacing: 0.04em;
}

.an-cohort-cell.header {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.an-cohort-cell.label {
  background: transparent;
  color: var(--text);
  font-weight: 700;
  justify-content: flex-start;
  padding: 0 8px;
}

.an-cohort-cell.size {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 10px;
}

.an-cohort-cell.empty { background: transparent; color: var(--text-tertiary); }

/* Heatmap (day × hour) */
.an-heatmap-wrap {
  display: grid;
  grid-template-columns: 44px repeat(24, minmax(18px, 1fr));
  gap: 2px;
}

.an-heat-label {
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}

.an-heat-hour {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 2px 0;
}

.an-heat-cell {
  height: 22px;
  background: rgba(123, 47, 242, 0.1);
  border-radius: 3px;
  position: relative;
}

.an-heat-cell[title]:hover { outline: 1px solid var(--accent); }

/* Export button next to section header */
section.panel .detail-head .linkish { font-size: 10px; }

/* ── Hamburger + sidebar backdrop (hidden on desktop) ─────── */

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  padding: 0;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: none;
  letter-spacing: 0;
}

.hamburger:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(123, 47, 242, 0.4);
  filter: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Table wrap (horizontal scroll for dense tables) ──────── */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap > .table { min-width: 600px; }

/* ── Users list head (result count) ─────────────────────── */
.users-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.users-list-head h2 { margin: 0; }
.users-list-total {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(123,47,242,0.12);
  border: 1px solid rgba(123,47,242,0.3);
  padding: 3px 12px;
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.users-list-total.empty {
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
}

/* ── Row-number column ──────────────────────────────────── */
.table .col-num {
  width: 44px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  padding-right: 8px;
}
.table thead .col-num {
  color: var(--muted);
  letter-spacing: 0.14em;
}

/* ── Sidebar badge (unread counter) ─────────────────────────── */
.sidebar-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(123, 47, 242, 0.55);
}

/* ── Support: 3-column layout ──────────────────────────────── */
.support-panel { padding: 0; overflow: hidden; }

.support-layout {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  min-height: calc(100vh - 180px);
  max-height: calc(100vh - 120px);
}

.support-chat-list {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.support-chat-list-head {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.support-chat-items {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.support-chat-item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: background 0.12s ease;
}
.support-chat-item:hover { background: rgba(255,255,255,0.03); }
.support-chat-item.active { background: rgba(123,47,242,0.12); border-left: 2px solid var(--accent); padding-left: 10px; }
.support-chat-item-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text); flex-shrink: 0;
}
.support-chat-item-body { flex: 1; min-width: 0; }
.support-chat-item-top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
}
.support-chat-item-name { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.support-chat-item-time { font-size: 10px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.support-chat-item-preview {
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.support-chat-item-badge {
  display: inline-block;
  min-width: 16px; height: 16px; padding: 0 5px;
  background: var(--accent); color: #fff;
  border-radius: 8px; font-size: 10px; font-weight: 700;
  margin-left: auto; line-height: 16px; text-align: center;
}
.support-chat-item.closed { opacity: 0.6; }

.support-chat-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(0,0,0,0.18);
}
.support-chat-empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 13px;
}
.support-chat-active {
  display: flex; flex-direction: column; min-height: 0; flex: 1;
}
.support-chat-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.support-chat-header-main { flex: 1; min-width: 0; }
.support-chat-name { font-weight: 700; font-size: 13px; }
.support-chat-sub { font-size: 11px; }
.support-chat-header-actions { display: flex; gap: 10px; flex-shrink: 0; }

.support-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.support-msg {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.4;
  word-wrap: break-word;
}
.support-msg.in {
  align-self: flex-start;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-top-left-radius: 3px;
}
.support-msg.out {
  align-self: flex-end;
  background: rgba(123,47,242,0.18);
  border: 1px solid rgba(123,47,242,0.35);
  border-top-right-radius: 3px;
}
.support-msg-meta {
  font-size: 9.5px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
  display: flex;
  gap: 6px;
  align-items: center;
}
.support-msg.failed { border-color: rgba(255,90,90,0.5); }

.support-composer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  background: rgba(0,0,0,0.2);
}
.support-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.support-quick-chip {
  padding: 3px 10px;
  font-size: 10.5px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  cursor: pointer;
}
.support-quick-chip:hover { background: rgba(123,47,242,0.12); border-color: rgba(123,47,242,0.35); }
.support-composer-row { display: flex; gap: 8px; align-items: flex-end; }
.support-composer-row textarea {
  flex: 1;
  min-height: 38px;
  max-height: 160px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  resize: vertical;
}

.support-profile {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}
.support-profile-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.support-profile-head h3 { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin: 0; }
.support-profile-section { margin-top: 18px; }
.support-profile-section h4 {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px;
}
.support-quick-actions { display: flex; flex-direction: column; gap: 6px; }
.support-quick-actions .toolbar-btn { width: 100%; justify-content: flex-start; }
.support-notes-list { display: flex; flex-direction: column; gap: 6px; }
.support-note {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12px;
  position: relative;
}
.support-note-meta { font-size: 9.5px; color: var(--muted); margin-top: 4px; }
.support-note-del {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 0;
}

.switch-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 8px 0; }

.auto-reply-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 8px;
  align-items: center;
}
.auto-reply-row strong {
  font-size: 12px;
  color: var(--accent);
  background: rgba(123,47,242,0.1);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auto-reply-row > div:nth-child(2) {
  font-size: 11.5px;
  color: rgba(255,255,255,0.8);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Scenario builder ───────────────────────────────────────── */
.scenario-panel { padding: 16px; }
.scenario-panel h2 { margin: 0; }
#btnDeleteScene {
  color: rgba(255,120,120,0.85);
  border: 1px solid rgba(255,120,120,0.25);
  background: rgba(255,120,120,0.06);
}
#btnDeleteScene:hover {
  color: #ff8080;
  background: rgba(255,120,120,0.12);
  border-color: rgba(255,120,120,0.5);
}
.scenario-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.scenario-head h2 { margin: 0; }
.scenario-head-actions { display: flex; align-items: center; gap: 10px; }

.scenario-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  min-height: 480px;
}
.scenario-layout[hidden] { display: none; }

.scenario-scenes {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.scenario-scenes-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.scenario-scenes-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.scene-item {
  padding: 9px 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.12s ease;
}
.scene-item:hover { background: rgba(255,255,255,0.04); }
.scene-item.active {
  background: rgba(123,47,242,0.12);
  border-left-color: var(--accent);
}
.scene-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-item-tag {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(189,248,17,0.15);
  color: #bef811;
  font-weight: 700;
  flex-shrink: 0;
}
.scene-item-badge {
  font-size: 9.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.scenario-editor {
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 72vh;
}
.scenario-editor .filter-group { margin-bottom: 14px; }
.scenario-editor .filter-group:last-child { margin-bottom: 0; }
.scenario-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  font-size: 13px;
}
.scenario-editor .switch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
}
.scenario-editor .switch-row input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
.scenario-editor .switch-row code {
  background: rgba(123,47,242,0.12);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-size: 10.5px;
}
.scenario-editor .hint code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
}

.scene-btn-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px;
  margin-top: 8px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.scene-btn-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.scene-btn-row-top input[type="text"] {
  flex: 1;
  min-width: 0;
}
.scene-btn-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.scene-btn-row-bottom select {
  flex: 1;
  min-width: 0;
}
.scene-btn-row select,
.scene-btn-row input[type="text"] {
  height: 30px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  box-sizing: border-box;
}
.scene-btn-row select:focus,
.scene-btn-row input[type="text"]:focus {
  outline: none;
  border-color: rgba(123,47,242,0.55);
  background: rgba(123,47,242,0.05);
}
.scene-btn-row label.switch-row {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  margin: 0;
  gap: 5px;
  white-space: nowrap;
  color: var(--muted);
  cursor: pointer;
}
.scene-btn-row label.switch-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}
.scene-btn-row .btn-row-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.scene-btn-row .btn-row-delete:hover {
  color: #ff6b6b;
  background: rgba(255,90,90,0.1);
  border-color: rgba(255,90,90,0.35);
}

@media (max-width: 1100px) {
  .scenario-layout { grid-template-columns: 220px 1fr; }
}
@media (max-width: 900px) {
  .scenario-layout { grid-template-columns: 1fr; }
  .scenario-editor { max-height: none; }
}

/* ── Visual (node-graph) scenario editor ───────────────────── */
.scenario-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
}
.scenario-canvas-toolbar[hidden] { display: none; }
.scenario-canvas-toolbar .linkish {
  height: 28px;
  padding: 2px 10px;
  font-size: 10.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.scenario-canvas-toolbar .linkish:hover {
  border-color: rgba(123,47,242,0.45);
  background: rgba(123,47,242,0.08);
}

.scenario-canvas-layout {
  display: grid;
  grid-template-columns: 220px 1fr 340px;
  gap: 12px;
  height: min(720px, calc(100vh - 240px));
}
.scenario-canvas-layout[hidden] { display: none; }

.scenario-canvas-nav {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.scenario-canvas-nav-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.scenario-canvas-nav-list {
  flex: 1;
  overflow-y: auto;
}
.scenario-canvas-nav-item {
  padding: 8px 12px;
  font-size: 11.5px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.scenario-canvas-nav-item:hover { background: rgba(255,255,255,0.04); }
.scenario-canvas-nav-item.active {
  background: rgba(123,47,242,0.14);
  border-left-color: var(--accent);
}
.scenario-canvas-nav-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario-canvas-nav-item-tag {
  font-size: 8.5px;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(189,248,17,0.18);
  color: #bef811;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.scenario-canvas-viewport {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    linear-gradient(rgba(123,47,242,0.03), rgba(123,47,242,0.03)),
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.07) 1px, transparent 0);
  background-size: auto, 22px 22px;
  height: 100%;
  min-height: 0;
  cursor: default;
}
.scenario-canvas-viewport.panning { cursor: grabbing; }
.scenario-canvas-viewport.connecting { cursor: crosshair; }

.scenario-canvas-hint {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  background: rgba(123,47,242,0.85);
  color: #fff;
  font-size: 11px;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(123,47,242,0.5);
  z-index: 10;
  pointer-events: none;
}

.scenario-canvas-world {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.scenario-canvas-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.scenario-canvas-svg path.connection { pointer-events: stroke; }

.flow-node {
  position: absolute;
  min-width: 240px;
  max-width: 300px;
  background: rgba(22, 22, 28, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  overflow: hidden;
  font-size: 12px;
  z-index: 2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.flow-node:hover { border-color: rgba(123,47,242,0.5); }
.flow-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(123,47,242,0.25), 0 8px 24px rgba(0,0,0,0.55);
}
.flow-node.is-start { border-top: 3px solid #bef811; }

.flow-node.drop-target {
  border-color: #bef811;
  box-shadow: 0 0 0 2px rgba(189,248,17,0.35), 0 8px 24px rgba(0,0,0,0.55);
}

.flow-node-head {
  padding: 8px 12px;
  cursor: grab;
  background: rgba(123,47,242,0.18);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.flow-node-head.grabbing { cursor: grabbing; }
.flow-node-title {
  flex: 1;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-node-start-tag {
  font-size: 8.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(189,248,17,0.18);
  color: #bef811;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.flow-node-del {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}
.flow-node-del:hover {
  background: rgba(255,90,90,0.2);
  color: #ff6b6b;
}

.flow-node-body {
  padding: 10px 12px;
  color: var(--text);
}
.flow-node-media {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.flow-node-text {
  font-size: 11.5px;
  line-height: 1.4;
  color: rgba(255,255,255,0.8);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}
.flow-node-text.empty { color: var(--muted); font-style: italic; }

.flow-node-buttons {
  border-top: 1px solid var(--border);
  padding: 4px 0;
}
.flow-node-btn {
  padding: 7px 12px;
  font-size: 11.5px;
  border-top: 1px solid rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: default;
  position: relative;
}
.flow-node-btn:hover { background: rgba(255,255,255,0.03); }
.flow-node-btn:first-child { border-top: none; }
.flow-node-btn-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-node-btn-target {
  font-size: 9.5px;
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.flow-node-btn.handoff .flow-node-btn-target {
  color: #bef811;
  background: rgba(189,248,17,0.12);
}
.flow-node-btn-del {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.flow-node-btn:hover .flow-node-btn-del { opacity: 1; }
.flow-node-btn-del:hover { color: #ff6b6b; background: rgba(255,90,90,0.18); }
.flow-node-port {
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #7b2ff2;
  border: 2px solid #15171b;
  cursor: crosshair;
  z-index: 3;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.flow-node-port:hover,
.flow-node-port.dragging {
  transform: translateY(-50%) scale(1.25);
  box-shadow: 0 0 12px rgba(123,47,242,0.8);
}
.flow-node-btn.handoff .flow-node-port { background: #bef811; }
.flow-node-btn.handoff .flow-node-port:hover { box-shadow: 0 0 12px rgba(189,248,17,0.8); }

/* Connection path hover (click to delete) */
.scenario-canvas-svg path.connection {
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke-width 0.12s ease;
}
.scenario-canvas-svg path.connection:hover { stroke: #ff6b6b !important; stroke-width: 2.4 !important; }

/* Ghost/dragging connection preview */
.scenario-canvas-svg path.ghost {
  stroke: #bef811;
  stroke-width: 2;
  stroke-dasharray: 5 4;
  fill: none;
  pointer-events: none;
}

.scenario-canvas-side {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
}
.scenario-canvas-side .filter-group { margin-bottom: 12px; }
.scenario-canvas-side .filter-group:last-child { margin-bottom: 0; }
.scenario-canvas-side label { font-size: 10px; letter-spacing: 0.14em; }
.scenario-canvas-side input[type="text"],
.scenario-canvas-side textarea {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}
.scenario-canvas-side .row { gap: 6px; flex-wrap: wrap; }
.scenario-canvas-side .stat-filter-select { max-width: 100%; }
.scenario-canvas-side .hint { font-size: 10px; margin-top: 4px; }
.scenario-canvas-side .toolbar-btn {
  width: 100%;
  justify-content: center;
}

/* ── Media dropzone ───────────────────────────────────────── */
.media-dropzone {
  margin-top: 8px;
  border: 1.5px dashed rgba(123,47,242,0.45);
  border-radius: var(--radius);
  background: rgba(123,47,242,0.04);
  padding: 10px 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.media-dropzone.dragover {
  border-color: #bef811;
  background: rgba(189,248,17,0.08);
}
.media-dropzone-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
}
.media-dropzone-inner svg { color: var(--accent); flex-shrink: 0; }
.media-dropzone-progress {
  margin-top: 8px;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.media-dropzone-progress::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: mdProg 1.2s linear infinite;
}
@keyframes mdProg {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.media-preview {
  margin-top: 8px;
  padding: 6px;
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius);
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.media-preview img,
.media-preview video {
  max-width: 80px;
  max-height: 60px;
  border-radius: 4px;
  object-fit: cover;
  background: rgba(255,255,255,0.05);
}

@media (max-width: 1200px) {
  .scenario-canvas-layout { grid-template-columns: 180px 1fr 300px; }
}
@media (max-width: 1000px) {
  .scenario-canvas-layout { grid-template-columns: 1fr 300px; }
  .scenario-canvas-nav { display: none; }
}
@media (max-width: 900px) {
  .scenario-canvas-layout { grid-template-columns: 1fr; height: auto; }
  .scenario-canvas-viewport { height: 420px; }
  .scenario-canvas-side { max-height: none; }
}

@media (max-width: 1100px) {
  .support-layout { grid-template-columns: 280px 1fr 280px; }
}

@media (max-width: 900px) {
  .support-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    max-height: none;
  }
  .support-chat-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 45vh;
  }
  .support-profile {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .support-msg { max-width: 92%; }
  .auto-reply-row { grid-template-columns: 1fr; }
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Tablet / small desktop */
@media (max-width: 1100px) {
  .page { padding: 16px 20px 40px; }
  .main-content, #err { padding-left: 20px; padding-right: 20px; }
}

/* Mobile (drawer sidebar + dense forms) */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 260px;
    --titlebar-h: 54px;
  }

  body { font-size: 13px; }

  .app-layout { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
    z-index: 100;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.55);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop { display: block; }

  .main-content {
    width: 100%;
    height: 100vh;
    overflow-y: auto;
  }

  .hamburger { display: inline-flex; }

  /* Titlebar */
  .header {
    padding: 0 14px;
    gap: 10px;
    height: var(--titlebar-h);
  }
  .header-title {
    gap: 10px;
    flex: 1;
    min-width: 0;
  }
  .header-title::before { width: 5px; height: 5px; }
  .header h1 { font-size: 12px; letter-spacing: 0.14em; }
  .header .muted { font-size: 9.5px; letter-spacing: 0.12em; }

  /* Page padding */
  .page { padding: 14px 14px 36px; }
  #err { margin: 12px 14px 0; }

  /* Panels */
  .panel { padding: 14px; border-radius: var(--radius); }
  .panel h2 { font-size: 9.5px; letter-spacing: 0.2em; }

  label { font-size: 10px; letter-spacing: 0.18em; }

  /* Buttons — bigger tap targets */
  button {
    height: 36px;
    padding: 6px 14px;
    font-size: 11px;
  }
  .linkish, .toolbar-btn { height: 32px; padding: 4px 12px; }

  /* Inputs — taller for touch */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="datetime-local"] {
    height: 38px;
    font-size: 14px; /* prevents iOS zoom on focus */
    min-width: 0;
  }
  input[type="date"],
  input[type="datetime-local"] { min-width: 0; width: 100%; }

  /* Row layout wraps better */
  .row { gap: 8px; }
  .filters-row { gap: 14px; flex-direction: column; align-items: stretch; }
  .filter-group { width: 100%; }

  /* Tabs / segmented controls — allow horizontal scroll if overflow */
  .tabs, .date-presets {
    overflow-x: auto;
    max-width: 100%;
    flex-wrap: nowrap;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .tab { padding: 5px 12px; height: 30px; font-size: 10px; }
  .preset-btn { padding: 3px 10px; height: 28px; font-size: 10px; }

  /* Stats cards */
  .stats-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 11px 12px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 9.5px; }

  /* Time range picker */
  .time-range-picker,
  .time-range-trigger { width: 100%; min-width: 0; }
  .time-range-dropdown {
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(var(--titlebar-h) + 8px);
    min-width: 0;
    max-height: calc(100vh - var(--titlebar-h) - 20px);
  }

  /* Stats range row + refresh button — stack full-width */
  .stats-range-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .stats-refresh-btn {
    width: 100%;
    height: 38px;
    justify-content: center;
    font-size: 12px;
  }

  /* Split stat cards — stack contents on mobile */
  .stat-split { gap: 12px; }
  .stat-split-divider { display: none; }
  .stat-split-main, .stat-sub {
    flex: 1 1 100%;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }
  .stat-split-main:first-child { border-top: none; padding-top: 0; }
  .stat-subvalue { font-size: 20px; }
  .stat-sublabel { font-size: 9px; }

  /* Leads filter select inside stat label */
  .stat-label-with-filter { gap: 6px; }
  .stat-filter-select {
    max-width: 60%;
    height: 26px;
    font-size: 11px;
  }

  /* Multi-select (tasks, composer task dropdown) */
  .multi-select { min-width: 0; width: 100%; }
  .multi-select-trigger { height: 38px; font-size: 14px; }

  /* Tables — keep them scrollable inside wrapper */
  .table-wrap > .table { min-width: 560px; }
  .table th, .table td { padding: 8px 10px; font-size: 12px; }
  .table th { font-size: 10px; letter-spacing: 0.12em; }

  /* Pagination — more tappable */
  .pagination button {
    min-width: 34px;
    height: 32px;
    font-size: 11px;
  }

  /* User card grid */
  .user-card-grid { grid-template-columns: 1fr; gap: 12px; }
  .card-field-value { font-size: 13px; }

  /* Professions list */
  .profession-row { padding: 8px 12px; font-size: 11.5px; }
  .profession-rank { width: 22px; font-size: 10px; }
  .profession-count { font-size: 12px; }
  .profession-percent { font-size: 10px; min-width: 42px; }

  /* Profession pills inside users table — allow wrap */
  .profession-pill-list { max-width: 220px; }
  .profession-pill { max-width: 160px; font-size: 9.5px; padding: 1px 8px; }

  /* Filter chips and profession chips */
  .filter-chip { font-size: 10px; }

  /* Modal — full-bleed on mobile */
  .modal-overlay { padding: 20px 12px; align-items: flex-start; }
  .modal {
    max-width: 100%;
    max-height: calc(100vh - 40px);
    border-radius: var(--radius-lg);
  }
  .modal-header { padding: 12px 16px; }
  .modal-header h3 { font-size: 13px; }
  .modal-body { padding: 14px 16px; }

  /* Broadcast composer */
  .bcast-textarea { min-height: 120px; font-size: 14px; padding: 10px 12px; }
  .bcast-preview { padding: 10px 12px; }
  .bcast-preview-text { font-size: 12px; }
  .bcast-user-search { height: 40px; padding: 0 10px; }
  .bcast-user-search input { font-size: 14px; }
  .bcast-search-results { max-height: 240px; }
  .bcast-chip { max-width: 170px; font-size: 10px; }
  .bcast-stats { grid-template-columns: 1fr 1fr; }
  .bcast-stats strong { font-size: 15px; }
  .bcast-stats span { font-size: 9px; }

  /* Sidebar brand on mobile (inside drawer) */
  .sidebar-brand { padding: 18px 18px 14px; }
  .brand-name { font-size: 16px; }

  /* Sidebar links — bigger tap target in drawer */
  .sidebar-link { padding: 10px 12px; font-size: 13px; }
  .sidebar-icon-tile { width: 26px; height: 26px; }
}

/* Very small phones */
@media (max-width: 420px) {
  .page { padding: 12px 10px 32px; }
  #err { margin: 10px 10px 0; }
  .panel { padding: 12px; }
  .stats-cards { grid-template-columns: 1fr; }
  .bcast-stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 20px; }
  .header { padding: 0 10px; }
  .header h1 { font-size: 11px; }
  .header .muted { display: none; }
  .toolbar-btn { padding: 4px 10px; font-size: 10px; }
  .profession-pill-list { max-width: 160px; }

  /* Login */
  .login-panel {
    margin: 8vh 14px;
    max-width: calc(100% - 28px);
    padding: 22px 20px;
  }
  .login-panel h1 { font-size: 16px; }
  .login-panel input { font-size: 14px; }
  .login-panel button { height: 40px; font-size: 12px; }
}

/* ═════════════════════════════════════════════════════════════
   LIGHT THEME
   Applied via <html data-theme="light"> — scoped variable + rule
   overrides. Dark theme is the default.
   ═════════════════════════════════════════════════════════════ */

[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f5f9;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --bg-elev: rgba(0, 0, 0, 0.025);
  --elev-2: rgba(0, 0, 0, 0.04);

  --border: rgba(17, 17, 26, 0.09);
  --border-strong: rgba(17, 17, 26, 0.16);
  --separator: rgba(17, 17, 26, 0.08);
  --separator-strong: rgba(17, 17, 26, 0.16);

  --text: #1a1a22;
  --text-secondary: #55565f;
  --text-tertiary: #8b8c94;
  --muted: #7a7b84;
  --dim: #ebecf0;

  --control-bg: #ffffff;
  --control-bg-hover: rgba(17, 17, 26, 0.04);
  --control-bg-active: rgba(17, 17, 26, 0.08);
  --control-stroke: rgba(17, 17, 26, 0.12);

  --accent: #6722d6;
  --accent-hover: #5b1cc1;
  --accent-fill: rgba(103, 34, 214, 0.10);
  --accent-dim: rgba(103, 34, 214, 0.08);
  --selection: rgba(103, 34, 214, 0.18);

  --high: #dc2626;
  --high-dim: rgba(220, 38, 38, 0.09);
  --mid: #d97706;
  --mid-dim: rgba(217, 119, 6, 0.10);
  --low: #7c3aed;
  --low-dim: rgba(124, 58, 237, 0.09);
  --violet: #7c3aed;

  --green: #059669;
  --red: #dc2626;
  --orange: #d97706;
  --yellow: #ca8a04;
  --purple: #7c3aed;
  --pink: #db2777;

  --shadow-panel: 0 1px 2px rgba(17,17,26,0.04), 0 6px 20px rgba(17,17,26,0.06);
  --shadow-popover: 0 0 0 1px rgba(17,17,26,0.08), 0 12px 36px rgba(17,17,26,0.12);
  --shadow-accent: 0 0 0 1px rgba(103,34,214,0.3), 0 4px 12px rgba(103,34,214,0.18);
}

/* Body background tint — softer radial glow, subtle grid */
[data-theme="light"] body::before {
  background-image:
    radial-gradient(circle at 50% 40%, rgba(103, 34, 214, 0.045) 0%, transparent 55%),
    radial-gradient(circle at 15% 85%, rgba(168, 85, 247, 0.03) 0%, transparent 50%);
}
[data-theme="light"] body::after {
  background-image:
    linear-gradient(rgba(17, 17, 26, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 26, 0.04) 1px, transparent 1px);
}

/* Sidebar */
[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--border);
}
[data-theme="light"] .sidebar-link { color: var(--text-secondary); }
[data-theme="light"] .sidebar-link:hover {
  background: var(--control-bg-hover);
  color: var(--text);
}
[data-theme="light"] .sidebar-link.active {
  background: var(--accent-fill);
  color: var(--accent);
}
[data-theme="light"] .sidebar-icon-tile {
  background: rgba(103, 34, 214, 0.08);
  border-color: rgba(103, 34, 214, 0.2);
}

/* Header */
[data-theme="light"] .header {
  background: rgba(255, 255, 255, 0.85);
  border-bottom-color: var(--border);
  backdrop-filter: saturate(180%) blur(6px);
}
[data-theme="light"] .header h1 { color: var(--text); }

/* Panels */
[data-theme="light"] .panel {
  background: var(--panel-solid);
  border-color: var(--border);
  box-shadow: var(--shadow-panel);
}

/* Inputs / textareas / selects */
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="datetime-local"],
[data-theme="light"] textarea {
  background: var(--control-bg);
  color: var(--text);
  border-color: var(--border-strong);
}
[data-theme="light"] input[type="text"]:focus,
[data-theme="light"] input[type="password"]:focus,
[data-theme="light"] input[type="number"]:focus,
[data-theme="light"] input[type="date"]:focus,
[data-theme="light"] input[type="datetime-local"]:focus,
[data-theme="light"] textarea:focus {
  background: #fff;
  border-color: rgba(103, 34, 214, 0.55);
  box-shadow: 0 0 0 3px rgba(103, 34, 214, 0.12);
}
[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.6;
}

/* Buttons */
[data-theme="light"] button {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}
[data-theme="light"] button:hover {
  background: var(--accent-hover);
}
[data-theme="light"] button:disabled {
  background: rgba(17, 17, 26, 0.06);
  color: var(--muted);
}

/* Linkish / toolbar buttons */
[data-theme="light"] .linkish,
[data-theme="light"] .toolbar-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}
[data-theme="light"] .linkish:hover,
[data-theme="light"] .toolbar-btn:hover {
  background: var(--accent-fill);
  border-color: var(--accent);
  color: var(--accent);
}

/* Preset (chip) buttons */
[data-theme="light"] .preset-btn {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
[data-theme="light"] .preset-btn:hover {
  background: rgba(103, 34, 214, 0.05);
  color: var(--text);
  border-color: rgba(103, 34, 214, 0.35);
}
[data-theme="light"] .preset-btn.active {
  background: var(--accent-fill);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(103, 34, 214, 0.35);
}

/* Tabs */
[data-theme="light"] .tab {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
}
[data-theme="light"] .tab:hover { color: var(--text); background: transparent; }
[data-theme="light"] .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tables */
[data-theme="light"] .table th {
  background: #fafbfd;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .table td { border-bottom: 1px solid var(--border); }
[data-theme="light"] .table tbody tr:hover { background: rgba(103, 34, 214, 0.04); }

/* Cards (stat, profession, user, etc.) */
[data-theme="light"] .stat-card {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(17,17,26,0.03);
}
[data-theme="light"] .stat-value {
  color: var(--accent);
  text-shadow: none;
}
[data-theme="light"] .stat-label { color: var(--muted); }
[data-theme="light"] .stat-delta-up   { color: #059669; }
[data-theme="light"] .stat-delta-down { color: #dc2626; }

[data-theme="light"] .profession-row {
  background: #ffffff;
  border: 1px solid var(--border);
}
[data-theme="light"] .profession-row:hover { background: rgba(103, 34, 214, 0.04); }
[data-theme="light"] .profession-row.active {
  background: rgba(103, 34, 214, 0.08);
  border-color: rgba(103, 34, 214, 0.35);
}

/* Badges */
[data-theme="light"] .badge-active {
  background: rgba(5, 150, 105, 0.10);
  color: #047857;
  border: 1px solid rgba(5, 150, 105, 0.25);
}
[data-theme="light"] .badge-expired {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.25);
}
[data-theme="light"] .badge-none {
  background: #f3f4f7;
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Filter chips */
[data-theme="light"] .filter-chip,
[data-theme="light"] .bcast-chip {
  background: var(--accent-fill);
  color: var(--accent);
  border: 1px solid rgba(103, 34, 214, 0.3);
}

/* Multi-select / time-range triggers */
[data-theme="light"] .multi-select-trigger,
[data-theme="light"] .time-range-trigger,
[data-theme="light"] .stats-refresh-btn {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
}
[data-theme="light"] .multi-select-trigger:hover,
[data-theme="light"] .time-range-trigger:hover,
[data-theme="light"] .stats-refresh-btn:hover {
  border-color: rgba(103, 34, 214, 0.4);
  background: rgba(103, 34, 214, 0.04);
}
[data-theme="light"] .multi-select-dropdown,
[data-theme="light"] .time-range-dropdown {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: var(--shadow-popover);
}
[data-theme="light"] .multi-select-option:hover { background: rgba(103, 34, 214, 0.06); }

/* Stat filter select (card-embedded) */
[data-theme="light"] .stat-filter-select {
  background-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2355565f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  border-color: var(--border-strong);
  color: var(--text);
}
[data-theme="light"] .stat-filter-select option { background: #fff; color: var(--text); }

/* Users list total badge */
[data-theme="light"] .users-list-total {
  background: var(--accent-fill);
  border-color: rgba(103, 34, 214, 0.28);
  color: var(--accent);
}
[data-theme="light"] .users-list-total.empty {
  background: #f3f4f7;
  border-color: var(--border);
  color: var(--muted);
}

/* Modals */
[data-theme="light"] .modal-overlay { background: rgba(17, 17, 26, 0.4); }
[data-theme="light"] .modal {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 24px 64px rgba(17,17,26,0.2);
}

/* Pagination */
[data-theme="light"] .pagination button {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
[data-theme="light"] .pagination button:hover {
  background: rgba(103, 34, 214, 0.06);
  color: var(--text);
}
[data-theme="light"] .pagination button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Support — chat layout */
[data-theme="light"] .support-chat-list { background: #fafbfd; }
[data-theme="light"] .support-chat-item:hover { background: rgba(103, 34, 214, 0.05); }
[data-theme="light"] .support-chat-item.active { background: rgba(103, 34, 214, 0.10); }
[data-theme="light"] .support-chat-item-avatar { background: rgba(17, 17, 26, 0.06); color: var(--text); }
[data-theme="light"] .support-chat-item-badge { background: var(--accent); color: #fff; }
[data-theme="light"] .support-chat-view { background: #ffffff; }
[data-theme="light"] .support-msg.in {
  background: #f1f2f6;
  border-color: var(--border);
  color: var(--text);
}
[data-theme="light"] .support-msg.out {
  background: var(--accent-fill);
  border-color: rgba(103, 34, 214, 0.3);
  color: var(--text);
}
[data-theme="light"] .support-composer { background: #fafbfd; }
[data-theme="light"] .support-composer-row textarea {
  background: #ffffff;
  border-color: var(--border-strong);
  color: var(--text);
}
[data-theme="light"] .support-quick-chip {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
[data-theme="light"] .support-quick-chip:hover { background: var(--accent-fill); border-color: rgba(103, 34, 214, 0.4); color: var(--accent); }
[data-theme="light"] .support-profile { background: #fafbfd; }
[data-theme="light"] .support-note {
  background: #fff;
  border: 1px solid var(--border);
}

/* Support — scenario/canvas builder */
[data-theme="light"] .scenario-panel { background: #fff; }
[data-theme="light"] .scenario-canvas-toolbar {
  background: #f6f7fb;
  border-color: var(--border);
}
[data-theme="light"] .scenario-scenes,
[data-theme="light"] .scenario-canvas-nav {
  background: #fafbfd;
  border-color: var(--border);
}
[data-theme="light"] .scene-item:hover,
[data-theme="light"] .scenario-canvas-nav-item:hover { background: rgba(103, 34, 214, 0.06); }
[data-theme="light"] .scene-item.active,
[data-theme="light"] .scenario-canvas-nav-item.active {
  background: rgba(103, 34, 214, 0.10);
  border-left-color: var(--accent);
}
[data-theme="light"] .scenario-editor,
[data-theme="light"] .scenario-canvas-side { background: #fafbfd; border-color: var(--border); }
[data-theme="light"] .scenario-canvas-viewport {
  background:
    linear-gradient(rgba(103,34,214,0.02), rgba(103,34,214,0.02)),
    radial-gradient(circle at 1px 1px, rgba(17,17,26,0.09) 1px, transparent 0);
  border-color: var(--border);
}

/* Flow nodes */
[data-theme="light"] .flow-node {
  background: #ffffff;
  border-color: var(--border-strong);
  box-shadow: 0 1px 2px rgba(17,17,26,0.04), 0 8px 24px rgba(17,17,26,0.08);
  color: var(--text);
}
[data-theme="light"] .flow-node-head { background: rgba(103, 34, 214, 0.1); }
[data-theme="light"] .flow-node-text { color: var(--text-secondary); }
[data-theme="light"] .flow-node-btn { border-top-color: var(--border); }
[data-theme="light"] .flow-node-btn:hover { background: rgba(103, 34, 214, 0.04); }
[data-theme="light"] .flow-node-btn-target {
  background: rgba(17, 17, 26, 0.06);
  color: var(--text-secondary);
}
[data-theme="light"] .flow-node-port { border-color: #ffffff; }
[data-theme="light"] .flow-node.drop-target {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.3), 0 8px 24px rgba(17,17,26,0.12);
}

/* Scene-button sub-row */
[data-theme="light"] .scene-btn-row { background: #f6f7fb; border-color: var(--border); }
[data-theme="light"] .scene-btn-row .btn-row-delete {
  background: #fff;
  border-color: var(--border);
}

/* Media dropzone */
[data-theme="light"] .media-dropzone {
  background: rgba(103, 34, 214, 0.04);
  border-color: rgba(103, 34, 214, 0.3);
}
[data-theme="light"] .media-dropzone.dragover {
  background: rgba(5, 150, 105, 0.06);
  border-color: #059669;
}
[data-theme="light"] .media-preview { background: #ffffff; }

/* Auto-reply row */
[data-theme="light"] .auto-reply-row {
  background: #ffffff;
  border: 1px solid var(--border);
}

/* Error banner */
[data-theme="light"] .error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.35);
  color: #b91c1c;
}

/* Stat delta base colors */
[data-theme="light"] .stat-delta-zero { color: var(--muted); }
[data-theme="light"] .stat-delta-na { color: var(--text-tertiary); }

/* Subvalue text */
[data-theme="light"] .stat-subvalue { color: var(--text); }

/* Sidebar brand */
[data-theme="light"] .brand-name { color: var(--text); }
[data-theme="light"] .brand-sub { color: var(--muted); }
[data-theme="light"] .brand-mark { background: var(--accent); box-shadow: 0 0 12px var(--accent); }

/* Login */
[data-theme="light"] .login-panel {
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
}

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover {
  border-color: rgba(123,47,242,0.45);
  color: var(--accent);
  background: var(--accent-fill);
}
.theme-toggle .sun-icon,
.theme-toggle .moon-icon { display: none; }
[data-theme="light"] .theme-toggle .moon-icon { display: block; }
:not([data-theme="light"]) .theme-toggle .sun-icon { display: block; }
