:root {
  --bg: #06070a;
  --surface: rgba(14, 17, 25, 0.84);
  --surface-solid: #0d1018;
  --surface-2: rgba(21, 26, 38, 0.9);
  --border: rgba(212, 175, 55, 0.18);
  --border-strong: rgba(212, 175, 55, 0.42);
  --text: #f5f2ea;
  --muted: #98a2b3;
  --gold: #d4af37;
  --gold-light: #f6dc87;
  --gold-deep: #9e7818;
  --emerald: #10b981;
  --amethyst: #a855f7;
  --cyan: #38bdf8;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(circle at 12% -8%, rgba(212, 175, 55, 0.13) 0%, transparent 45%),
    radial-gradient(circle at 88% 8%, rgba(16, 185, 129, 0.08) 0%, transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(168, 85, 247, 0.06) 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.mono { font-family: 'JetBrains Mono', monospace; }
.muted { color: var(--muted); }
.small { font-size: 0.83rem; }
.m-0 { margin: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 13px 28px;
  background: rgba(7, 9, 14, 0.86);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-emblem {
  position: relative; width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(135deg, #f8e192 0%, #d4af37 55%, #8f6a12 100%);
  color: #090a0e; display: grid; place-items: center;
  font-size: 1.35rem; font-weight: 900;
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.32);
}
.pulse-ring {
  position: absolute; inset: -3px; border-radius: 15px;
  border: 1px solid rgba(246, 220, 135, 0.45);
  animation: pulseRing 2.6s ease-out infinite;
}
@keyframes pulseRing {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.18); opacity: 0; }
}
.brand-title { font-size: 1.18rem; font-weight: 900; display: flex; align-items: center; gap: 8px; letter-spacing: 0.2px; }
.gold-pill {
  background: linear-gradient(135deg, rgba(246, 220, 135, 0.2), rgba(212, 175, 55, 0.08));
  color: var(--gold-light); border: 1px solid rgba(212, 175, 55, 0.48);
  font-size: 0.68rem; font-weight: 800; padding: 1px 9px; border-radius: 999px;
}
.brand-sub { font-size: 0.77rem; color: var(--muted); }

.nav-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-tab {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 8px 14px; border-radius: 11px; font-family: inherit; font-weight: 700; font-size: 0.9rem;
  cursor: pointer; transition: all 0.2s ease;
}
.nav-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-tab.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.16), rgba(212, 175, 55, 0.05));
  color: var(--gold-light);
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: 0 0 18px rgba(212, 175, 55, 0.12);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shield-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
  background: rgba(16, 185, 129, 0.11); color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.shield-pill.paused {
  background: rgba(245, 158, 11, 0.14); color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.42);
}
.emerald-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}
.shield-pill.paused .emerald-dot {
  background: var(--warn); box-shadow: 0 0 10px var(--warn);
}

/* Container & KPIs */
.container { max-width: 1360px; margin: 0 auto; padding: 24px 20px 64px; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px; margin-bottom: 22px;
}
@media (max-width: 1180px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kpi-card {
  position: relative; overflow: hidden;
  background: var(--surface); backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; inset-inline: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.35), transparent);
}
.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 30px rgba(212, 175, 55, 0.08);
}
.kpi-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.kpi-val { font-size: 1.8rem; font-weight: 900; line-height: 1.15; letter-spacing: -0.5px; }
.kpi-sub { font-size: 0.77rem; }

.kpi-emerald .kpi-val { color: #34d399; }
.kpi-emerald #kpi-open-rate { color: #6ee7b7; font-weight: 700; }
.kpi-gold .kpi-val {
  background: linear-gradient(135deg, #fcebb6, #d4af37);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.kpi-amethyst .kpi-val { color: #c084fc; }
.kpi-slate .kpi-val { color: #cbd5e1; }
.kpi-cyan .kpi-val { color: #38bdf8; }

/* Panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.panel-card {
  background: var(--surface); backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.36);
}
.glass-gold {
  border-color: rgba(212, 175, 55, 0.34);
  background: linear-gradient(155deg, rgba(22, 20, 14, 0.88), rgba(11, 14, 22, 0.92));
}
.panel-card h2, .panel-card h3 { margin-top: 0; margin-bottom: 6px; font-weight: 800; }
.card-header-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}

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

/* Form Controls & Buttons */
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid rgba(212, 175, 55, 0.22); border-radius: 10px;
  padding: 10px 13px; font-family: inherit; font-size: 0.9rem; outline: none;
  width: 100%; transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; min-width: 165px; }

.btn-gold {
  background: linear-gradient(135deg, #f8e192 0%, #d4af37 55%, #b1861b 100%);
  color: #090a0e; border: none; border-radius: 10px; padding: 10px 18px;
  font-family: inherit; font-weight: 800; font-size: 0.9rem; cursor: pointer;
  box-shadow: 0 4px 18px rgba(212, 175, 55, 0.25); transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-gold:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-gold:disabled { opacity: 0.55; cursor: wait; }

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #03150e; border: none; border-radius: 10px; padding: 10px 18px;
  font-family: inherit; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.04); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px;
  font-family: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: all 0.18s ease;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-light); }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; border-radius: 9px; }

/* Charts & Heatmaps */
.legend-row { display: flex; gap: 14px; align-items: center; font-size: 0.82rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-emerald { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.dot-amethyst { background: var(--amethyst); box-shadow: 0 0 8px var(--amethyst); }

.svg-chart-wrap { width: 100%; min-height: 225px; }
.heatmap-wrap {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 7px; margin-top: 8px;
}
@media (max-width: 680px) { .heatmap-wrap { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.heat-cell {
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px; padding: 8px 4px; text-align: center;
  display: flex; flex-direction: column; gap: 2px;
}
.heat-cell strong { font-size: 0.86rem; }
.heat-cell span { font-size: 0.7rem; color: var(--muted); }

/* Hot Leads & Mini Events */
.hot-leads-list, .mini-events-list, .ip-list { display: flex; flex-direction: column; gap: 9px; }
.hot-item, .mini-ev-row, .ip-row {
  background: rgba(255, 255, 255, 0.025); border: 1px solid rgba(212, 175, 55, 0.14);
  border-radius: 12px; padding: 11px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.hot-item { cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.hot-item:hover { border-color: var(--gold); background: rgba(212, 175, 55, 0.06); }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td {
  text-align: right; padding: 12px 12px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.12); vertical-align: middle;
}
.data-table th { color: var(--gold-light); font-weight: 700; font-size: 0.8rem; white-space: nowrap; opacity: 0.9; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: rgba(212, 175, 55, 0.04); }
html[dir="ltr"] .data-table th, html[dir="ltr"] .data-table td { text-align: left; }

/* Semantic Badges & Counters */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 800; white-space: nowrap;
}
.pill-client { background: rgba(16, 185, 129, 0.16); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.pill-hot { background: rgba(212, 175, 55, 0.18); color: #f6dc87; border: 1px solid rgba(212, 175, 55, 0.55); }
.pill-self { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.45); }
.pill-mpp { background: rgba(245, 158, 11, 0.15); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.38); }
.pill-bot { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }
.pill-click { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.42); }
.pill-unopened { background: rgba(255, 255, 255, 0.04); color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.1); }

.counter-stack { display: flex; flex-direction: column; gap: 3px; }
.open-bar-bg { width: 90px; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.open-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--emerald)); border-radius: 999px; }

/* Manual Tracker & Settings Forms */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; } }

