/* ============================================================
   dopovo.bet Remarketing Console
   Design system: Operations Console
   ============================================================ */

:root {
  /* Surface — deep cool black with subtle blue tilt */
  --surface-0: oklch(7% 0.012 240);
  --surface-1: oklch(10% 0.014 240);
  --surface-2: oklch(14% 0.016 240);
  --surface-3: oklch(18% 0.018 240);
  --surface-inset: oklch(5% 0.010 240);

  /* Text — warm-tinted off-white (NOT pure #fff) */
  --text: oklch(94% 0.012 80);
  --text-dim: oklch(72% 0.018 80);
  --text-mute: oklch(50% 0.014 80);
  --text-faint: oklch(35% 0.012 80);

  /* Lines */
  --line: oklch(22% 0.018 240);
  --line-strong: oklch(30% 0.020 240);

  /* Accents */
  --live: oklch(82% 0.21 142);          /* electric lime */
  --live-soft: oklch(82% 0.21 142 / 0.12);
  --live-glow: oklch(82% 0.21 142 / 0.45);
  --send: oklch(74% 0.18 28);           /* warm coral */
  --send-soft: oklch(74% 0.18 28 / 0.12);
  --warn: oklch(80% 0.16 85);
  --warn-soft: oklch(80% 0.16 85 / 0.14);
  --crit: oklch(68% 0.22 25);
  --crit-soft: oklch(68% 0.22 25 / 0.14);
  --info: oklch(72% 0.14 220);
  --info-soft: oklch(72% 0.14 220 / 0.12);

  /* Chart palette */
  --chart-1: oklch(82% 0.21 142);       /* lime */
  --chart-2: oklch(74% 0.18 28);        /* coral */
  --chart-3: oklch(72% 0.14 220);       /* ice */
  --chart-4: oklch(80% 0.16 85);        /* amber */
  --chart-5: oklch(70% 0.18 320);       /* magenta */

  /* Motion */
  --t-fast: 120ms cubic-bezier(0.16, 1, 0.3, 1);
  --t-base: 220ms cubic-bezier(0.16, 1, 0.3, 1);
  --t-slow: 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-0);
  color: var(--text);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, oklch(15% 0.04 142 / 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, oklch(15% 0.04 28 / 0.10), transparent 60%),
    var(--surface-0);
}

#app { min-height: 100vh; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--text); text-decoration: none; }

/* ============================================================
   Layout shell
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: oklch(12% 0.018 240);
  border: 1px solid oklch(30% 0.03 25 / 0.7);
  display: grid;
  place-items: center;
  padding: 5px;
  box-shadow: 0 0 0 1px oklch(68% 0.22 25 / 0.12), 0 8px 22px oklch(68% 0.22 25 / 0.16);
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-meta { line-height: 1.1; }
.brand-name {
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.brand-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-mute);
  margin-top: 4px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  font-size: 13.5px;
  position: relative;
  transition: color var(--t-fast), background var(--t-fast);
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-item.active {
  color: var(--text);
  background: var(--surface-2);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--live);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--live-glow);
}

.nav-glyph {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-kbd {
  margin-left: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  color: var(--text-faint);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.live-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live-glow);
  animation: live-pulse 1.8s ease-out infinite;
}

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 var(--live-glow); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}

.btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--live);
  color: var(--surface-0);
  border-color: var(--live);
  font-weight: 600;
}
.btn-primary:hover { background: oklch(86% 0.20 142); border-color: transparent; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--crit);
  border-color: oklch(68% 0.22 25 / 0.25);
}
.btn-danger:hover { background: var(--crit-soft); }

.btn-block { width: 100%; }

/* ============================================================
   Main content
   ============================================================ */

.main {
  padding: 32px 40px 64px;
  max-width: 1480px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  animation: rise var(--t-slow) both;
}

.topbar h1 {
  font-family: "DM Sans", sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.1;
}

.topbar p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13.5px;
  max-width: 64ch;
}

.topbar .topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes rise-soft {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   KPI row
   ============================================================ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  animation: rise-soft var(--t-base) both;
  transition: border-color var(--t-base), transform var(--t-base);
}
.kpi:nth-child(1) { animation-delay: 40ms; }
.kpi:nth-child(2) { animation-delay: 80ms; }
.kpi:nth-child(3) { animation-delay: 120ms; }
.kpi:nth-child(4) { animation-delay: 160ms; }

.kpi:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.kpi::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, oklch(82% 0.21 142 / 0.4), transparent);
  opacity: 0;
  transition: opacity var(--t-base);
}
.kpi:hover::after { opacity: 1; }

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.kpi-label .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 6px var(--live-glow);
}

