/* JUNEPAY (v2) - visual language ported from v1 admin. */

:root {
  --bg: #eef0f4; --panel: #ffffff; --ink: #171a1f; --muted: #575f6c;
  --muted-2: #8a919e;             /* tertiary — micro-labels, section headers, placeholders */
  --line: #e8eaef; --line-2: #e0e3e9;
  --sidebar: #171a1f; --sidebar-ink: #9aa1ad; --sidebar-active: #ffffff;
  --primary: #2f6bed; --primary-strong: #245ad0; --green: #16a34a; --pink: #ec4899;
  --yellow: #e08a1e; --red: #e0483d; --grey: #8a919e; --blue: #2f6bed;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  /* Card corner radius — the reference's soft 16px. */
  --radius: 16px;
  /* Inputs are inset surfaces — slightly off-panel so "type here" reads without heavy borders. */
  --control-bg: #f2f3f6;
  /* One focus signal, reused everywhere. A soft ring beats a hard outline. */
  --ring: rgba(47,107,237,.35);
  --ring-shadow: 0 0 0 3px rgba(47,107,237,.18);
  /* Motion: a single ease-out curve + duration, so the whole app moves with one hand. */
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --t-fast: 120ms; --t-mid: 180ms;
  /* Two-font system (payments-terminal signature): a grotesk for UI chrome, a
     monospace for every piece of financial data — amounts, UTRs, VPAs, txn ids,
     dates, hashes. Data should read like a ledger, not like prose. Matches the
     JunePay Admin reference: Instrument Sans + IBM Plex Mono. */
  --font-ui: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
body[data-theme=dark] {
  --bg: #0b1220; --panel: #171a1f; --ink: #e8eaef; --muted: #9ca3af;
  --line: #1f2937; --line-2: #374151;
  --sidebar: #050a18; --sidebar-ink: #94a3b8; --sidebar-active: #ffffff;
  --control-bg: #0d1526;
  --ring: rgba(96,165,250,.45);
  --ring-shadow: 0 0 0 3px rgba(96,165,250,.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-ui); }
body { display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
[hidden] { display: none !important; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { margin-left: auto; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

/* ---- App shell -------------------------------------------------------------*/
.app { display: grid; grid-template-columns: 240px 1fr; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.main {
  display: flex; flex-direction: column;
  overflow: auto;
  min-width: 0;
}

/* ---- Sidebar ---------------------------------------------------------------*/
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; letter-spacing: -.02em; flex-shrink: 0; box-shadow: 0 2px 8px -2px rgba(47,107,237,.5); }
.brand-title { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub, .brand-pro { color: var(--muted-2); font-weight: 600; font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; padding: 8px 0 16px; flex: 1; min-height: 0; overflow-y: auto; }
.nav-group { display: flex; flex-direction: column; }
.nav-group-items { display: flex; flex-direction: column; overflow: hidden; transition: max-height .18s ease; max-height: 800px; }
.nav-group.collapsed .nav-group-items { max-height: 0; }
button.nav-sec {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: transparent; border: 0; cursor: pointer;
  color: var(--muted-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  padding: 18px 18px 8px; font-family: inherit; font-weight: 600;
}
button.nav-sec:hover { color: #e8eaef; }
.nav-sec-chev { width: 14px; height: 14px; transition: transform .18s ease; opacity: .6; }
.nav-group.collapsed .nav-sec-chev { transform: rotate(-90deg); }
/* Legacy non-button .nav-sec rule kept for backward compat */
.nav > .nav-sec { color: #575f6c; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 18px 18px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--sidebar-ink); font-size: 14px; cursor: pointer; border-left: 3px solid transparent; text-decoration: none; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.nav-item:hover { background: rgba(255,255,255,.04); color: #fff; text-decoration: none; }
.nav-item:focus-visible { outline: none; background: rgba(255,255,255,.06); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.nav-item.active { background: rgba(255,255,255,.06); color: var(--sidebar-active); border-left-color: var(--primary); }
.nav-item i[data-lucide] { width: 18px; height: 18px; stroke-width: 2; flex: 0 0 18px; }
.nav-item.danger { color: #fca5a5; }
.nav-item.danger:hover { background: rgba(224,72,61,.08); color: #fecaca; }
.sidebar-foot { padding: 8px 18px; border-top: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---- Topbar ----------------------------------------------------------------*/
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.company { font-size: 17px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.role-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.role-pill i[data-lucide] { width: 14px; height: 14px; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: inherit; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(0,0,0,.03); border-color: var(--line-2); }
body[data-theme=dark] .icon-btn:hover { background: rgba(255,255,255,.05); }
.icon-btn i[data-lucide] { width: 18px; height: 18px; }
#sidebarToggle { display: none; }   /* visible on mobile via @media */

/* ---- Content --------------------------------------------------------------*/
.content { padding: 24px 24px 48px; max-width: 100%; }
.content > .view > h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: -.018em; text-wrap: balance; }
.content > .view > p.muted { margin: 0 0 16px; }
.crumbs { font-size: 13px; margin-bottom: 16px; color: var(--muted); }
.crumbs span:first-child { color: var(--ink); font-weight: 500; }

/* ---- Panels + cards -------------------------------------------------------*/
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 16px; overflow-x: auto; }
.panel h2 { margin: 0 0 16px; font-size: 18px; letter-spacing: -.01em; text-wrap: balance; }
.panel h3 { margin: 18px 0 8px; font-size: 14px; }
.panel input, .panel select, .panel textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--control-bg); color: var(--ink); font: inherit;
  box-sizing: border-box;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.panel input:focus, .panel select:focus, .panel textarea:focus {
  outline: none; border-color: var(--primary); background: var(--panel); box-shadow: var(--ring-shadow);
}
.panel input::placeholder, .panel textarea::placeholder { color: var(--muted); opacity: .7; }
.panel textarea { font: 13px var(--font-mono); resize: vertical; min-height: 80px; }
/* Unified compact-control height. Small buttons and small inline form controls
   (Rows-per-page pager, inline date range, cap inputs) all lock to ONE height so
   an inline row never mixes a 28px and a 32px control. Higher specificity wins
   over `.panel select`; `.filter-row`/`.filters` rows keep their own 34px sizing. */
input.small, select.small,
.panel input.small, .panel select.small {
  width: auto; height: 30px; padding: 0 8px; font-size: 12px; line-height: 1; border-radius: 6px;
}
select.small { padding-right: 22px; }   /* room for the native dropdown caret */

/* Stat cards — flat "ledger" cards (trading-terminal inspiration). Each is an
   uppercase micro-label + a big tabular MONO value + an optional semantic delta.
   No gradient fills: color communicates payment status, it doesn't decorate.
   The category classes (.green/.blue/.grey/.pink/.amber/.indigo) now render as a
   quiet 3px left accent + tinted corner icon — the structure stays neutral. */
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.info-card {
  position: relative; border-radius: var(--radius); padding: 18px 20px;
  min-height: 104px; box-shadow: var(--shadow); overflow: hidden;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  transition: transform var(--t-mid) var(--ease), box-shadow var(--t-mid) var(--ease), border-color var(--t-mid) var(--ease);
}
.info-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px -8px rgba(2,8,23,.18), var(--shadow); border-color: var(--line-2); }
.info-lbl { font-size: 10.5px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.info-val { font-family: var(--font-mono); font-size: 27px; font-weight: 600; line-height: 1.1; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 1px 0 2px; }
.info-card .muted, .info-card .small { color: var(--muted); }
.info-ic { position: absolute; right: 16px; top: 16px; opacity: .18; color: var(--muted); }
.info-ic i[data-lucide] { width: 30px; height: 30px; stroke-width: 1.5; }
/* Semantic delta chip next to / under the value */
.info-delta { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 3px; }
.info-delta.up { color: #16a34a; }
.info-delta.down { color: #dc2626; }
.info-delta.flat { color: var(--muted); }
.kpi-cmp { font-variant-numeric: tabular-nums; }
/* Category accent — quiet left stripe + tinted icon, never a fill */
.info-card.green, .info-card.blue, .info-card.grey, .info-card.pink, .info-card.amber, .info-card.indigo { padding-left: 21px; }
.info-card.green::before, .info-card.blue::before, .info-card.grey::before,
.info-card.pink::before, .info-card.amber::before, .info-card.indigo::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.info-card.green::before  { background: #16a34a; } .info-card.green  .info-ic { color: #16a34a; opacity: .85; }
.info-card.blue::before   { background: #2f6bed; } .info-card.blue   .info-ic { color: #2f6bed; opacity: .85; }
.info-card.grey::before   { background: #94a3b8; } .info-card.grey   .info-ic { color: #94a3b8; opacity: .85; }
.info-card.pink::before   { background: #ec4899; } .info-card.pink   .info-ic { color: #ec4899; opacity: .85; }
.info-card.amber::before  { background: #e08a1e; } .info-card.amber  .info-ic { color: #e08a1e; opacity: .85; }
.info-card.indigo::before { background: #6366f1; } .info-card.indigo .info-ic { color: #6366f1; opacity: .85; }
.info-card.plain { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }

/* Lead KPI — the single North-Star metric per dashboard. Wins by size + a primary
   top accent (focal point), not by area, so the 4-up grid stays clean.
   NB: named `.lead`, NOT `.hero` — `.hero` is the page identity banner and its
   styles (centering, brand gradient stripe) would leak onto the card. */
.info-card.lead { border-color: rgba(47,107,237,.35); }
.info-card.lead::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--primary); }
.info-card.lead .info-val { font-size: 34px; }
.info-card.lead .info-lbl { color: var(--primary); }

/* KPI definition affordance — dotted underline reveals the calculation on hover (title attr). */
.kpi-def { border-bottom: 1px dotted var(--line-2); cursor: help; }

/* Conversion composition bar inside a stat card (paid / active / fails) */
.health-bar { display: flex; height: 8px; border-radius: 6px; overflow: hidden; background: var(--line); margin-top: 8px; }
.health-bar > span { display: block; height: 100%; transition: width var(--t-mid) var(--ease); }
.health-bar .seg-ok { background: #16a34a; }
.health-bar .seg-active { background: #e08a1e; }
.health-bar .seg-fail { background: #e0483d; }
.health-legend { display: flex; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.health-legend b { color: var(--ink); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.health-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }

/* Alert strip — renders only when a real rule trips (high fail-rate, cap reached, stale feed). */
.alert-strip { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert-strip[hidden], .alert-strip:empty { display: none; }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid; }
.alert-item i[data-lucide] { width: 16px; height: 16px; flex-shrink: 0; }
.alert-item .pill { margin-left: auto; }
.alert-item.bad  { background: rgba(224,72,61,.08);  border-color: rgba(224,72,61,.25);  color: #b91c1c; }
.alert-item.warn { background: rgba(224,138,30,.10); border-color: rgba(224,138,30,.28); color: #b45309; }
body[data-theme=dark] .alert-item.bad  { color: #fca5a5; }
body[data-theme=dark] .alert-item.warn { color: #fcd34d; }

/* Freshness governance hook (honest client fetch time) */
.freshness { font-size: 12px; }

/* Dashboard header row — kicker + title on the left, time control + sync on the
   right. Baseline-aligned so the segmented control sits level with the title. */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Segmented control — one enclosure, active pill in --primary. Replaces the row
   of ghost range buttons; inner buttons keep .range-btn + data-range so the
   existing click handlers are untouched. */
.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented .range-btn {
  border: 0; background: transparent; color: var(--muted); font: inherit;
  font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.segmented .range-btn:hover { color: var(--ink); }
.segmented .range-btn.active { background: var(--primary); color: #fff; box-shadow: 0 1px 3px rgba(47,107,237,.4); }
.segmented .range-btn:focus-visible { outline: none; box-shadow: var(--ring-shadow); }

/* ---- Topbar shell: breadcrumb + global search + status pill (mockup) -------*/
.topbar-crumb { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.topbar-crumb .company { font-weight: 600; }
.topbar-crumb .sep { color: var(--muted); font-weight: 500; }
.topbar-crumb .crumb-view { color: var(--muted); font-weight: 500; }
.topbar-search {
  display: flex; align-items: center; gap: 9px; flex: 1; max-width: 400px;
  margin-left: 24px; background: var(--control-bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; color: var(--muted);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.topbar-search:focus-within { border-color: var(--primary); box-shadow: var(--ring-shadow); }
.topbar-search i[data-lucide] { width: 16px; height: 16px; flex: none; }
.topbar-search input { border: 0; background: none; outline: none; font: inherit; font-size: 13px; color: var(--ink); width: 100%; }
.topbar-search input::placeholder { color: var(--muted); opacity: .8; }
.topbar-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
/* Status pill: green "· ACTIVE" with a live dot (replaces the warm gradient) */
.role-pill {
  background: rgba(22,163,74,.10); border: 1px solid rgba(22,163,74,.28);
  color: #047857; font-family: var(--font-mono); font-weight: 600;
  font-size: 11px; letter-spacing: .04em; padding: 6px 12px; border-radius: 999px;
}
.role-pill .rp-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.16); flex: none; }
body[data-theme=dark] .role-pill { background: rgba(22,163,74,.16); color: #6ee7b7; border-color: rgba(22,163,74,.3); }
@media (max-width: 900px) { .topbar-search { display: none; } }

/* ---- Sidebar nav: rounded inset items + pill active state (mockup navbar) --*/
.nav { padding: 6px 12px 16px; }
.nav-item { border-radius: 9px; border-left: 0; padding: 9px 12px; margin: 1px 0; font-size: 13.5px; }
.nav-item:hover { background: rgba(148,163,184,.09); border-left: 0; }
.nav-item.active { background: rgba(47,107,237,.16); color: #fff; border-left: 0; position: relative; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-item.active i[data-lucide] { color: #93b4fd; }
button.nav-sec { padding: 16px 10px 8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; }

/* ---- KPI sparkline (real trend on the hero metric card) -------------------*/
/* In-flow, right-aligned under the note so it never collides with the delta
   chip. Empty until fed a series, so cards without trend data stay clean. */
.kpi-spark { display: block; align-self: flex-end; margin-top: 4px; line-height: 0; pointer-events: none; }
.kpi-spark:empty { display: none; }
.kpi-spark svg { display: block; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-grid strong { font-family: var(--font-mono); font-weight: 500; font-size: 13.5px; word-break: break-all; }
.kv-grid .muted { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }

/* Section-header row inside panels (title left · meta/action right) — the
   recurring "Holdings · All Assets ▾" / "Tenants · + Add tenant" pattern. */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 16px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Status dot — services up/down, account active, feed fresh/stale, "session encrypted" */
.status-dot { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.status-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.ok::before   { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.status-dot.warn::before { background: #e08a1e; box-shadow: 0 0 0 3px rgba(224,138,30,.16); }
.status-dot.bad::before  { background: #e0483d; box-shadow: 0 0 0 3px rgba(224,72,61,.16); }

/* My Profile: editable form stack on the left, read-only account summary on the right. */
.profile-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.profile-stack { display: flex; flex-direction: column; }
.profile-stack > .panel { margin-bottom: 16px; }
.profile-stack > .panel:last-child { margin-bottom: 0; }
.profile-grid > .panel { margin-bottom: 0; }
.profile-summary { position: sticky; top: 16px; }
.profile-summary .summary-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.profile-summary .summary-row:last-child { border-bottom: 0; }
.profile-summary .summary-row strong { font-size: 14px; text-align: right; word-break: break-all; }
.profile-summary .summary-row .muted { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
@media (max-width: 1100px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-summary { position: static; }
}

/* ---- Buttons --------------------------------------------------------------*/
/* All buttons share one motion contract: ease-out transition + a tactile press. */
.primary, .ghost-btn, .danger, .icon-btn {
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.primary:active, .ghost-btn:active, .danger:active, .icon-btn:active { transform: scale(.97); }
.primary:focus-visible, .ghost-btn:focus-visible, .danger:focus-visible, .icon-btn:focus-visible {
  outline: none; box-shadow: var(--ring-shadow);
}
.primary { background: var(--primary); color: #fff; border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.primary i[data-lucide] { width: 16px; height: 16px; }
.primary:hover { background: #245ad0; }
.primary.small { padding: 0 12px; font-size: 13px; height: 30px; }
button:disabled, button[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.3); }
button:disabled:active, button[disabled]:active { transform: none; }
.ghost-btn { background: transparent; border: 1px solid var(--line-2); color: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 8px; }
.ghost-btn:hover { background: rgba(0,0,0,.03); border-color: var(--muted); }
body[data-theme=dark] .ghost-btn:hover { background: rgba(255,255,255,.05); }
.ghost-btn.small { padding: 0 10px; font-size: 12px; height: 30px; }
.danger.small { padding: 0 12px; font-size: 13px; height: 30px; }
.ghost-btn i[data-lucide] { width: 14px; height: 14px; }
.danger { background: transparent; border: 1px solid var(--red); color: var(--red); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 8px; }
.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.danger:hover { background: #fef2f2; }
body[data-theme=dark] .danger:hover { background: rgba(224,72,61,.12); }
.danger.solid:hover { background: #dc2626; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Tables (v1-style bordered container) ---------------------------------*/
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; vertical-align: middle; }
.data-table thead tr { background: var(--bg); border-bottom: 1px solid var(--line); }
.data-table thead th { background: var(--bg); font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-top: 14px; padding-bottom: 14px; }
.data-table tbody tr { border-bottom: 1px solid var(--line); transition: background var(--t-fast) var(--ease); }
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(0,0,0,.02); }
body[data-theme=dark] .data-table tbody tr:hover { background: rgba(255,255,255,.03); }
.data-table .center { text-align: center; }
/* When a data-table is the direct child of a .panel (no wrap), still give it
   the bordered look so panels with tables match wrapped ones visually. */
.panel > .data-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel > .data-table thead tr:first-child th:first-child { border-top-left-radius: 12px; }
.panel > .data-table thead tr:first-child th:last-child { border-top-right-radius: 12px; }

/* Inline toggle switch (replaces raw checkboxes in tables) */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; vertical-align: middle; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--line-2); border-radius: 20px; transition: background .12s; }
.toggle-slider::before { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .12s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-slider { box-shadow: var(--ring-shadow); }

/* Small/secondary controls share the same focus signal so nothing is keyboard-invisible. */
.modal-x:focus-visible, .icon-mini:focus-visible, .nav-sec:focus-visible, a:focus-visible {
  outline: none; border-radius: 6px; box-shadow: var(--ring-shadow);
}

/* Mini icon-only button used inline next to text/code (e.g. reveal-key, rotate) */
.icon-mini { background: transparent; border: 0; padding: 2px 4px; cursor: pointer; color: var(--muted); vertical-align: middle; border-radius: 4px; }
.icon-mini:hover { background: var(--line); color: var(--ink); }
.icon-mini i[data-lucide] { width: 14px; height: 14px; }

/* Inline danger button (just the trash icon, no label) */
.ghost-btn.danger-btn { color: #b91c1c; border-color: rgba(224,72,61,.4); padding: 6px 8px; }
.ghost-btn.danger-btn:hover { background: rgba(224,72,61,.08); }

/* Status pills */
.pill { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; letter-spacing: .03em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.pill.ok, .pill.approved, .pill.paid, .pill.active { background: #e7f6ec; color: #0f7a37; }
.pill.bad, .pill.rejected, .pill.failed { background: #fbeae8; color: #c23327; }
.pill.warn, .pill.pending { background: #fdf5e6; color: #9a7b2e; }
.pill.inactive, .pill.archived { background: #ecedf1; color: #6b7280; }
.pill.paid_submitted { background: #eaf1fd; color: #245ad0; }
.pill.expired { background: #eef0f4; color: #575f6c; }
.pill.muted { background: var(--line); color: var(--muted); }
.pill.soon { background: #fdf5e6; color: #9a7b2e; }
/* Dark mode: desaturate-but-brighten so semantic text keeps contrast on charcoal. */
body[data-theme=dark] .pill.ok, body[data-theme=dark] .pill.approved,
body[data-theme=dark] .pill.paid, body[data-theme=dark] .pill.active { background: rgba(22,163,74,.16); color: #6ee7b7; }
body[data-theme=dark] .pill.bad, body[data-theme=dark] .pill.rejected,
body[data-theme=dark] .pill.failed { background: rgba(224,72,61,.16); color: #fca5a5; }
body[data-theme=dark] .pill.warn, body[data-theme=dark] .pill.pending,
body[data-theme=dark] .pill.soon { background: rgba(224,138,30,.16); color: #fcd34d; }
body[data-theme=dark] .pill.paid_submitted { background: rgba(99,102,241,.18); color: #a5b4fc; }
body[data-theme=dark] .pill.expired { background: rgba(148,163,184,.16); color: #cbd5e1; }

/* ---- Filter / search bars -------------------------------------------------*/
.filters { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--control-bg); color: var(--ink); font: inherit; transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring-shadow); }

/* Compact filter row used in transaction/agent/admin list pages. Locks every
   control (label-stacked input + raw input + button) to a single line height
   so search/date/Apply/Clear/Export sit on one tight baseline. */
.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filter-row > div { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.filter-row > div.grow { flex: 1; }
.filter-row label { margin: 0; font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-row input, .filter-row select {
  height: 34px; padding: 0 10px; font-size: 13px;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--control-bg); color: var(--ink); font-family: inherit;
  box-sizing: border-box;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.filter-row input:focus, .filter-row select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring-shadow); }
.filter-row .primary,
.filter-row .ghost-btn,
.filter-row .danger { height: 34px; padding: 0 14px; font-size: 13px; line-height: 1; }
.filter-row .ghost-btn.small,
.filter-row .primary.small { height: 34px; padding: 0 14px; font-size: 13px; }

/* ---- Forms ----------------------------------------------------------------*/
label { display: block; font-size: 13px; margin: 12px 0 6px; color: var(--muted); }
label.small { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.form-msg { margin-top: 8px; padding: 8px 12px; border-radius: 6px; background: #fef3c7; color: #92400e; font-size: 13px; }
.form-msg:empty { display: none; }   /* don't render the yellow strip when there's no message */
.form-msg.ok  { background: #d1fae5; color: #065f46; }
.form-msg.err { background: #fee2e2; color: #991b1b; }

/* Copy-row pattern (URL + Copy button) */
.copy-row { display: flex; gap: 6px; align-items: center; }
.copy-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; font: 12.5px var(--font-mono); }

/* ---- Code blocks ----------------------------------------------------------*/
.panel pre { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; }
.panel code, code { background: rgba(15,23,42,.06); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 12px; }
body[data-theme=dark] .panel code, body[data-theme=dark] code { background: rgba(255,255,255,.08); color: #f8fafc; }

/* ---- Auth pages (login / forgot / reset) ----------------------------------*/
.auth-body { background: linear-gradient(135deg, #1e3a8a 0%, #6d28d9 100%); min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { background: #fff; border-radius: 16px; padding: 36px 32px 24px; max-width: 400px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand .brand-mark { width: 40px; height: 40px; font-size: 14px; }
.auth-brand-title { font-size: 17px; font-weight: 700; color: #171a1f; }
.auth-brand-sub { font-size: 12px; color: #575f6c; margin-top: 2px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; color: #171a1f; }
.auth-card .muted { font-size: 13px; margin: 0 0 20px; }
.auth-card label { display: block; font-size: 12px; font-weight: 500; color: #4b5563; margin: 14px 0 6px; }
.auth-card input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #e0e3e9; border-radius: 8px; font: 14px inherit; color: var(--ink); }
.auth-card input:focus { outline: none; border-color: #2f6bed; box-shadow: 0 0 0 3px rgba(47,107,237,.15); }
.auth-card .primary { width: 100%; margin-top: 18px; padding: 10px 16px; background: #2f6bed; color: #fff; border: 0; border-radius: 8px; font: 14px inherit; font-weight: 600; cursor: pointer; justify-content: center; }

/* ---- Modals ---------------------------------------------------------------*/
/* Two class names used historically: .modal-backdrop (new) and .modal-overlay
   (older markup). Style both the same so the entire app works regardless. */
.modal-backdrop, .modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 32px 16px; animation: backdrop-in var(--t-mid) var(--ease); }
.modal-backdrop[hidden], .modal-overlay[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px -12px rgba(16,24,40,.28); max-height: calc(100vh - 64px); overflow-y: auto; animation: modal-in 220ms var(--ease); }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-x, .modal-card .modal-x { background: transparent; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.modal-card label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--ink); font-weight: 500; }
.modal-card label.small { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px; }
.modal-card input, .modal-card select, .modal-card textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--control-bg); color: var(--ink); font: inherit; box-sizing: border-box; transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus { outline: none; border-color: var(--primary); background: var(--panel); box-shadow: var(--ring-shadow); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
/* Inline checkbox-with-text labels - keep the row horizontal regardless of
   the .small text-transform; cap the text width so it doesn't column-wrap. */
.modal-card label[style*="flex"] { display: flex !important; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); font-weight: 500; }
.modal-card label[style*="flex"] input[type="checkbox"] { width: 16px; height: 16px; padding: 0; margin: 0; flex-shrink: 0; }

/* ---- Drawer (right-side slide-out for merchant/agent detail) -------------*/
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer[hidden] { display: none; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.drawer-bg { animation: backdrop-in var(--t-mid) var(--ease); }
.drawer-panel { position: absolute; right: 0; top: 0; height: 100vh; width: 560px; max-width: 100vw; background: var(--panel); overflow-y: auto; box-shadow: -20px 0 60px rgba(0,0,0,.25); display: flex; flex-direction: column; animation: drawer-in 260ms var(--ease); }
.drawer-head { display: flex; align-items: flex-start; gap: 16px; padding: 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 4px 0; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { padding: 24px; flex: 1; }
.drawer-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---- Toast: see the canonical rule lower in this file (centered, bottom). The
   old top-right rule was removed — keeping both merged their positions (top+right
   AND left+bottom) into one giant full-page box. ------------------------------*/

/* ---- Impersonation banner -------------------------------------------------*/
.imp-banner { width: 100%; box-sizing: border-box; background: #fef3c7; color: #92400e; border: 0; border-bottom: 1px solid #fde68a; border-radius: 0; padding: 10px 20px; margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }

/* ---- Platform Usage view (admin) ------------------------------------------*/
.funnel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.funnel-stage { flex: 1; min-width: 160px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); text-align: center; }
.funnel-num { font-family: var(--font-mono); font-size: 32px; font-weight: 600; color: var(--ink); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.funnel-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }
.funnel-pct { font-size: 13px; color: #16a34a; font-weight: 600; margin-top: 8px; font-variant-numeric: tabular-nums; }
.funnel-arrow { font-size: 22px; color: var(--muted); flex-shrink: 0; }
.usage-bars { display: flex; flex-direction: column; gap: 8px; }
.us-row { display: grid; grid-template-columns: 160px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; }
.us-row .lbl { color: var(--ink); text-transform: capitalize; word-break: break-all; }
/* Meter track: neutral until near-limit, then amber→red. A hard cap should LOOK
   like it's filling up. Add .warn (≈80%+) / .danger (≈95%+) on the fill. */
.us-row .track { background: var(--line); border-radius: 4px; height: 6px; overflow: hidden; }
.us-row .fill { background: var(--primary); height: 100%; border-radius: 4px; transition: width var(--t-mid) var(--ease); }
.us-row .fill.warn { background: #e08a1e; }
.us-row .fill.danger { background: #e0483d; }
.us-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.stack-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.stack-bar > span { display: block; height: 100%; }
.stack-legend { display: flex; gap: 18px; margin-top: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.stack-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 6px -1px 0; }

/* ---- Footprint card (merchant drawer + standalone) ------------------------*/
.fp-card { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.fp-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.fp-timeline { display: flex; flex-direction: column; gap: 10px; }
.fp-step { display: flex; gap: 10px; align-items: flex-start; }
.fp-step strong { font-size: 13px; color: var(--ink); display: block; }
.fp-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.fp-dot-1 { background: #6366f1; }
.fp-dot-2 { background: #06b6d4; }
.fp-dot-3 { background: #16a34a; }
.fp-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }

/* ---- Theme picker cards (admin → JunePay → default checkout theme) ----*/
.theme-card {
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--panel);
  color: var(--ink); cursor: pointer; font: inherit; font-weight: 500;
  text-align: left; transition: border-color .15s, transform .12s, box-shadow .15s;
  position: relative;
}
.theme-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(47,107,237,.12); }
.theme-card.active {
  border-color: var(--primary);
  background: rgba(47,107,237,.06);
  box-shadow: 0 0 0 4px rgba(47,107,237,.20), 0 8px 24px rgba(47,107,237,.15);
}
.theme-card.active::after {
  content: '✓ SELECTED'; position: absolute; top: -10px; right: 10px;
  padding: 4px 10px; border-radius: 999px; background: var(--primary);
  color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .05em;
  box-shadow: 0 4px 12px rgba(47,107,237,.35);
}
.theme-card .theme-name { font-size: 14px; font-weight: 600; padding: 0 2px; display: flex; align-items: center; justify-content: space-between; }
.theme-card .theme-sub { font-size: 11px; font-weight: 400; color: var(--muted); }

/* The preview is a small mock of the checkout layout: brand chip, QR area, button. */
.theme-card .theme-preview {
  width: 100%; aspect-ratio: 16 / 10; border-radius: 10px;
  border: 1px solid var(--line); position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 10px;
}
.theme-card .tp-head { display: flex; align-items: center; gap: 6px; }
.theme-card .tp-logo { width: 14px; height: 14px; border-radius: 4px; }
.theme-card .tp-title-bar { flex: 1; height: 5px; border-radius: 2px; opacity: .35; background: currentColor; max-width: 60%; }
.theme-card .tp-qr { align-self: center; width: 38px; height: 38px; border-radius: 4px; opacity: .85; background:
  conic-gradient(currentColor 0 25%, transparent 0 50%, currentColor 0 75%, transparent 0); }
.theme-card .tp-btn { height: 14px; border-radius: 4px; opacity: .9; }

/* Theme palettes (background, accent text color used by ::after / tp-btn / tp-qr) */
.tp-classic { background: #f1f5f9; color: #6366f1; }
.tp-classic .tp-logo { background: #6366f1; }
.tp-classic .tp-btn  { background: #6366f1; }
.tp-orange  { background: #fff7ed; color: #ea580c; }
.tp-orange  .tp-logo { background: #ea580c; }
.tp-orange  .tp-btn  { background: #ea580c; }
.tp-dark    { background: #0f172a; color: #818cf8; }
.tp-dark    .tp-logo { background: #818cf8; }
.tp-dark    .tp-btn  { background: #818cf8; }
.tp-dark    .tp-title-bar { background: #cbd5e1; opacity: .25; }
.tp-blue    { background: #eff6ff; color: #245ad0; }
.tp-blue    .tp-logo { background: #245ad0; }
.tp-blue    .tp-btn  { background: #245ad0; }

/* ---- Nepal Gateway workspace ----------------------------------------------*/
.nepal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .nepal-grid { grid-template-columns: 1fr; } }
.qr-frame { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px; border: 1px dashed var(--line-2); border-radius: 12px; background: var(--bg); }
.qr-frame img { width: 240px; height: 240px; max-width: 100%; border-radius: 12px; background: #fff; padding: 8px; box-shadow: var(--shadow); }
.qr-frame .vpa-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font: 12.5px var(--font-mono); }

/* ---- Chart container ------------------------------------------------------*/
/* Chart.js sizes its canvas to fit the parent. Without a height on the parent
   the canvas ends up at 0px and you get an invisible chart inside a tall panel.
   Give every chart a fixed height + responsive width. */
/* ---- API docs "In this reference" jump nav --------------------------------*/
.doc-toc { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-toc button { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); font: inherit; font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 999px; cursor: pointer; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.doc-toc button:hover { border-color: var(--primary); color: var(--primary); background: rgba(47,107,237,.06); }
.doc-toc button:focus-visible { outline: none; box-shadow: var(--ring-shadow); }
.doc-toc button .pill { font-size: 9px; padding: 2px 6px; }

.chart-box { position: relative; width: 100%; height: 240px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-box.tall { height: 320px; }

/* ---- Skeleton loading (shimmer placeholders) -------------------------------*/
/* A quiet, design-system-native loading state: neutral blocks that shimmer once
   per ~1.3s, replaced in-place the moment real data lands. Used across the backend
   dashboards + tables (see app.js skel* helpers). */
.skel { position: relative; overflow: hidden; background: var(--line); border-radius: 8px; display: inline-block; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--panel) 72%, transparent), transparent);
  animation: skel-shimmer 1.3s ease-in-out infinite; }
@keyframes skel-shimmer { 100% { transform: translateX(100%); } }
.skel-line { height: 12px; border-radius: 6px; width: 100%; }
.skel-val  { height: 30px; width: 62%; border-radius: 9px; }        /* KPI number placeholder */
.chart-skel { position: absolute; inset: 0; border-radius: 12px; display: block; }
body[data-theme=dark] .skel { background: var(--line-2); }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* ---- Loading state --------------------------------------------------------*/
.loading { color: var(--muted); padding: 32px; text-align: center; }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }

/* ---- Sidebar collapsed (laptop hamburger) ---------------------------------*/
.app.sidebar-collapsed { grid-template-columns: 64px 1fr; }
.app.sidebar-collapsed .sidebar .brand-title,
.app.sidebar-collapsed .sidebar .brand-sub,
.app.sidebar-collapsed .sidebar .brand-pro,
.app.sidebar-collapsed .sidebar .nav-sec,
.app.sidebar-collapsed .sidebar .nav-item > span { display: none; }
.app.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 12px 0; }
.app.sidebar-collapsed .sidebar .brand { justify-content: center; padding: 16px 0; }
.app.sidebar-collapsed .sidebar .sidebar-foot { justify-content: center; padding: 8px 0; }

/* ---- Mobile (≤1024px): hide sidebar by default, hamburger reveals it ------*/
@media (max-width: 1024px) {
  .app { grid-template-columns: 0 1fr; }
  .app:not(.sidebar-open) .sidebar { width: 0; overflow: hidden; }
  .app.sidebar-open .sidebar {
    position: fixed; top: 0; left: 0; width: 240px; height: 100vh;
    z-index: 30; box-shadow: 8px 0 24px rgba(0,0,0,.25);
  }
  .app.sidebar-open::after {
    content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 29;
  }
  #sidebarToggle { display: grid; }
  .content { padding: 16px 16px 32px; }
  .topbar { padding: 10px 16px; }
  .nepal-grid { grid-template-columns: 1fr; }
  .drawer-panel { width: 100vw; }
  .modal-card { max-width: 100%; }
}

@media (max-width: 640px) {
  .cards-row { grid-template-columns: 1fr; }
  .funnel { flex-direction: column; }
  .funnel-arrow { transform: rotate(90deg); }
}

/* ---- Hero identity header (content-native, theme-aware) --------------------*/
/* Flat panel surface that belongs to the content — not a dark slab fighting the
   canvas. Identity comes from ONE restrained signature: the brand gradient as a
   3px left stripe (echoes .brand-mark). Hierarchy is carried by type weight and
   --ink, not by a colored background. Adapts to light/dark via tokens. */
.hero {
  position: relative; overflow: hidden; border-radius: 14px; padding: 20px 24px 20px 27px; margin: 0 0 18px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--ink); display: flex; align-items: center; gap: 20px;
}
.hero::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--primary); pointer-events: none;
}
.hero-main { flex: 1; min-width: 0; position: relative; }
.hero-kicker {
  display: inline-block; font-size: 11px; letter-spacing: .12em; font-weight: 700; color: var(--primary);
  background: rgba(47,107,237,.08); border: 1px solid rgba(47,107,237,.18); padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase;
}
.hero-title { font-size: 22px; font-weight: 700; margin-top: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; line-height: 1.15; letter-spacing: -.022em; text-wrap: balance; color: var(--ink); }
.hero-id {
  font: 600 12px var(--font-mono); color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); padding: 3px 9px; border-radius: 7px;
}
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.hero-right { position: relative; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; }
.hero-status {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: #16a34a;
  background: rgba(22,163,74,.1); border: 1px solid rgba(22,163,74,.22); padding: 5px 12px; border-radius: 999px;
}
body[data-theme=dark] .hero-status { color: #4ade80; }
.hero-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
@media (max-width: 640px) { .hero { flex-direction: column; align-items: flex-start; } .hero-right { align-items: flex-start; text-align: left; } }

/* ---- Sub-brand tagline ----------------------------------------------------*/
.brand-tag { font-size: 9px; letter-spacing: .14em; color: #64748b; text-transform: uppercase; margin-top: 2px; }

/* ---- Telemetry footer -----------------------------------------------------*/
.app-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 22px; border-top: 1px solid var(--line); color: var(--muted);
  font: 11px/1.5 var(--font-mono);
}
.app-foot .net { display: inline-flex; align-items: center; gap: 7px; color: #16a34a; }
.app-foot .net .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

/* ---- Toast (transient feedback / error safety net) ------------------------*/
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  opacity: 0; pointer-events: none; max-width: 90vw; padding: 12px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500; color: #fff; background: #1e293b;
  box-shadow: 0 12px 34px -12px rgba(0,0,0,.55); transition: opacity .2s, transform .2s; z-index: 9999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }
.toast.info { background: #1e293b; }
