/* ============================================================= *
 *  Design tokens — "Journey Board" premium light system (2026-07-19
 *  redesign). Light is the default/primary look; dark is an override
 *  kept for the existing theme toggle, not the other way around like
 *  before. Every color/radius/shadow/spacing value used across the
 *  admin (Jinja templates) should trace back to one of these — avoid
 *  introducing new raw hex/px values in individual templates.
 * ============================================================= */
:root {
  color-scheme: light;
  /* canvas / surfaces */
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e8ebf5;
  /* typography */
  --text: #171b36;
  --muted: #64708a;
  --soft: #3c4560;
  /* borders — thin, cool blue-gray, never a muddy neutral gray */
  --border: rgba(29,41,82,.10);
  --border-strong: rgba(29,41,82,.18);
  /* primary: indigo/violet, with distinct interaction states */
  --accent: #6c5ce7;
  --accent-hover: #5a48de;
  --accent-active: #4b39cb;
  --accent-2: #8f7ffb;
  --on-accent: #ffffff;
  /* semantic — good/danger/info picked to hold >=4.5:1 against white for
     solid-button use; warning (amber) intentionally pairs with dark text
     instead (see .btn.orange) since amber+white never reads accessibly */
  --good: #15803d;
  --warning: #d97706;
  --danger: #e11d48;
  --info: #2563eb;
  --on-warning: #171b36;
  /* shadows — 3 soft, realistic levels, no heavy black halos */
  --shadow-sm: 0 1px 2px rgba(23,27,54,.05), 0 1px 1px rgba(23,27,54,.03);
  --shadow: 0 8px 24px rgba(23,27,54,.07), 0 2px 6px rgba(23,27,54,.04);
  --shadow-lg: 0 24px 60px rgba(23,27,54,.12), 0 8px 20px rgba(23,27,54,.06);
  /* radius scale */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  /* spacing scale: 4/8/12/16/24/32 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  /* motion */
  --motion-fast: 140ms ease;
  --motion: 200ms ease;
  /* inputs */
  --input: #ffffff;
  --input-bd: rgba(29,41,82,.16);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17;
  --surface: #111827;
  --surface-2: #162033;
  --surface-3: #1c2638;
  --text: #eef4ff;
  --muted: #94a3b8;
  --soft: #cbd5e1;
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.16);
  --accent: #8f7ffb;
  --accent-hover: #a394ff;
  --accent-active: #7a68f0;
  --accent-2: #6c5ce7;
  --on-accent: #0b0f17;
  --good: #55d487;
  --warning: #f4bd50;
  --danger: #ff6b6b;
  --info: #6aa6ff;
  --on-warning: #1a1206;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.28);
  --shadow: 0 18px 48px rgba(0,0,0,.22);
  --shadow-lg: 0 32px 80px rgba(0,0,0,.5);
  --input: rgba(255,255,255,.06);
  --input-bd: rgba(255,255,255,.13);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
[data-theme="dark"] body {
  background:
    radial-gradient(circle at 18% 8%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 26%),
    linear-gradient(135deg, var(--bg), #0f1625 72%);
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
button, input, textarea, select { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 254px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--space-5) var(--space-3);
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  font-weight: 850;
}
.brand strong { display: block; font-size: 14px; line-height: 1.15; color: var(--text); }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.main-nav { display: grid; gap: 4px; }
.nav-section {
  padding: 0 9px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}
.nav-link {
  position: relative;
  min-height: 38px;
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  color: var(--soft);
  font-size: 14px;
  border: 1px solid transparent;
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.nav-link .nav-ic { flex: 0 0 auto; display: inline-flex; color: var(--muted); }
.nav-link .nav-label { flex: 1; min-width: 0; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover .nav-ic { color: var(--text); }
.nav-link.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent-active);
  font-weight: 640;
}
.nav-link.active .nav-ic { color: var(--accent); }
.nav-link.active::after {
  content: "";
  position: absolute;
  right: -1px;
  width: 3px;
  height: 18px;
  border-radius: 3px 0 0 3px;
  background: var(--accent);
}
.nav-link em {
  min-width: 23px;
  height: 20px;
  border-radius: 999px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.nav-link em[hidden] { display: none; }

.developer-tools {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}
.developer-tools summary {
  cursor: pointer;
  list-style: none;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--soft);
  font-size: 13px;
  background: var(--surface-2);
}
.developer-tools summary::-webkit-details-marker { display: none; }
.developer-tools summary:after { content: "згорнуто"; color: var(--muted); font-size: 12px; }
.developer-tools[open] summary:after { content: "відкрито"; }
.developer-tools a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--soft);
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.developer-tools a:hover { background: var(--surface-2); color: var(--text); }