.kpi-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-delta {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.kpi-delta.up   { color: var(--live); background: var(--live-soft); }
.kpi-delta.down { color: var(--crit); background: var(--crit-soft); }
.kpi-delta.flat { color: var(--text-mute); background: var(--surface-2); }

/* ============================================================
   Cards / panels
   ============================================================ */

.card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  position: relative;
}

.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-h h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-h p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-mute);
}

.card-h .actions {
  display: flex;
  gap: 6px;
}

/* ============================================================
   Charts (with hover/tooltip/drilldown)
   ============================================================ */

.chart-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px 8px;
  position: relative;
  overflow: hidden;
}

.chart-card .chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.chart-card .chart-title h2 {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.chart-card .chart-title .total {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.chart-card .chart-sub {
  font-size: 11.5px;
  color: var(--text-mute);
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.chart-wrap {
  position: relative;
}

.chart-svg {
  width: 100%;
  height: 240px;
  display: block;
  overflow: visible;
}

.chart-grid line.grid {
  stroke: var(--line);
  stroke-dasharray: 2 4;
  stroke-width: 1;
}

.chart-axis-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  fill: var(--text-faint);
  letter-spacing: 0.04em;
}

.chart-line {
  fill: none;
  stroke: var(--chart-1);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 0 transparent);
  transition: stroke-width var(--t-fast), filter var(--t-base);
}

.chart-line.dimmed { opacity: 0.25; }

.chart-area {
  fill: var(--chart-1);
  fill-opacity: 0.10;
}

.chart-bar {
  fill: var(--chart-2);
  transition: fill var(--t-fast), transform var(--t-base);
  transform-origin: center bottom;
  cursor: pointer;
}
.chart-bar:hover { fill: var(--chart-1); }

.chart-bar.dimmed { opacity: 0.18; }

.chart-point {
  fill: var(--chart-1);
  stroke: var(--surface-1);
  stroke-width: 2;
  cursor: pointer;
  transition: r var(--t-fast), filter var(--t-base);
}
.chart-point:hover { filter: drop-shadow(0 0 6px var(--live-glow)); }

.chart-hover-rect {
  fill: transparent;
  cursor: crosshair;
}

.chart-hover-target {
  fill: transparent;
  cursor: pointer;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  box-shadow: 0 12px 32px oklch(0% 0 0 / 0.5);
  z-index: 10;
  opacity: 0;
  transform: translate(-50%, -110%) scale(0.96);
  transition: opacity var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
  font-family: "JetBrains Mono", monospace;
}
.chart-tooltip.show {
  opacity: 1;
  transform: translate(-50%, -110%) scale(1);
}
.chart-tooltip .tt-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-family: "DM Sans", sans-serif;
  margin-bottom: 4px;
}
.chart-tooltip .tt-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.chart-active-dot {
  fill: var(--surface-0);
  stroke: var(--chart-1);
  stroke-width: 2.5;
}

.chart-active-bar {
  fill: oklch(86% 0.18 28);
  filter: drop-shadow(0 0 8px oklch(74% 0.18 28 / 0.4));
}

/* Chart legend */
.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 0 0;
  font-size: 11.5px;
  color: var(--text-mute);
}
.legend .swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}

/* ============================================================
   System health card
   ============================================================ */

.health-card {
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  align-items: center;
}

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.04em;
}
.health-pill.ok   { background: var(--live-soft); color: var(--live); }
.health-pill.warn { background: var(--warn-soft); color: var(--warn); }
.health-pill.crit { background: var(--crit-soft); color: var(--crit); }

.health-pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.health-counts {
  display: flex;
  gap: 18px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}
.health-counts .count {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.health-counts .count .num {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.health-counts .ok   .num { color: var(--live); }
.health-counts .warn .num { color: var(--warn); }
.health-counts .crit .num { color: var(--crit); }
.health-counts .count .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  font-family: "DM Sans", sans-serif;
}

.findings-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.finding-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.finding-pill.warn { color: var(--warn); border-color: oklch(80% 0.16 85 / 0.3); }
.finding-pill.crit { color: var(--crit); border-color: oklch(68% 0.22 25 / 0.3); }
.finding-pill .d { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-1);
  overflow: hidden;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  font-weight: 500;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: "DM Sans", sans-serif;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.data thead th .sort-arrow { opacity: 0.4; margin-left: 4px; }
table.data thead th.sorted .sort-arrow { opacity: 1; color: var(--live); }

table.data tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast);
}
table.data tbody tr:last-child { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }

table.data tbody td {
  padding: 12px 16px;
  vertical-align: middle;
}

table.data .mono {
  font-family: "JetBrains Mono", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--text);
}

