@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Manrope:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg:       #0a0c14;
  --bg2:      #0f1117;
  --surface:  #141824;
  --surface2: #1a2035;
  --surface3: #1f2640;
  --border:   #252d42;
  --border2:  #2e3a55;
  --accent:   #3d7eff;
  --green:    #00d4aa;
  --red:      #ff6b6b;
  --amber:    #f7b731;
  --purple:   #9b59b6;
  --text:     #e8edf5;
  --text2:    #b0bdd4;
  --muted:    #6b7a99;
  --mono:     'JetBrains Mono', monospace;
  --sans:     'Manrope', sans-serif;
  --radius:   14px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────── */
h1, h2, h3 { font-weight: 700; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
p  { line-height: 1.6; color: var(--text2); }
small { font-size: .8125rem; color: var(--muted); }

/* ── Cards / Surfaces ───────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card-sm { padding: .875rem 1rem; }
.card-hover {
  transition: border-color .2s, transform .2s;
  cursor: pointer;
}
.card-hover:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
  padding: .625rem 1.25rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--sans);
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 45%, transparent); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text2);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-block { width: 100%; }

/* ── Forms ──────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .375rem; }
.form-label { font-size: .875rem; font-weight: 600; color: var(--text2); }
.form-input {
  height: 44px;
  width: 100%;
  min-width: 0;
  padding: 0 .875rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  color: var(--text);
  font-family: var(--sans);
  font-size: .9375rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.form-input::placeholder { color: var(--muted); }

/* Alias used in dynamic templates */
.input {
  height: 44px;
  padding: 0 .875rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  color: var(--text);
  font-family: var(--sans);
  font-size: .9375rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
  min-width: 0;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input::placeholder { color: var(--muted); }
select.input { cursor: pointer; }

/* ── Badge / Chip ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-accent   { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge-green    { background: color-mix(in srgb, var(--green)  18%, transparent); color: var(--green);  }
.badge-red      { background: color-mix(in srgb, var(--red)    18%, transparent); color: var(--red);    }
.badge-amber    { background: color-mix(in srgb, var(--amber)  18%, transparent); color: var(--amber);  }
.badge-purple   { background: color-mix(in srgb, var(--purple) 18%, transparent); color: var(--purple); }

/* ── KPI tile ───────────────────────────────────────── */
.kpi-tile {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--text);
}
.kpi-label { font-size: .8125rem; color: var(--muted); font-weight: 500; }

/* ── Divider ────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ── Animations ─────────────────────────────────────── */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  50%       { box-shadow: 0 0 22px 8px color-mix(in srgb, var(--accent) 25%, transparent); }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes count-up { from { opacity: .3; } to { opacity: 1; } }

.pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }
.slide-in   { animation: slide-in-right .4s ease forwards; }
.fade-in    { animation: fade-in .3s ease forwards; }

/* ── Toast ──────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  padding: .75rem 1.125rem;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  font-size: .9rem;
  max-width: 320px;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .3s ease, transform .3s ease;
}
.toast.visible  { opacity: 1; transform: translateX(0); }
.toast-success  { border-left-color: var(--green); }
.toast-error    { border-left-color: var(--red); }

/* ── Funnel flow (tree with arrows + tiles) ───────────────────────────────────
   Shared by the manager dashboard and the superadmin network analytics.
   Reads top-to-bottom as a flow: flyers → visits → (with/without flyer) →
   purchases → (promo/regular) → no-purchase outcomes. */
.fnl { display: flex; flex-direction: column; align-items: stretch; gap: .55rem; }
.fnl-stage { display: flex; justify-content: center; gap: .75rem; }
.fnl-stage.two { gap: .75rem; }
.fnl-stage.two .fnl-tile { flex: 1; }
.fnl-arrow { text-align: center; color: var(--text2); font-size: .92rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; line-height: 1; margin: .25rem 0;
  display: flex; align-items: center; justify-content: center; gap: .5rem; }
