:root {
  --bg: #0f0f14;
  --card: #1a1a22;
  --accent: #9370db;
  --muted: #b0b0b0;
  --line: #ffffff14;
  --pad: clamp(16px, 3vw, 32px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  min-height: 100%;
  touch-action: manipulation;
}
html, body { min-height: 100%; }
body {
  font-family: Poppins, system-ui, sans-serif;
  background: radial-gradient(900px 480px at 80% -10%, #9370db33, transparent 60%), var(--bg);
  color: #fff;
}
.bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(#ffffff10 1px, transparent 1px),
    linear-gradient(90deg, #ffffff10 1px, transparent 1px);
  background-size: 120px 120px;
}
.hidden { display: none !important; }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
body.hide-range #range,
body.hide-range #datepicker-wrap,
body.hide-range #summary { display: none !important; }
.brand-icon {
  display: block;
  flex: none;
  border-radius: 10px;
  box-shadow: 0 4px 20px #9370db44;
}
.brand-icon--lg {
  margin: 0 auto 8px;
  border-radius: 18px;
  box-shadow: 0 8px 32px #9370db55;
}
.brand-icon--md { border-radius: 12px; opacity: 0.95; }
.brand-icon--sm { border-radius: 8px; box-shadow: none; }
.kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
h1 { font-size: 36px; letter-spacing: -0.04em; }
.lead { color: var(--muted); font-size: 15px; }
.error { color: #fb7185; min-height: 1.2em; font-size: 13px; }
.banner {
  margin: 0 var(--pad) 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fb71851a;
  color: #fb7185;
  font-size: 13px;
}
.banner a { color: inherit; font-weight: 700; }
.linkbtn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
}
.charts {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.chart-card { min-height: 280px; }
.chart-card h3 { margin-bottom: 12px; }
.chart-wrap { position: relative; height: 240px; }
.chart-wrap.pie {
  width: min(100%, 240px);
  height: 240px;
  margin: 0 auto;
  aspect-ratio: 1;
}
.spark {
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 10px;
}
.app-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  background: var(--app-accent, var(--accent));
}
.app-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card.app { cursor: pointer; box-shadow: none; border-left: 3px solid var(--app-accent, var(--accent)); }
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.summary-card {
  margin-bottom: 16px;
}
.summary-card pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  color: #e8e8ef;
}
.summary-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.summary-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #000000aa;
  backdrop-filter: blur(4px);
}
.summary-modal-card {
  width: min(100%, 420px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 80px #00000066;
}
.summary-modal-card h3 { font-size: 20px; }
.summary-result-card {
  width: min(100%, 640px);
  max-height: min(88vh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.summary-result-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.summary-result-titles { flex: 1; min-width: 0; }
.summary-result-titles h3 { font-size: 18px; margin-bottom: 4px; }
.summary-result-body {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #12121a;
  border: 1px solid var(--line);
  overflow: auto;
  flex: 1;
  max-height: min(60vh, 520px);
}
.md-body {
  font-size: 14px;
  line-height: 1.6;
  color: #e8e8ef;
  overflow-wrap: anywhere;
}
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  color: #fff;
  font-weight: 700;
  line-height: 1.3;
  margin: 1em 0 0.45em;
}
.md-body h1 { font-size: 1.35rem; }
.md-body h2 { font-size: 1.18rem; color: #c4b5fd; }
.md-body h3, .md-body h4 { font-size: 1.02rem; color: #ddd6fe; }
.md-body h1:first-child, .md-body h2:first-child, .md-body h3:first-child, .md-body p:first-child {
  margin-top: 0;
}
.md-body p { margin: 0.55em 0; }
.md-body ul, .md-body ol {
  margin: 0.45em 0 0.7em;
  padding-left: 1.3em;
}
.md-body li { margin: 0.25em 0; }
.md-body strong { color: #fff; font-weight: 700; }
.md-body em { color: #d4d4dc; }
.md-body a { color: #a78bfa; }
.md-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}
.md-body blockquote {
  margin: 0.7em 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: #9370db18;
  color: #d8d8e4;
}
.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: #ffffff12;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1em 0.35em;
  color: #f5f3ff;
}
.md-body pre {
  margin: 0.7em 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #0a0a10;
  border: 1px solid var(--line);
  overflow: auto;
}
.md-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.7em 0;
  font-size: 13px;
}
.md-body th, .md-body td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}
.md-body th { color: var(--muted); background: #ffffff08; }
.summary-modal-card select,
.summary-modal-card input[type="date"],
.summary-modal-card input[type="number"] {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #12121a;
  color: #fff;
  font: inherit;
}
.summary-modal-actions {
  margin-top: 4px;
  justify-content: flex-end;
}
.summary-custom .dp-row { margin-top: 0; }
.fb-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
}
.pill.generation_issue { background: #f59e0b33; color: #fbbf24; }
.pill.other { background: #94a3b833; color: #cbd5e1; }
.studio { margin-bottom: 16px; }
.studio .chart-wrap { height: 320px; }
.studio .chart-wrap canvas#studio-line {
  color: #fff;
}
.listing-settings .lead { margin-bottom: 12px; }
@media (max-width: 1100px) {
  .charts { grid-template-columns: 1fr; }
}

.gate {
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 24px 24px;
  position: relative;
  z-index: 1;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: none;
  border-radius: 20px;
  padding: 28px;
  display: grid;
  gap: 12px;
  box-shadow: inset 0 3px 0 var(--accent);
}
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input {
  background: #0f0f14;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #fff;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
}
button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: #fff;
}
#section-back,
#app-back {
  background: var(--accent);
  color: #fff;
  border: 0;
}

#app { position: relative; z-index: 1; padding-bottom: 48px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 20px var(--pad) 12px;
}
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.phone-only { display: none; }
.session-more-wrap { position: relative; }
.session-more {
  min-width: 44px;
  letter-spacing: 0.12em;
  padding: 10px 12px;
}
.session-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  display: grid;
  gap: 4px;
  box-shadow: 0 12px 32px #00000088;
}
.session-more-menu button {
  width: 100%;
  background: transparent;
  color: #fff;
  text-align: left;
  font-weight: 600;
  padding: 10px 12px;
}
.session-more-menu button:hover { background: #ffffff10; }
.seg {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.seg button {
  background: transparent;
  border-radius: 0;
  padding: 8px 12px;
  font-size: 13px;
}
.seg button.on { background: var(--accent); }
.tabs {
  display: flex;
  gap: 8px;
  padding: 0 var(--pad) 18px;
}
.tabs button {
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  padding: 8px 14px;
}
.tabs button.on { border-color: var(--accent); }
.page-seg-host {
  padding: 0 var(--pad) 14px;
}
.page-seg-host.hidden { display: none; }
.page-seg-host .page-seg {
  display: inline-flex;
}
.section-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--pad) 14px;
}
.section-bar.hidden { display: none; }
.section-bar h2 {
  font-size: 22px;
  letter-spacing: -0.03em;
}
.main-hub {
  padding-top: 0;
}

body.on-main #app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.on-main #view-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 72px;
}