table.data .cell-muted {
  color: var(--text-mute);
  font-size: 12px;
}

table.data .pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.pill.ok   { background: var(--live-soft); color: var(--live); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.dim  { background: var(--surface-2); color: var(--text-dim); }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-dim);
}

.table-pagination .page-btns {
  display: flex;
  gap: 4px;
}

.page-btn {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 5px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.page-btn:hover { background: var(--surface-3); color: var(--text); }
.page-btn.active { background: var(--live); color: var(--surface-0); border-color: var(--live); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============================================================
   Forms
   ============================================================ */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  margin-bottom: 8px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0;
  border-color: var(--live);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--live-soft);
}

.field textarea {
  resize: vertical;
  min-height: 100px;
  font-family: "DM Sans", sans-serif;
}

.code-textarea {
  font-family: "JetBrains Mono", monospace !important;
  font-size: 12px !important;
  line-height: 1.5;
}

.templates-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-row {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.template-row:hover,
.template-row.active {
  border-color: var(--live);
  background: var(--live-soft);
}

.template-row span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-row strong {
  font-size: 13px;
  font-weight: 600;
}

.template-row em {
  color: var(--text-mute);
  font-size: 11.5px;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-row small {
  color: var(--text-dim);
  font-size: 11px;
  flex: 0 0 auto;
}

.templates-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
}

.asset-result {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.asset-result img {
  width: 96px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.asset-result strong {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.asset-result input {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
}

.email-preview {
  width: 100%;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.segment {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: all var(--t-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.segment strong {
  font-weight: 500;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.segment strong .count {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 400;
}
.segment span {
  font-size: 11.5px;
  color: var(--text-mute);
}
.segment:hover { border-color: var(--line-strong); }
.segment.active {
  border-color: var(--live);
  background: var(--live-soft);
}
.segment.active strong { color: var(--live); }

/* ============================================================
   Two-col grid
   ============================================================ */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
}

/* ============================================================
   Login
   ============================================================ */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(800px 600px at 50% 30%, oklch(18% 0.05 142 / 0.12), transparent 70%),
    radial-gradient(600px 400px at 80% 80%, oklch(15% 0.05 28 / 0.10), transparent 60%),
    var(--surface-0);
}

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 30px 60px oklch(0% 0 0 / 0.4);
  animation: rise var(--t-slow) both;
}

.login-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: oklch(12% 0.018 240);
  border: 1px solid oklch(30% 0.03 25 / 0.7);
  display: grid;
  place-items: center;
  padding: 7px;
  margin-bottom: 22px;
  box-shadow: 0 0 0 1px oklch(68% 0.22 25 / 0.12), 0 10px 30px oklch(68% 0.22 25 / 0.18);
  overflow: hidden;
}

.login-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.2;
}

.login-card p {
  font-size: 13.5px;
  color: var(--text-dim);
  margin: 0 0 24px;
}

/* ============================================================
   Toasts
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 12px 32px oklch(0% 0 0 / 0.4);
  z-index: 1000;
  transform: translateY(20px);
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: oklch(82% 0.21 142 / 0.4); }
.toast.error   { border-color: oklch(68% 0.22 25 / 0.4); color: var(--crit); }

/* ============================================================
   Modal (kept minimal — used only for confirm)
   ============================================================ */

.modal-back {
  position: fixed;
  inset: 0;
  background: oklch(0% 0 0 / 0.6);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fade-in var(--t-base) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  animation: rise var(--t-base) both;
}

/* ============================================================
   Empty states
   ============================================================ */

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13.5px;
}
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; }

/* ============================================================
   Helpers
   ============================================================ */

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 6px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-22 { margin-top: 22px; }
.mb-12 { margin-bottom: 12px; }
.mb-22 { margin-bottom: 22px; }
.muted { color: var(--text-mute); }
.dim   { color: var(--text-dim); }
.tabnum { font-variant-numeric: tabular-nums; font-family: "JetBrains Mono", monospace; }
.hidden { display: none; }
.relative { position: relative; }
.flex1 { flex: 1; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }
.gap-14 { gap: 14px; }

/* ============================================================
   Modal + funnel + clickable rows (tracking/results)
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.loading { cursor: wait; }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}

.modal-body {
  padding: 26px;
}

.modal-body .kpi-row {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 22px;
}

.modal-body .kpi-row:last-of-type {
  margin-bottom: 28px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  margin: 0 0 14px;
}

.funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 110px 80px 64px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.funnel-stage {
  color: var(--text-dim);
  text-transform: capitalize;
}

.funnel-count { color: var(--text); }
.funnel-pct { color: var(--text-mute); }

.funnel-bar {
  height: 8px;
  background: linear-gradient(90deg, var(--live), var(--live-soft));
  border-radius: 4px;
  min-width: 4px;
}

.clickable {
  cursor: pointer;
}

table.data tr.clickable:hover {
  background: var(--surface-3);
}

.topbar-meta .input {
  min-width: 110px;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.modal-tabs .tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 16px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}

.modal-tabs .tab:hover {
  color: var(--text);
}

.modal-tabs .tab.active {
  color: var(--live);
  border-bottom-color: var(--live);
}

.lead-filters {
  margin-bottom: 16px;
}

.lead-filters .input {
  max-width: 320px;
}

.lead-table .lead-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}

.lead-table .lead-email {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}


/* Tracking por disparo */
.tracking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.tracking-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.tracking-header .count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}