.sidebar-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  padding: 0 var(--space-2);
}

.app-main {
  min-width: 0;
  padding: 18px 22px 36px;
}
.command-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(300px, 520px) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.page-title span,
.muted,
.hint { color: var(--muted); font-size: 12px; }
.page-title h1,
h1, h2, h3 { margin: 0; }
.page-title h1 { font-size: 24px; line-height: 1.15; }

.global-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
.global-search:before {
  content: "";
  position: absolute;
  left: 15px;
  width: 14px;
  height: 14px;
  border: 2px solid #7e8ca3;
  border-radius: 50%;
}
.global-search:after {
  content: "";
  position: absolute;
  left: 28px;
  width: 8px;
  height: 2px;
  background: #7e8ca3;
  transform: rotate(45deg);
  border-radius: 3px;
}
.global-search input {
  height: 44px;
  width: 100%;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--text);
  outline: none;
  padding: 0 90px 0 42px;
}
.global-search kbd {
  position: absolute;
  right: 10px;
  margin-left: 0;
  min-width: 28px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  background: rgba(0,0,0,.12);
  pointer-events: none;
}
.global-search kbd:first-of-type { right: 43px; }
.search-popover {
  position: absolute;
  left: 0;
  right: 0;
  top: 50px;
  z-index: 40;
  max-height: 520px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.search-popover h4,
.search-page-results h3 {
  margin: 8px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.search-popover a {
  display: block;
  padding: 9px;
  border-radius: var(--radius-sm);
}
.search-popover a:hover { background: var(--surface-2); }
.search-popover small,
.list-row small { display: block; margin-top: 3px; color: var(--muted); }
.search-empty { padding: 12px; color: var(--muted); }

.top-actions { display: flex; align-items: center; gap: 8px; }

/* Buttons: primary (.btn), secondary, ghost, danger, icon-only, ghost-icon.
   All share one transition/disabled/focus contract. */
.ghost-btn,
.icon-btn,
.quick-btn,
.btn {
  border: 0;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--on-accent);
  background: var(--accent);
  font-weight: 700;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast);
}
.ghost-btn:hover,
.icon-btn:hover,
.quick-btn:hover,
.btn:hover { background: var(--accent-hover); }
.ghost-btn:active,
.icon-btn:active,
.quick-btn:active,
.btn:active { background: var(--accent-active); }
.ghost-btn {
  height: 38px;
  padding: 0 var(--space-3);
  background: var(--surface);
  color: var(--soft);
  border: 1px solid var(--border);
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text); }
.ghost-btn:active { background: var(--surface-3); }
.quick-btn {
  width: 42px;
  height: 42px;
  font-size: 24px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  background: var(--surface);
  color: var(--soft);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.btn {
  min-height: 38px;
  padding: 0 var(--space-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.secondary:active { background: var(--surface-3); }
.btn.danger, .btn.red { background: var(--danger); color: #fff; }
.btn.danger:hover, .btn.red:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn.green { background: var(--good); color: #fff; }
.btn.green:hover { background: color-mix(in srgb, var(--good) 88%, black); }
.btn.orange { background: var(--warning); color: var(--on-warning); }
.btn.orange:hover { background: color-mix(in srgb, var(--warning) 88%, black); }
.btn.sm { min-height: 30px; padding: 0 var(--space-3); font-size: 12px; }
.btn[disabled],
.ghost-btn[disabled],
.icon-btn[disabled] {
  cursor: not-allowed;
  opacity: .55;
  pointer-events: none;
}
.btn.loading { color: transparent; position: relative; pointer-events: none; }
.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--on-accent) 40%, transparent);
  border-top-color: var(--on-accent);
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.loading::after { animation-duration: 1.2s; }
}

.dashboard-first-screen {
  min-height: calc(100vh - 92px);
  display: grid;
  grid-template-rows: auto auto auto minmax(300px, 1fr);
  gap: 18px;
}
.command-summary,
.panel-card,
.metric-panel,
.kpi-card,
.attention-item,
.card,
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.026));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
[data-theme="light"] .command-summary,
[data-theme="light"] .panel-card,
[data-theme="light"] .metric-panel,
[data-theme="light"] .kpi-card,
[data-theme="light"] .attention-item,
[data-theme="light"] .card,
[data-theme="light"] .panel { background: var(--surface); }