.field-lbl { display: block; font-size: 0.78rem; color: var(--gold-light); font-weight: 700; margin-bottom: 5px; }
.empty-box {
  background: rgba(255, 255, 255, 0.02); border: 1px dashed rgba(212, 175, 55, 0.3);
  border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); line-height: 1.7;
}
.manual-action-hero {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.14), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(212, 175, 55, 0.4); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
.copy-input-row { display: flex; gap: 8px; align-items: center; }
.code-snippet {
  background: #050609; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 0.82rem; color: #f6dc87; white-space: pre-wrap; word-break: break-all;
}

.steps-box { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.step-pill {
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(212, 175, 55, 0.16);
  border-radius: 11px; padding: 10px 12px; font-size: 0.86rem; display: flex; align-items: center; gap: 10px;
}
.step-pill span {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
  background: linear-gradient(135deg, #f6dc87, #d4af37); color: #090a0e;
  display: grid; place-items: center; font-weight: 900; font-size: 0.8rem;
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.shield-toggles-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ip-add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ip-add-row input { flex: 1; min-width: 150px; }
.options-row { display: flex; gap: 18px; flex-wrap: wrap; }
.chk-label { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--text); cursor: pointer; }
.chk-label input { width: auto; accent-color: var(--gold); }

/* Slide-Over Luxury Detail Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(2, 3, 6, 0.74); backdrop-filter: blur(6px);
  z-index: 90; display: flex; justify-content: flex-end;
}
html[dir="rtl"] .drawer-backdrop { justify-content: flex-start; }
.detail-drawer {
  width: 100%; max-width: 540px; height: 100%; overflow-y: auto;
  padding: 24px; border-inline-end: 1px solid var(--border-strong);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.75);
}
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.drawer-eyebrow { font-size: 0.72rem; color: var(--gold-light); font-weight: 800; letter-spacing: 0.8px; }
.drawer-header h3 { margin: 4px 0; font-size: 1.08rem; }
.drawer-meta-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px;
}
.meta-box {
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(212, 175, 55, 0.16);
  border-radius: 10px; padding: 9px 12px;
}
.meta-box span { display: block; font-size: 0.74rem; color: var(--muted); }
.meta-box strong { font-size: 0.88rem; }
.drawer-counters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.drawer-section-title { font-weight: 800; color: var(--gold-light); margin-bottom: 10px; font-size: 0.9rem; }
.drawer-timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-card {
  background: rgba(255, 255, 255, 0.025); border: 1px solid rgba(212, 175, 55, 0.16);
  border-radius: 12px; padding: 12px 14px;
}
.timeline-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Auth Modal & Toast */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 4, 8, 0.88); backdrop-filter: blur(10px);
  display: grid; place-items: center; z-index: 120; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 440px; border-radius: 18px; padding: 28px;
  display: flex; flex-direction: column; gap: 13px; border: 1px solid var(--border-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}
.modal-badge {
  align-self: flex-start; background: rgba(212, 175, 55, 0.14); color: var(--gold-light);
  border: 1px solid rgba(212, 175, 55, 0.4); font-size: 0.72rem; font-weight: 800;
  padding: 4px 11px; border-radius: 999px; letter-spacing: 0.5px;
}
.error-text { color: var(--danger); font-size: 0.86rem; }

.toast-banner {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #16130b, #0c1412);
  color: var(--gold-light); border: 1px solid var(--border-strong);
  padding: 12px 22px; border-radius: 12px; font-weight: 700; font-size: 0.9rem;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.65); z-index: 200;
}