.tracking-filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tracking-filters .filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tracking-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.tracking-filters label svg,
.tracking-filters label .icon {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}
.tracking-filters .input,
.tracking-filters select {
  width: 100%;
  background: var(--surface-0);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.tracking-filters .input:hover,
.tracking-filters select:hover {
  border-color: var(--text-dim);
}
.tracking-filters .input:focus,
.tracking-filters select:focus {
  outline: none;
  border-color: var(--live);
  box-shadow: 0 0 0 3px var(--live-soft);
}
.tracking-filters .input::placeholder {
  color: var(--text-dim);
}
.tracking-filters .input[type="date"] {
  color-scheme: dark;
}
.tracking-filters .filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.tracking-filters .btn-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.tracking-filters .btn-clear:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--text-dim);
}
@media (max-width: 1200px) {
  .tracking-filters { grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 900px) {
  .tracking-filters { grid-template-columns: 1fr 1fr; }
  .tracking-filters .filter-field.search { grid-column: span 2; }
}
@media (max-width: 600px) {
  .tracking-filters { grid-template-columns: 1fr; }
  .tracking-filters .filter-field.search { grid-column: span 1; }
  .tracking-filters .filter-actions { justify-content: stretch; }
  .tracking-filters .btn-clear { width: 100%; }
}

.tracking-table-wrap {
  position: relative;
  min-height: 320px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
}
.tracking-table {
  width: 100%;
  border-collapse: collapse;
}
.tracking-table th,
.tracking-table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
}
.tracking-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tracking-table tbody tr { border-bottom: 1px solid var(--line); }
.tracking-table tbody tr:last-child { border-bottom: 0; }
.tracking-table tbody tr:hover { background: var(--surface-2); }
.tracking-summary {
  margin-bottom: 14px;
}
.tracking-summary.secondary {
  margin-top: -4px;
  margin-bottom: 22px;
}
.tracking-table th:nth-child(1), .tracking-table td:nth-child(1) { min-width: 260px; max-width: 420px; }
.tracking-table th:nth-child(2), .tracking-table td:nth-child(2) { white-space: nowrap; }
.tracking-table th:nth-child(n+3), .tracking-table td:nth-child(n+3) { text-align: right; white-space: nowrap; }
.tracking-table th:last-child, .tracking-table td:last-child { width: 1%; }
.tracking-table td small {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
}

.cell-campaign .campaign-name {
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}
.cell-campaign .campaign-slug {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-lead .lead-name {
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}
.cell-lead .lead-email {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 3px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-status .pill {
  text-transform: capitalize;
}

.page-btn.compact {
  padding: 6px 10px;
  min-height: 30px;
  font-size: 11px;
}

.tracking-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(10, 10, 14, 0.7);
  backdrop-filter: blur(2px);
  z-index: 5;
}
.tracking-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--live);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.tracking-loading p {
  font-size: 13px;
  color: var(--text-dim);
}
@keyframes spin { to { transform: rotate(360deg); } }

.tracking-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 64px 24px;
  color: var(--text-dim);
  text-align: center;
}
.tracking-empty strong {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.tracking-empty p {
  font-size: 13px;
  margin: 0;
}

.tracking-table-wrap .table-pagination {
  border-top: 1px solid var(--line);
  border-radius: 0 0 11px 11px;
}
.tracking-table-wrap .table-pagination .page-info {
  font-weight: 500;
  color: var(--text-dim);
}
.tracking-table-wrap .table-pagination .page-info strong {
  color: var(--text);
  font-weight: 600;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
  .shell { grid-template-columns: 200px 1fr; }
  .main { padding: 24px 28px 48px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .health-card { grid-template-columns: 1fr; }
  .segment-grid { grid-template-columns: repeat(2, 1fr); }
  .templates-layout { grid-template-columns: 1fr; }
  .templates-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px; }
  .kpi-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar h1 { font-size: 24px; }
}