.command-summary {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto 160px;
  align-items: center;
  gap: 14px;
  padding: 14px;
}
.command-summary h2 { margin: 3px 0; font-size: 17px; }
.command-summary p { margin: 0; color: var(--muted); font-size: 13px; }
.period-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.period-switch a {
  height: 32px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.period-switch a.active { color: var(--text); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.business-health-card {
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.business-health-card span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.business-health-card strong { display: block; font-size: 26px; line-height: 1; margin: 5px 0; }
.business-health-card small { display: flex; gap: 7px; color: var(--muted); font-size: 10px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.kpi-card {
  min-height: 116px;
  padding: 15px;
  display: grid;
  align-content: space-between;
  border-top: 3px solid var(--border-strong);
}
.kpi-card:hover,
.attention-item:hover,
.metric-panel:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.kpi-card.revenue { border-top-color: var(--good); }
.kpi-card.sales { border-top-color: var(--accent); }
.kpi-card.conversion { border-top-color: var(--danger); }
.kpi-card.customers { border-top-color: #9aa8ff; }
.kpi-card.abandoned { border-top-color: var(--warning); }
.kpi-card span,
.metric-panel span { color: var(--muted); font-size: 12px; font-weight: 730; }
.kpi-card strong,
.metric-panel strong { font-size: 28px; line-height: 1; }
.kpi-card em,
.metric-panel em { font-size: 12px; font-style: normal; font-weight: 800; }
.good { color: var(--good); }
.bad { color: var(--danger); }

.attention-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.attention-item {
  min-height: 86px;
  padding: 13px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 9px;
  align-items: start;
}
.attention-item strong { font-size: 13px; }
.attention-item span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.decision-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, .95fr);
  gap: 14px;
}
.chart-panel,
.funnel-panel { min-height: 0; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: rgba(255,255,255,.035); }
[data-theme="light"] .chart-panel,
[data-theme="light"] .funnel-panel { background: #fff; }
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-title h2 { font-size: 16px; }
.panel-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-title a { color: var(--accent); font-size: 13px; font-weight: 740; white-space: nowrap; }

.revenue-chart {
  height: 230px;
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 7px;
  align-items: end;
  padding: 16px 12px 28px;
  border-radius: var(--radius);
  background:
    linear-gradient(var(--border) 1px, transparent 1px) 0 0/100% 25%,
    var(--surface-2);
}
.revenue-chart.empty-chart {
  grid-template-columns: 1fr;
  place-items: center;
}
.chart-empty {
  max-width: 360px;
  text-align: center;
  color: var(--muted);
}
.chart-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 15px;
}
.chart-empty span {
  font-size: 13px;
  line-height: 1.45;
}
.chart-day {
  position: relative;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
}
.chart-day i {
  width: 60%;
  min-height: 8px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 28%, transparent));
}
.chart-day small {
  position: absolute;
  bottom: -22px;
  color: var(--muted);
  font-size: 10px;
}
.sale-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 16%, transparent);
}
.insight-line,
.action-insight {
  margin: 12px 0 0;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: var(--soft);
  background: color-mix(in srgb, var(--good) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--good) 18%, transparent);
  font-size: 13px;
}
.action-insight { background: color-mix(in srgb, var(--warning) 9%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 24%, transparent); }
.action-insight strong { display: block; margin-bottom: 5px; }
.action-insight span { color: var(--soft); font-size: 13px; }

