:root {
  --bg: #070d18;
  --sidebar: #0b1220;
  --card: #111a2b;
  --card-2: #0e1726;
  --line: rgba(148, 163, 184, .16);
  --line-strong: rgba(148, 163, 184, .28);
  --text: #f4f7fb;
  --muted: #93a0b8;
  --faint: #6d7c95;
  --blue: #3b82f6;
  --blue-2: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --cyan: #38bdf8;
  --pink: #ec4899;
  --shadow: 0 10px 30px rgba(0, 0, 0, .18);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.nav-toggle, .nav-backdrop { display: none; }
.nav-toggle {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: #0e1728; color: white; font-size: 18px;
}
.sidebar {
  background: linear-gradient(180deg, #0c1424 0%, #0a101c 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 18px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(180deg, #60a5fa, #2563eb 55%, #7c3aed);
  display: grid; place-items: center; box-shadow: 0 8px 18px rgba(37, 99, 235, .35);
}
.logo svg { width: 22px; height: 22px; }
.brand strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.brand span { color: var(--faint); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: transparent; border: 0; color: #c5d0e0;
  border-radius: 10px; padding: 10px 12px; font-weight: 500;
}
.nav button svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: .9; }
.nav button.active { background: var(--blue-2); color: white; box-shadow: 0 8px 18px rgba(37, 99, 235, .28); }
.nav button:hover:not(.active) { background: rgba(255,255,255,.04); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.env-select, .menu, .daterange, .filter, .userchip {
  background: #0e1728; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 8px 10px;
}
.env-select { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.env-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 4px rgba(34,197,94,.15); display: inline-block; margin-right: 8px; }
.credits {
  background: #10192b; border: 1px solid var(--line); border-radius: 14px; padding: 14px;
}
.credits .label { color: var(--muted); font-size: 13px; }
.credits .top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.bar { height: 6px; border-radius: 99px; background: #1e293b; overflow: hidden; }
.bar i { display: block; height: 100%; width: 68%; background: linear-gradient(90deg, #2563eb, #60a5fa); border-radius: 99px; }
.credits small { display: block; color: var(--faint); margin-top: 8px; }
.upgrade {
  margin-top: 12px; background: transparent; border: 0; color: #f5c542;
  padding: 0; font-weight: 650; display: flex; gap: 6px; align-items: center;
}
.workspace { min-width: 0; }
.topbar {
  height: 72px; display: flex; align-items: center; gap: 16px;
  padding: 0 22px; border-bottom: 1px solid var(--line);
  background: rgba(7, 13, 24, .9); position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(16px);
}
.search {
  flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px;
  background: #0e1728; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; height: 42px;
}
.search input { flex: 1; background: transparent; border: 0; outline: none; }
.search svg, .icon-btn svg, .daterange svg { width: 16px; height: 16px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.daterange { display: flex; align-items: center; gap: 8px; height: 40px; color: #d5deea; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: #0e1728; display: grid; place-items: center; position: relative;
}
.badge-count {
  position: absolute; top: -4px; right: -4px; background: #ef4444; color: white;
  border-radius: 99px; font-size: 10px; min-width: 16px; height: 16px; display: grid; place-items: center; font-weight: 700;
}
.userchip { display: flex; align-items: center; gap: 10px; height: 48px; padding-right: 12px; }
.userchip b { display: block; font-size: 13px; }
.userchip span { color: var(--faint); font-size: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 99px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: white; flex: 0 0 auto;
  background: linear-gradient(180deg, #60a5fa, #1d4ed8);
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.photo { background: radial-gradient(circle at 50% 35%, #f3d2b5 0 28%, transparent 29%), linear-gradient(#1d4ed8, #0f172a); }
.content { padding: 26px 28px 40px; }
.page { display: none; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 32px; letter-spacing: -.03em; font-weight: 700; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: 1.15fr .85fr; }
.g-split { grid-template-columns: 1fr 1fr; }
.g-apps { grid-template-columns: repeat(3, 1fr); }
.g-bottom { grid-template-columns: 1.05fr 1.2fr .9fr; margin-top: 16px; }
.mt { margin-top: 16px; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent 40%), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h2 .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: #173056; color: #93c5fd; }
.card .sub { color: var(--muted); margin: 4px 0 14px; font-size: 13px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.kpi { min-height: 112px; }
.kpi .k { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.kpi .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi b { display: block; font-size: 28px; margin: 10px 0 2px; letter-spacing: -.03em; }
.kpi small, .delta { color: var(--faint); font-size: 12px; }
.up { color: var(--green); font-weight: 650; }
.down { color: #fb7185; font-weight: 650; }
.btn {
  border: 1px solid var(--line-strong); background: #182338; color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-weight: 600;
}
.btn.primary { background: var(--blue-2); border-color: transparent; color: white; box-shadow: 0 8px 16px rgba(37,99,235,.25); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
label.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
input[type="text"], input[type="search"], input[type="password"], select, .fake-input {
  background: #0c1424; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
.prefs { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.pref, .note-row, .rule, .channel, .sec-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid rgba(148, 163, 184, .08);
}
.pref span, .sec-row div b { display: block; }
.hint { color: var(--faint); font-size: 12px; margin-top: 2px; }
.check { accent-color: var(--blue-2); width: 16px; height: 16px; }
.switch {
  width: 42px; height: 24px; border-radius: 99px; border: 0; background: #334155; position: relative; flex: 0 0 auto;
}
.switch i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 99px; background: white; transition: .15s; }
.switch.on { background: var(--blue-2); }
.switch.on i { left: 21px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--faint); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid rgba(148,163,184,.08); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.who { display: flex; align-items: center; gap: 10px; }
.who small { display: block; color: var(--faint); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 3px 8px; font-size: 12px; font-weight: 650; background: #1e293b; color: #dbe4f0;
}
.pill.green { background: rgba(34,197,94,.15); color: #4ade80; }
.pill.blue { background: rgba(59,130,246,.18); color: #93c5fd; }
.pill.purple { background: rgba(139,92,246,.2); color: #c4b5fd; }
.pill.amber { background: rgba(245,158,11,.16); color: #fbbf24; }
.pill.red { background: rgba(239,68,68,.16); color: #fca5a5; }
.pill.gray { background: #1f2937; color: #cbd5e1; }
.dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; display: inline-block; }
.status { display: inline-flex; align-items: center; gap: 6px; }
.icon-link { background: transparent; border: 0; color: var(--muted); padding: 4px; }
.right { margin-left: auto; }
.chart { width: 100%; height: 210px; display: block; }
.chart.sm { height: 92px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.legend i { width: 8px; height: 8px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: center; }
.donut { width: 168px; height: 168px; }
.center-label { font-size: 20px; font-weight: 750; }
.bars { display: flex; align-items: flex-end; gap: 18px; height: 180px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .col b { width: 100%; border-radius: 8px 8px 4px 4px; }
.bars small { color: var(--muted); }
.app-card h3 { margin: 0; font-size: 18px; }
.app-top { display: flex; gap: 12px; align-items: flex-start; }
.app-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; }
.app-card p { color: var(--muted); min-height: 44px; }
.metrics-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.metrics-3 div { background: #0c1424; border-radius: 10px; padding: 8px; }
.metrics-3 span { color: var(--faint); font-size: 11px; display: flex; gap: 4px; align-items: center; }
.metrics-3 b { display: block; margin-top: 4px; }
.app-foot { display: flex; justify-content: space-between; align-items: center; color: var(--faint); font-size: 12px; }
.platforms { color: var(--faint); font-size: 12px; margin-left: 8px; }
.map {
  height: 200px; border-radius: 12px;
  background: #0c1424 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 220'><g fill='%2394a3b8' fill-opacity='.45'><circle cx='90' cy='70' r='1.2'/><circle cx='110' cy='80' r='1.2'/><circle cx='130' cy='64' r='1.2'/><circle cx='150' cy='90' r='1.2'/><circle cx='170' cy='76' r='1.2'/><circle cx='190' cy='100' r='1.2'/><circle cx='80' cy='100' r='1.2'/><circle cx='120' cy='110' r='1.2'/><circle cx='160' cy='120' r='1.2'/><circle cx='200' cy='80' r='1.2'/><circle cx='300' cy='70' r='1.2'/><circle cx='320' cy='84' r='1.2'/><circle cx='340' cy='68' r='1.2'/><circle cx='360' cy='96' r='1.2'/><circle cx='380' cy='78' r='1.2'/><circle cx='400' cy='110' r='1.2'/><circle cx='420' cy='90' r='1.2'/><circle cx='440' cy='70' r='1.2'/><circle cx='460' cy='100' r='1.2'/><circle cx='480' cy='84' r='1.2'/><circle cx='500' cy='120' r='1.2'/><circle cx='250' cy='140' r='1.2'/><circle cx='270' cy='156' r='1.2'/><circle cx='290' cy='148' r='1.2'/><circle cx='520' cy='150' r='1.2'/><circle cx='540' cy='166' r='1.2'/><circle cx='560' cy='150' r='1.2'/></g><circle cx='150' cy='90' r='7' fill='%2360a5fa'/><circle cx='180' cy='78' r='3' fill='%2322d3ee'/><circle cx='390' cy='88' r='7' fill='%23a78bfa'/><circle cx='430' cy='100' r='3' fill='%23c084fc'/><circle cx='300' cy='150' r='4' fill='%2334d399'/></svg>") center / contain no-repeat;
}
.cohort { display: flex; gap: 4px; }
.cohort span { width: 42px; text-align: center; border-radius: 4px; padding: 4px 0; font-size: 11px; background: #172033; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters .grow { margin-left: auto; display: flex; gap: 8px; }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline .ev { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: start; }
.pay { display: flex; gap: 16px; align-items: center; }
.card-brand { width: 48px; height: 32px; border-radius: 6px; background: linear-gradient(135deg, #ef4444, #f59e0b); }
.menu-pop, .dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); background: #121b2e; border: 1px solid var(--line);
  border-radius: 12px; min-width: 180px; padding: 6px; box-shadow: var(--shadow); z-index: 8; display: none;
}
.dropdown.open, .menu-pop.open { display: block; }
.dropdown button, .menu-pop button { width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; }
.dropdown button:hover, .menu-pop button:hover { background: rgba(255,255,255,.05); }
.rel { position: relative; }
.modal-back {
  position: fixed; inset: 0; background: rgba(2, 6, 16, .62); display: none; place-items: center; z-index: 20;
}
.modal-back.open { display: grid; }
.modal { width: min(460px, 92vw); background: #121b2e; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.modal h3 { margin: 0 0 6px; }
.modal p { color: var(--muted); margin: 0 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#toast {
  position: fixed; right: 22px; bottom: 22px; background: #17233a; border: 1px solid var(--line);
  padding: 12px 14px; border-radius: 12px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 50% 0%, rgba(37,99,235,.25), transparent 36%), var(--bg); }
.login-card { width: min(420px, 92vw); background: #111a2b; border: 1px solid var(--line); border-radius: 20px; padding: 28px; }
.login-card h1 { margin: 14px 0 4px; }
.login-card p { color: var(--muted); }
.login-card label { display: block; margin: 12px 0; color: var(--muted); }
.login-card input { width: 100%; margin-top: 6px; background: #0c1424; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.login-card button { width: 100%; margin-top: 8px; background: var(--blue-2); color: white; border: 0; border-radius: 10px; padding: 12px; font-weight: 700; }
.error { color: #fca5a5; }
.link { background: none; border: 0; color: #93c5fd; padding: 0; font-weight: 650; }
.mini-stats { display: flex; gap: 16px; }
.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: center; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge svg { width: 92px; height: 92px; }
.gauge b { font-size: 18px; }
.gauge small, .bar-chart small { color: var(--faint); }
.bar-chart { display: grid; grid-template-columns: 28px 1fr; gap: 8px; height: 230px; }
.bar-chart .ylab { display: flex; flex-direction: column; justify-content: space-between; color: var(--faint); font-size: 11px; }
.bar-chart .cols { display: flex; align-items: flex-end; gap: 16px; height: 100%; }
.bar-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; gap: 6px; min-width: 0; }
.bar-slot { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar-chart .col b, .bar-slot b { width: min(54px, 80%); border-radius: 8px 8px 3px 3px; }
.tip { fill: #0f172a; stroke: #334155; }
.ov-grid { display: grid; grid-template-columns: 1.35fr .8fr; gap: 16px; }
.ov-3 { display: grid; grid-template-columns: 1.15fr .85fr 1.05fr; gap: 16px; }
.ov-2 { display: grid; grid-template-columns: 1.25fr .9fr; gap: 16px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 36px; }
.spark i { width: 4px; border-radius: 3px; background: #3b82f6; display: block; }
.chart { max-width: 100%; }
.table-wrap { max-width: 100%; }
@media (max-width: 1440px) and (min-width: 1280px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  .content { padding: 18px 20px 32px; }
  .page-head h1 { font-size: 28px; }
  .kpi b { font-size: 24px; }
  .chart { height: 190px; }
}
@media (max-width: 1279px) and (min-width: 768px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .content { padding: 16px; }
  .page-head h1 { font-size: 26px; }
  .g-4, .g-apps, .g-3, .ov-3, .g-bottom { grid-template-columns: 1fr 1fr; }
  .ov-grid, .ov-2, .g-2, .g-split, .donut-wrap, .form-grid { grid-template-columns: 1fr; }
  .brand span, .nav button { font-size: 13px; }
}
@media (max-width: 767px) {
  .nav-toggle { display: grid; place-items: center; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 30; top: 0; left: 0; bottom: 0;
    width: min(280px, 86vw); height: 100vh;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .shell.nav-open .sidebar { transform: none; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 16, .62); z-index: 25; }
  .shell.nav-open .nav-backdrop { display: block; }
  .topbar { height: auto; padding: 12px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .top-actions { grid-column: 1 / -1; margin-left: 0; justify-content: space-between; }
  .search { max-width: none; }
  .userchip { display: none; }
  .daterange { min-width: 0; }
  .content { padding: 14px; }
  .page-head { flex-direction: column; }
  .page-head h1 { font-size: 26px; }
  .g-4, .g-apps, .g-3, .g-split, .g-2, .g-bottom, .ov-grid, .ov-3, .ov-2, .form-grid, .donut-wrap, .metrics-3 { grid-template-columns: 1fr; }
  .kpi b { font-size: 24px; }
  .chart { height: 180px; }
  .x-minor { display: none; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 560px; }
  .filters { align-items: stretch; }
  .filters .field, .filters select, .filters .grow { width: 100%; }
  .card-head { flex-direction: column; }
}