section { padding: 0 var(--pad); }
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: none;
  border-radius: 18px;
  padding: 14px 16px;
}
.kpi span { color: var(--muted); font-size: 12px; display: block; margin-bottom: 4px; }
.kpi b { font-size: 22px; letter-spacing: -0.03em; }
.kpi-sub {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.funnel {
  display: flex;
  gap: 8px;
  align-items: stretch;
  overflow-x: auto;
  padding-bottom: 8px;
}
.funnel-step {
  min-width: 132px;
  flex: 1;
  background: var(--card);
  border: none;
  border-radius: 16px;
  padding: 14px;
}
.funnel-step .icon { font-size: 20px; display: block; margin-bottom: 8px; }
.funnel-step .lbl { color: var(--muted); font-size: 12px; }
.funnel-step b { display: block; font-size: 22px; margin: 4px 0; }
.funnel-step .cr { color: #34d399; font-size: 13px; font-weight: 700; }
.funnel-step .cr.miss { color: var(--muted); font-weight: 500; }
.funnel-arrow { color: var(--muted); align-self: center; font-size: 20px; flex: 0; }
.table-wrap { overflow-x: auto; }
.card {
  background: var(--card);
  border: none;
  border-radius: 18px;
  padding: 16px;
  text-align: left;
  color: inherit;
  width: 100%;
}
.card.app { cursor: pointer; box-shadow: none; border-left: 3px solid var(--app-accent, var(--accent)); }
.card h3 { font-size: 16px; margin-bottom: 10px; }
.stat { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.stat b { color: #fff; font-weight: 700; }
.note { color: var(--muted); font-size: 12px; margin-top: 8px; }
.warn { color: #fbbf24; font-size: 12px; margin-top: 8px; }

.kpi em { font-style: normal; font-size: 12px; font-weight: 700; margin-left: 6px; }
.kpi .up { color: #34d399; }
.kpi .down { color: #fb7185; }
.kpi .flat { color: var(--muted); }
.studio-tools { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.rank { width: 100%; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 52px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.bar-track { height: 10px; background: #ffffff10; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.search { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.search input, .search select { background: var(--card); color: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font: inherit; }
.stamp { color: var(--muted); font-size: 12px; padding: 0 var(--pad) 8px; }
.ghost.on { border-color: var(--accent); background: #9370db33; }
.charts-3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; margin: 16px 0; }
@media (max-width: 1100px) {
  .charts-3 { grid-template-columns: 1fr; }
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.country {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.flag {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #ffffff24;
  flex: none;
}
.flag-empty {
  display: grid;
  place-items: center;
  background: #ffffff10;
  font-size: 13px;
}
.country-rank {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}
.country-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) 1fr 52px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.country-row b { text-align: right; }
.country-row .bar-fill {
  background: linear-gradient(90deg, #38bdf8, #818cf8);
}
.table th { color: var(--muted); font-weight: 600; }
.events-table code { color: #fff; font-size: 12px; }
.events-table th:nth-child(n+2),
.events-table td:nth-child(n+2) { text-align: right; white-space: nowrap; }
.event-actions { display: flex; align-items: center; gap: 10px; }
.event-actions button { padding: 8px 12px; font-size: 12px; }
.event-analysis {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 12px;
  background: #0f0f14;
  border: 1px solid #9370db66;
}
.event-analysis h4 { margin-bottom: 8px; color: #c4b5fd; }
.event-analysis .md-body { font-size: 13px; }

.backlog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .backlog-grid { grid-template-columns: 1fr; }
}
.backlog-editor {
  width: 100%;
  min-height: 360px;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12121a;
  color: #fff;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}
.backlog-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #0f0f14;
  max-height: 520px;
  overflow: auto;
}
.backlog-inline {
  margin-top: 16px;
}
.backlog-inline .backlog-preview {
  margin-top: 10px;
  max-height: none;
}
.errors-table tbody tr.error-row-click {
  cursor: pointer;
}
.errors-table tbody tr.error-row-click:hover td {
  background: #ffffff0a;
}
button.inline-link {
  display: inline;
  padding: 0 2px;
  min-height: 0;
  font-size: inherit;
  vertical-align: baseline;
  border: none;
  background: transparent;
}
.event-analysis-loading { margin-bottom: 12px; }
.errors-table { min-width: 980px; }
.errors-table td { vertical-align: top; }
.error-time { white-space: nowrap; color: var(--muted); }
.error-message { min-width: 320px; max-width: 620px; white-space: pre-wrap; overflow-wrap: anywhere; }
.error-context { margin-top: 8px; color: var(--muted); }
.error-context summary { cursor: pointer; font-size: 12px; }
.error-context pre {
  margin-top: 6px;
  padding: 8px;
  border-radius: 8px;
  background: #0f0f14;
  color: #fff;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffffff12;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill.complaint { background: #fb718533; color: #fb7185; }
.pill.idea, .pill.suggestion { background: #34d39933; color: #34d399; }
.pill.tiktok { background: #00F2EA22; color: #00F2EA; }
.pill.instagram { background: #E1306C22; color: #E1306C; }
.muted { color: var(--muted); }

.feedback {
  display: grid;
  gap: 10px;
}
.fb {
  background: var(--card);
  border: none;
  border-radius: 16px;
  padding: 14px 16px;
}
.fb-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.fb p { white-space: pre-wrap; line-height: 1.45; }

.app-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.app-analytics-head .app-head { margin-bottom: 10px; }
.app-analytics-head .app-head-kpis { margin-bottom: 16px; }
.select {
  background: var(--card);
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
}

@media (max-width: 1100px) {
  .grid, .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid, .kpis { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
}
.setup { margin: 0 var(--pad) 18px; }
.setup .lead { margin: 8px 0 14px; }
.steps { color: var(--muted); font-size: 14px; line-height: 1.55; padding-left: 1.2em; display: grid; gap: 10px; margin-bottom: 16px; }
.steps a { color: #c4b5fd; }
.steps code, .copy {
  display: block;
  margin: 8px 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0f0f14;
  color: #fff;
  font-size: 13px;
  word-break: break-all;
}

/* Datepicker */
.datepicker-wrap { position: relative; }
.datepicker-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.datepicker-btn svg { flex: none; opacity: 0.7; }
.datepicker-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  background: #1e1e28;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 16px 40px #00000066;
  min-width: 260px;
}
.dp-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.dp-row label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.dp-row input[type="date"] {
  background: #0f0f14;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #fff;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  width: 100%;
  cursor: pointer;
}
.dp-row input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(0.5); cursor: pointer; }
.dp-apply {
  width: 100%;
  padding: 9px;
  font-size: 13px;
  border-radius: 10px;
}

/* KPI main highlight */
.kpi-main { border-color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent)33; }
.kpi-main b { color: var(--accent); }
.kpi-ios { border-color: #5AC8FA55 !important; }
.kpi-ios b { color: #5AC8FA; }
.kpi-android { border-color: #3DDC8455 !important; }
.kpi-android b { color: #3DDC84; }

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: #0f0f14d9;
  backdrop-filter: blur(10px);
  animation: loader-fade-in 0.2s ease;
}
@keyframes loader-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.app-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 32px 24px;
  border-radius: 20px;
  background: linear-gradient(165deg, #1f1f2a 0%, #15151c 100%);
  border: 1px solid #ffffff14;
  box-shadow: 0 24px 80px #00000066, 0 0 0 1px #9370db22 inset;
  min-width: min(92vw, 320px);
  text-align: center;
}
.loader-bar {
  width: 100%;
  max-width: 220px;
  height: 3px;
  border-radius: 99px;
  background: #ffffff14;
  overflow: hidden;
}
.loader-bar-fill {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #c4b5fd);
  animation: loader-bar-slide 1.2s ease-in-out infinite;
}
@keyframes loader-bar-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.loader-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 260px;
}
.loader-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.loader-hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  min-height: 1.35em;
}
.loader-hint:empty { display: none; }
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid #ffffff22;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--lg {
  width: 52px;
  height: 52px;
  border-width: 4px;
  border-top-color: #9370db;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.switch input {
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #ffffff18;
  border: 1px solid var(--line);
  position: relative;
  padding: 0;
  cursor: pointer;
  flex: none;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s ease;
}
.switch input:checked {
  background: var(--accent);
  border-color: transparent;
}
.switch input:checked::after { transform: translateX(18px); }
.store-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.store-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.store-card-head img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
}
.store-card .toggles {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.store-card .campaign-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.store-card .campaign-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.store-card .campaign-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.store-card .campaign-row input {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line, #2a2f3a);
  background: transparent;
  color: inherit;
}
.store-card label.url {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.store-card input[type="url"] {
  width: 100%;
}
.store-card .save-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.waitlist-box {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}
.waitlist-box .waitlist-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  font-size: 12px;
}
@media (max-width: 1200px) {
  .store-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .store-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBILE POLISH & RESPONSIVE — v7
   Breakpoints: 900px, 640px, 480px
   ============================================================ */

/* --- Improved card polish (all screens) --- */
.card {
  box-shadow: 0 2px 16px #00000033;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.card:hover { box-shadow: 0 6px 28px #00000055; }
.card.app:hover { transform: translateY(-2px); box-shadow: 0 8px 32px #00000055; }

.kpi {
  box-shadow: 0 2px 12px #00000028;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.kpi:hover { box-shadow: 0 6px 24px #00000050; transform: translateY(-1px); }

button:not(.seg button) { transition: opacity 0.14s ease, transform 0.14s ease; }
button:hover:not(:disabled) { opacity: 0.88; }
button:active:not(:disabled) { transform: scale(0.97); }

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- 900px: medium tablets --- */
@media (max-width: 900px) {
  h1 { font-size: 28px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .charts-3 { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- 640px: small tablets / large phones --- */
@media (max-width: 640px) {
  :root { --pad: 14px; }
  h1 { font-size: 24px; }

  /* Tabs: horizontal scroll, 5 items fit comfortably */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding: 0 var(--pad) 12px;
    gap: 6px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; font-size: 12px; padding: 7px 12px; flex-shrink: 0; }

  /* Header stacks */
  .top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px var(--pad) 8px;
  }
  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Range segment scrollable on small */
  .seg#range {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }
  .seg#range::-webkit-scrollbar { display: none; }
  .seg#range button { white-space: nowrap; padding: 8px 10px; font-size: 12px; }

  /* KPIs: 2 columns */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi b { font-size: 18px; }

  /* Store grid 1 col */
  .store-grid { grid-template-columns: 1fr; }

  /* Grid 1 col */
  .grid { grid-template-columns: 1fr; gap: 10px; }

  /* Charts 1 col */
  .charts, .charts-3 { grid-template-columns: 1fr; gap: 10px; margin: 10px 0; }

  /* Funnel: horizontal scroll already set, just ensure min-width */
  .funnel-step { min-width: 120px; }

  /* Stamp */
  .stamp { padding: 0 var(--pad) 6px; font-size: 11px; }

  /* Datepicker popup left-anchored on mobile */
  .datepicker-popup { right: auto; left: 0; min-width: 240px; }

  /* Waitlist rows wrap */
  .waitlist-box .waitlist-row {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
  }
  .waitlist-box .waitlist-row > :last-child { grid-column: 1 / -1; }

  /* Country rank */
  .country-row { grid-template-columns: 1fr 52px; }
  .country-row .bar-track { display: none; }

  /* Bar row label truncate */
  .bar-row { grid-template-columns: 80px 1fr 48px; }

  /* Table horizontal scroll already on .table-wrap, just ensure font */
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 6px; }

  /* Feedback items */
  .fb { padding: 12px; }
  .fb-top { gap: 6px; }

  /* Store save-row */
  .store-card .save-row { flex-direction: column; align-items: stretch; }
  .store-card .save-row button { width: 100%; }
  .store-card .campaign-row,
  .store-card .campaign-row-3 { grid-template-columns: 1fr; }

  /* Studio tools */
  .studio-tools { flex-direction: column; align-items: flex-start; }

  /* App head */
  .app-head { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Section spacing */
  section { padding: 0 var(--pad); }

  .desk-only { display: none !important; }
  .phone-only { display: block; }
  .session-more-wrap.phone-only { display: block; }

  .social-app-grid { grid-template-columns: 1fr; }
  #view-social .app-head { align-items: stretch; }
  #view-social .app-head > div:last-of-type {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  #view-social .app-head button { flex: 1; }
  #view-social .kpis { grid-template-columns: repeat(3, 1fr); }
  #view-social .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
  }
  #view-social .table { min-width: 520px; }
  .social-input { font-size: 16px; }
}

/* --- 480px: phones --- */
@media (max-width: 480px) {
  :root { --pad: 12px; }

  /* Login card full-width */
  .login-card {
    width: 100%;
    border-radius: 16px;
    padding: 22px 18px;
  }
  .gate { padding: 10vh 16px 24px; align-items: flex-start; }
  .gate .login-card { border-radius: 16px; }

  /* KPIs: 2 columns tight */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .kpi { padding: 12px; border-radius: 14px; }
  .kpi b { font-size: 17px; }
  .kpi span { font-size: 11px; }

  /* Tabs smaller */
  .tabs button { font-size: 11px; padding: 6px 10px; }

  /* Top actions full width */
  .top-actions > * { flex: 1 1 auto; }
  .session-more-wrap { flex: 0 0 auto !important; }
  .datepicker-btn { justify-content: center; }

  /* Charts height smaller */
  .chart-wrap { height: 200px; }
  .studio .chart-wrap { height: 260px; }

  /* Funnel smaller */
  .funnel-step { min-width: 100px; padding: 10px; }
  .funnel-step b { font-size: 18px; }
  .funnel-arrow { font-size: 16px; }

  /* Cards */
  .card { border-radius: 14px; padding: 14px; }
  .card h3 { font-size: 14px; }

  /* Setup steps code block */
  .steps code, .copy { font-size: 11px; padding: 8px 10px; }

  /* Feedback */
  .fb { border-radius: 12px; }

  /* Datepicker full width popup */
  .datepicker-popup { left: 0; right: 0; position: fixed; top: auto; bottom: 0; border-radius: 16px 16px 0 0; padding: 20px; box-shadow: 0 -8px 40px #00000088; }
  .dp-row { grid-template-columns: 1fr; }
}

.social-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.social-form input, .social-form select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: inherit; }

.section-loading {
  display: grid;
  place-items: center;
  align-content: center;
  justify-items: center;
  gap: 12px;
  min-height: 50vh;
  width: 100%;
  padding: 48px 16px;
  text-align: center;
}
/* ── Analytics lazy-load skeleton ──────────────────────────────────────── */
.analytics-loading {
  position: relative;
  inset: auto;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 50vh;
  width: 100%;
  padding: 48px 16px;
  pointer-events: auto;
}
.analytics-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.analytics-loading .spinner--lg {
  pointer-events: none;
}

.app-hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.main-hub-wrap {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  gap: 16px;
}
.app-hub-grid.main-hub {
  max-width: none;
  margin: 0;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.app-hub-grid.main-hub .app-hub-card {
  aspect-ratio: 16 / 9;
  min-height: 0;
  width: 100%;
}
.app-hub-card {
  position: relative;
  overflow: hidden;
  min-height: 200px;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: flex-end;
  text-align: left;
  color: inherit;
  font: inherit;
  background: var(--card);
}
.app-hub-card .hub-cover {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  object-fit: cover;
  filter: brightness(1.22) saturate(1.2) contrast(1.06);
}
.app-hub-card .hub-cover::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52%;
  background: linear-gradient(180deg, transparent 0%, #0f0f1455 42%, #0f0f14c4 100%);
  pointer-events: none;
}
.app-hub-card .hub-body {
  position: relative;
  z-index: 1;
  padding: 20px;
  display: grid;
  gap: 2px;
  text-shadow: 0 1px 10px #00000088;
}
.app-hub-card .hub-body h3 {
  margin: 0;
}
.app-hub-card .hub-body .muted {
  margin: 0;
  line-height: 1.35;
}
.hub-settings-fab {
  position: fixed;
  right: clamp(16px, 3vw, 28px);
  bottom: clamp(16px, 3vw, 28px);
  z-index: 50;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 16px;
  background: linear-gradient(145deg, #7c3aed 0%, #9370db 48%, #a78bfa 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 8px 28px #9370db88, 0 2px 8px #00000044;
}
.hub-settings-fab:hover {
  background: linear-gradient(145deg, #6d28d9 0%, #a78bfa 50%, #c4b5fd 100%);
  opacity: 1;
}
.hub-settings-fab svg {
  display: block;
}
.store-date-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.store-date-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: #9370db33;
  color: #e9e0ff;
  border: 1px solid #9370db55;
}
.store-date-chip.is-empty {
  background: #ffffff0a;
  color: var(--muted);
  border-color: var(--line);
  font-weight: 500;
}
.app-hub-card .hub-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffffffaa;
}
.app-hub-card h3 {
  font-size: 22px;
  font-weight: 700;
}
.feedback-stack {
  display: grid;
  gap: 16px;
}
.feedback-empty-card {
  max-width: 360px;
  margin: 32px auto;
  text-align: center;
}
.feedback-empty-card .fb-empty {
  padding: 8px 0 4px;
}
.fb {
  margin-bottom: 0;
}
.fb-actions {
  margin-left: auto;
}
@media (max-width: 720px) {
  .app-hub-grid,
  .app-hub-grid.main-hub { grid-template-columns: 1fr; }
}

/* ── Site countries rich rows ───────────────────────────────────────────── */
.site-countries-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.site-countries-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.site-countries-legend span { min-width: 52px; text-align: right; }

.country-row--rich {
  display: grid;
  grid-template-columns: 160px 1fr 52px 52px 52px 52px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.country-row--rich:last-child { border-bottom: none; }
.country-stat {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  min-width: 52px;
}

/* ── Social video tab ───────────────────────────────────────────────────── */
.social-app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.social-app-card {
  background: var(--card);
  border: none;
  border-left: 3px solid var(--app-accent, var(--accent));
  border-radius: 14px;
  padding: 12px 14px;
}
.social-app-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.social-app-head strong { flex: 1; min-width: 0; }
.social-collect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  margin-left: auto;
}
.social-collect input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.social-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  margin-top: 6px;
}
.social-field--limit input.social-limit {
  max-width: 88px;
}
.social-video {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.social-url {
  display: inline-flex;
  color: var(--accent);
  opacity: 0.85;
}
.social-url:hover { opacity: 1; }
.social-input {
  font: inherit;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: #fff;
  width: 100%;
  margin-top: 2px;
}
.social-input::placeholder {
  color: var(--muted);
  opacity: 1;
}
.social-loader {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0 4px;
}
.promo-modal-card { width: min(100%, 460px); }
.promo-modal-card .lead { margin: 0; }
.promo-modal-card form { display: flex; flex-direction: column; gap: 12px; }
.promo-modal-plats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.promo-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.promo-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.promo-list { display: grid; gap: 10px; margin-top: 12px; }
.promo-card {
  border-left: 3px solid var(--app-accent, var(--accent));
  background: #ffffff08;
  border-radius: 12px;
  padding: 12px 14px;
}
.promo-card.is-done { opacity: 0.55; }
.promo-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.promo-card-head img { border-radius: 8px; }
.promo-card-head div { flex: 1; min-width: 0; }
.promo-card-head p { margin: 2px 0 0; font-size: 12px; }
.promo-meter { margin-top: 8px; }
.promo-meter span { font-size: 12px; color: var(--muted); }
.promo-meter i {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: #ffffff14;
  margin-top: 4px;
  overflow: hidden;
}
.promo-meter b {
  display: block;
  height: 100%;
  background: var(--app-accent, var(--accent));
  border-radius: 99px;
}
.promo-pace { margin: 8px 0 0; font-size: 12px; }
@media (max-width: 980px) {
  .promo-form { grid-template-columns: 1fr 1fr; }
}