.funnel-list { display: grid; gap: 13px; }
.funnel-list.large { gap: 16px; }
.funnel-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 12px;
}
.funnel-row span { color: var(--soft); font-size: 13px; font-weight: 740; }
.funnel-row div {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}
.funnel-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.funnel-row strong { text-align: right; font-size: 13px; }

.below-command-grid,
.section-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.below-command-grid { grid-template-columns: 1.05fr 1fr .9fr; }
.section-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.panel-card { padding: 16px; }
.metric-panel {
  min-height: 116px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.list-row,
.content-row,
.source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.list-row:first-of-type,
.content-row:first-of-type,
.source-row:first-of-type { border-top: 0; }
.list-row em,
.source-row strong { color: var(--soft); font-size: 13px; font-style: normal; white-space: nowrap; }
.source-row { grid-template-columns: 86px minmax(0, 1fr) 84px; }
.source-row div,
.wide-bars div i {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
}
.source-row div i,
.wide-bars div i {
  display: block;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tabs a {
  height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 740;
}
.tabs a.active { color: var(--accent-active); background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
}
.status-dot.green { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 12%, transparent); }
.status-dot.yellow { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 12%, transparent); }
.status-dot.red { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent); }

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
th, td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}
.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 640;
  background: var(--surface-3);
  color: var(--soft);
}
.badge.paid,
.badge.success {
  background: color-mix(in srgb, var(--good) 14%, var(--surface));
  color: color-mix(in srgb, var(--good) 70%, var(--text));
}
.badge.created {
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  color: color-mix(in srgb, var(--warning) 70%, var(--text));
}
.badge.failed,
.badge.failure {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: color-mix(in srgb, var(--danger) 70%, var(--text));
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--text);
  padding: 10px 11px;
  outline: none;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input[disabled], textarea[disabled], select[disabled] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
textarea { resize: vertical; }
label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.stack { display: grid; gap: 10px; }
.filters,
.inline-form,
.coupon-grid,
.coupon-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.filters { grid-template-columns: minmax(240px, 1fr) 180px auto; }
.inline-form.compact { max-width: 520px; grid-template-columns: minmax(0, 1fr) auto; }
.coupon-grid { grid-template-columns: minmax(100px, 1fr) 74px 82px auto; }
.coupon-create { grid-template-columns: minmax(160px, 1fr) 90px 110px 120px auto; margin-bottom: 16px; }

.wide-bars { display: grid; gap: 9px; }
.wide-bars div {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
}
.wide-bars span,
.wide-bars strong { font-size: 12px; color: var(--muted); }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  background: rgba(0,0,0,.35);
}
.drawer.open { display: block; }
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(460px, 100vw);
  min-height: 100%;
  padding: 20px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: auto;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.drawer-section {
  padding: 15px 0;
  border-top: 1px solid var(--border);
}
.drawer-section h3 { margin-bottom: 10px; font-size: 15px; }
.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-links a {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--soft);
  background: var(--surface-2);
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow);
  font-weight: 760;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-state strong { color: var(--text); }