.fnl-arrow::before { content: "↓"; font-size: 1.35rem; color: var(--accent); }
.fnl-branch { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.fnl-col { display: flex; flex-direction: column; gap: .5rem;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: .85rem; }
.fnl-col-arrow { text-align: center; color: var(--border2); font-size: 1.1rem; line-height: .6; }
.fnl-tile {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--muted); border-radius: 12px; padding: .7rem .9rem;
  display: flex; align-items: center; gap: .7rem; min-width: 0; width: 100%; box-sizing: border-box;
  transition: transform .12s, box-shadow .15s;
}
/* Centred single-tile stages get a comfortable width on wide screens but shrink
   to fit narrow containers (e.g. the drill-down side panel). */
.fnl-stage:not(.two) .fnl-tile { width: min(340px, 100%); }
.fnl-tile:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.28); }
.fnl-tile { padding: .9rem 1.1rem; gap: .95rem; }
.fnl-tile .fi { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.fnl-tile .fb { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.fnl-tile .fv { font-family: var(--mono); font-weight: 800; font-size: 1.85rem; line-height: 1; color: var(--text); letter-spacing: .01em; }
.fnl-tile .fl { font-size: .92rem; font-weight: 500; color: var(--text2); line-height: 1.25; }
.fnl-tile .fp { font-family: var(--mono); font-weight: 700; font-size: .92rem; color: #fff;
  background: var(--green); border-radius: 99px; padding: .25rem .7rem; flex-shrink: 0; align-self: center; }
.fnl-tile.big .fv { font-size: 2.25rem; }
.fnl-tile.big .fl { font-size: 1rem; }
.fnl-tile.accent { border-left-color: var(--accent); }
.fnl-tile.green  { border-left-color: var(--green); }
.fnl-tile.amber  { border-left-color: var(--amber); }
.fnl-tile.purple { border-left-color: var(--purple); }
.fnl-tile.red    { border-left-color: var(--red); }
.fnl-tile.muted  { border-left-color: var(--muted); }
.fnl-sub { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.fnl-mini {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  padding: .65rem .8rem; display: flex; align-items: center; gap: .6rem;
}
.fnl-mini .fi { font-size: 1.15rem; flex-shrink: 0; }
.fnl-mini .fb { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.fnl-mini .mv { font-family: var(--mono); font-weight: 800; font-size: 1.35rem; line-height: 1; color: var(--text); }
.fnl-mini .ml { font-size: .82rem; color: var(--muted); }
.fnl-mini.accent { border-left: 3px solid var(--accent); }
.fnl-mini.muted  { border-left: 3px solid var(--muted); }
.fnl-colhead { font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); text-align: center; margin-bottom: .1rem; }
@media (max-width: 700px) {
  .fnl-branch { grid-template-columns: 1fr; }
  .fnl-tile { min-width: 0; }
}

/* ── Left-reasons detail popup (clickable "left without buying") ───────────── */
.lr-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 400;
  display: none; align-items: center; justify-content: center; animation: fade-in .15s ease; }
.lr-overlay.open { display: flex; }
.lr-box { background: var(--surface); border: 1px solid var(--border2); border-radius: 16px;
  width: min(580px, 94vw); max-height: 85vh; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,.6); }
.lr-head { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border); }
.lr-title { font-weight: 800; font-size: 1.02rem; }
.lr-x { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.lr-x:hover { color: var(--text); }
.lr-body { overflow-y: auto; padding: 1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 1.1rem; }
.lr-group-h { font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text2); display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.lr-group-h .cnt { background: color-mix(in srgb,var(--red) 18%,transparent); color: var(--red);
  border-radius: 99px; padding: .1rem .6rem; font-size: .72rem; font-weight: 700; }
.lr-item { background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--red);
  border-radius: 10px; padding: .55rem .8rem; font-size: .88rem; margin-bottom: .4rem; }
.lr-item .note { color: var(--text); line-height: 1.4; }
.lr-item .note.empty { color: var(--muted); font-style: italic; }
.lr-item .meta { color: var(--muted); font-size: .72rem; margin-top: .3rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.lr-empty { color: var(--muted); text-align: center; padding: 2rem; }

.fnl-leftclick { cursor: pointer; }
.fnl-leftclick:hover { box-shadow: 0 0 0 2px var(--red), 0 6px 18px rgba(0,0,0,.3); }