.insight-stack { display: grid; gap: 10px; }
.insight-stack p {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--soft);
}
.status-list { display: grid; gap: 9px; }
.status-list span,
.health-list a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.segment-card { display: grid; gap: 6px; }
.profile-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 14px; margin-bottom: 14px; }
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  font-weight: 850;
  font-size: 24px;
}
.customer-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.customer-metrics div {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.customer-metrics span { display: block; color: var(--muted); font-size: 11px; }
.customer-metrics strong { display: block; margin-top: 5px; font-size: 16px; }
.journey-list { display: grid; gap: 10px; }
.journey-list div { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.journey-list span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}
.journey-list .done { color: var(--text); }
.journey-list .done span { background: var(--good); }
.activity-line {
  padding: 8px 0;
  border-top: 1px solid var(--border);
  color: var(--soft);
  font-size: 13px;
}
.activity-line span { color: var(--muted); margin-right: 8px; }
.back-link { display: inline-flex; margin-bottom: 14px; color: var(--accent); font-size: 13px; font-weight: 760; }
.preview-box,
.success-box {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 12px;
}
.preview-box span,
.preview-box strong,
.preview-box p { display: block; margin: 0 0 8px; }
.success-box { color: color-mix(in srgb, var(--good) 70%, var(--text)); border: 1px solid color-mix(in srgb, var(--good) 25%, transparent); background: color-mix(in srgb, var(--good) 8%, var(--surface)); }
.health-hero strong { display: block; margin: 8px 0; font-size: 54px; line-height: 1; }

/* Legacy compatibility */
.layout { display: grid; grid-template-columns: 254px minmax(0, 1fr); min-height: 100vh; }
.sidebar { padding: 16px; background: #0f172a; color: #e2e8f0; }
.main { padding: 22px; }
.topbar { display: flex; justify-content: space-between; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.card { padding: 16px; }
.card .num { font-size: 28px; font-weight: 850; }
.card .lbl { margin-top: 4px; color: var(--muted); font-size: 13px; }
.panel { padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.flex { display: flex; gap: 10px; align-items: center; }
.bar { height: 26px; border-radius: var(--radius); background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); color: var(--on-accent); padding-left: 8px; line-height: 26px; }
.photo-prev { max-width: 240px; border-radius: var(--radius); border: 1px solid var(--border); }
.theme-toggle { display: none; }
.tg { max-width: 420px; background: #17212b; padding: 16px; border-radius: var(--radius); }
.tg-bubble, .tg-btn { background: #212d3b; border-radius: var(--radius); padding: 12px; }
.tg-photo { width: 100%; border-radius: var(--radius); }

/* ============================================================= *
 *  V2: command palette (⌘K), top-bar trigger, focus states
 * ============================================================= */
.cmd-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  width: 100%;
  padding: 0 12px 0 40px;
  position: relative;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--muted);
  cursor: text;
  font-size: 14px;
  text-align: left;
}
.cmd-trigger:hover { border-color: var(--border-strong); }
.cmd-trigger .ct-ic {
  position: absolute; left: 14px; width: 14px; height: 14px;
  border: 2px solid #7e8ca3; border-radius: 50%;
}
.cmd-trigger .ct-ic:after {
  content: ""; position: absolute; left: 11px; top: 10px;
  width: 7px; height: 2px; background: #7e8ca3; transform: rotate(45deg); border-radius: 3px;
}
.cmd-trigger .ct-text { flex: 1; }
.cmd-trigger kbd {
  min-width: 26px; height: 22px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); display: grid; place-items: center;
  color: var(--muted); font-size: 11px; background: rgba(0,0,0,.14);
}
.create-btn { white-space: nowrap; }

.cmdk-overlay {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  background: rgba(4, 8, 14, .58);
  backdrop-filter: blur(4px);
}
.cmdk-overlay[hidden] { display: none; }
.cmdk {
  width: min(640px, 94vw);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cmdk-in .12s ease;
}
@keyframes cmdk-in { from { transform: translateY(-8px); opacity: .6; } to { transform: none; opacity: 1; } }
.cmdk-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; position: relative;
  border-bottom: 1px solid var(--border);
}
.cmdk-ic { width: 16px; height: 16px; border: 2px solid var(--muted); border-radius: 50%; flex: 0 0 auto; }
.cmdk-head input {
  flex: 1; border: 0; background: transparent; padding: 0;
  color: var(--text); font-size: 16px; outline: none;
}
.cmdk-head kbd {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 7px;
  color: var(--muted); font-size: 11px; background: rgba(0,0,0,.14);
}
.cmdk-list { max-height: 56vh; overflow: auto; padding: 6px; }
.cmdk-group {
  padding: 10px 12px 4px; color: var(--muted);
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
}
.cmdk-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text); cursor: pointer;
}
.cmdk-item .ci-ic {
  width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px;
}
.cmdk-item .ci-t { flex: 1; min-width: 0; font-size: 14px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item .ci-t small { display: block; color: var(--muted); font-size: 12px; }
.cmdk-item .ci-go { color: var(--muted); font-size: 12px; opacity: 0; }
.cmdk-item.sel { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.cmdk-item.sel .ci-go { opacity: 1; }
.cmdk-empty { padding: 26px; text-align: center; color: var(--muted); }
.cmdk-foot {
  display: flex; gap: 16px; padding: 10px 16px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 11px;
}

:where(a, button, input, textarea, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: var(--radius);
}

@media (max-width: 760px) {
  .cmd-trigger .ct-text { display: none; }
  .cmd-trigger { width: auto; padding-right: 10px; }
  .cmdk-overlay { padding-top: 6vh; }
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .brand span:not(.brand-mark),
  .nav-section,
  .nav-link span,
  .developer-tools summary,
  .sidebar-footer { display: none; }
  .nav-link { justify-content: center; }
  .command-bar { grid-template-columns: minmax(0, 1fr) minmax(260px, 430px) auto; }
  .attention-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .decision-grid { grid-template-columns: 1fr; }
  .dashboard-first-screen { min-height: auto; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .app-sidebar {
    position: static;
    height: auto;
    display: block;
  }
  .brand { margin-bottom: 12px; }
  .brand span:not(.brand-mark) { display: block; }
  .main-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-link span { display: inline; }
  .app-main { padding: 14px; }
  .command-bar,
  .command-summary,
  .kpi-grid,
  .attention-strip,
  .decision-grid,
  .below-command-grid,
  .section-grid.two,
  .section-grid.three,
  .section-grid.four,
  .profile-layout,
  .customer-metrics,
  .grid2 { grid-template-columns: 1fr; }
  .global-search { order: 3; grid-column: 1 / -1; }
  .global-search input { min-width: 0; padding-right: 14px; }
  .global-search kbd { display: none; }
  .filters,
  .coupon-create,
  .coupon-grid,
  .inline-form { grid-template-columns: 1fr; }
  .revenue-chart { height: 190px; overflow-x: auto; }
  table { display: block; overflow-x: auto; }
}

/* Login page: compact centered card instead of a full-width stretched form */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  margin: 0;
  padding: 28px 26px;
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.026));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
[data-theme="light"] .login-box { background: var(--surface); }
.login-box h2 {
  margin: 0 0 20px;
  font-size: 19px;
  text-align: center;
}
.login-box label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12px;
  color: var(--muted);
}
.login-box input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--text);
  outline: none;
}
.login-box input:focus { border-color: var(--accent); }
.login-box .err {
  margin: 0 0 6px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: #ef4444;
  font-size: 13px;
}
.logout-form { margin: 0; }
.logout-link { border: 0; padding: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.logout-link:hover, .logout-link:focus-visible { color: var(--accent, #7c5cff); text-decoration: underline; }