/* Pay0 Plus app UI v4. Colours come from CSS variables injected by PHP (admin editable). */
:root {
  --theme-primary: #8b5cf6;
  --theme-primary-dark: #7c3aed;
  --theme-accent: #a855f7;
  --theme-body-bg: #110d1c;
  --theme-app-bg: #f5f3fb;
  --theme-card-bg: #ffffff;
  --theme-input-border: #ebe7f5;
  --theme-border: #ebe7f5;
  --theme-text-primary: #1e1533;
  --theme-text: #1e1533;
  --theme-text-muted: #7a7091;
  --white: #ffffff;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --top-h: 60px;
  --sidebar-w: 248px;
  --bottom-h: 64px;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --grad: linear-gradient(135deg, var(--theme-primary-dark), var(--theme-accent));
  --shadow-sm: 0 1px 2px rgba(30,21,51,.05);
  --shadow: 0 6px 18px -10px rgba(30,21,51,.22);
  --ring: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 18%, transparent);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.v2 {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--theme-app-bg);
  color: var(--theme-text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
:where(body.v2) a { color: inherit; text-decoration: none; }
body.v2 img { max-width: 100%; }
body.v2 h1, body.v2 h2, body.v2 h3, body.v2 h4 { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }

/* ---------- Top bar ---------- */
.v2-topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h);
  margin-left: var(--sidebar-w);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--theme-primary);
  background-image: var(--grad);
  color: var(--white);
  box-shadow: 0 4px 16px -8px color-mix(in srgb, var(--theme-primary) 70%, transparent);
}
.v2-top-icon {
  position: relative;
  width: 38px; height: 38px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.18); border-radius: var(--r);
  background: rgba(255,255,255,.12); color: var(--white);
  font-size: 16px; cursor: pointer; transition: background .15s;
}
.v2-top-icon:hover { background: rgba(255,255,255,.22); color: var(--white); }
.v2-top-icon .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 2px var(--theme-primary-dark); }
.v2-top-title { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.v2-top-title img { width: 32px; height: 32px; border-radius: 9px; background: var(--white); padding: 2px; flex: none; }
.v2-top-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.v2-top-name strong { font-size: 16px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-top-name small { font-size: 11.5px; font-weight: 600; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-topbar-actions { display: flex; align-items: center; gap: 8px; }
.v2-top-plan {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.16); font-size: 12px; font-weight: 700; color: var(--white);
}
.v2-top-menu { display: none; }

/* ---------- Sidebar / drawer ---------- */
.v2-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  width: var(--sidebar-w);
  background: var(--theme-card-bg);
  border-right: 1px solid var(--theme-input-border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.v2-brand { display: flex; align-items: center; gap: 10px; height: var(--top-h); padding: 0 18px; font-weight: 800; font-size: 16px; border-bottom: 1px solid var(--theme-input-border); flex: none; }
.v2-brand img { border-radius: 9px; }
.v2-side-user { display: flex; align-items: center; gap: 10px; margin: 12px; padding: 12px; border-radius: var(--r-lg); background: var(--grad); color: var(--white); }
.v2-side-user .av { width: 38px; height: 38px; flex: none; border-radius: 50%; background: rgba(255,255,255,.2); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; overflow: hidden; }
.v2-side-user .av img { width: 100%; height: 100%; object-fit: cover; }
.v2-side-user div { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.v2-side-user strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-side-user small { font-size: 12px; opacity: .85; }
.v2-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px 16px; }
.v2-nav-label { padding: 14px 10px 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--theme-text-muted); }
.v2-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r);
  font-weight: 600; font-size: 13.5px; color: var(--theme-text-primary);
  transition: background .15s;
}
.v2-nav a .ni { width: 30px; height: 30px; flex: none; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.v2-nav a:hover { background: var(--theme-app-bg); }
.v2-nav a.active { background: color-mix(in srgb, var(--theme-primary) 10%, transparent); color: var(--theme-primary-dark); }
.v2-nav a.active .ni { background: var(--theme-primary); color: var(--white); }
.v2-nav-badge { margin-left: auto; padding: 1px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 800; background: var(--theme-primary); color: var(--white); }
.v2-backdrop { display: none; }

/* ---------- Bottom nav (mobile) ---------- */
.v2-bottomnav { display: none; }

/* ---------- Main ---------- */
.v2-main, body.v2 .app-content {
  margin-left: var(--sidebar-w);
  padding: 22px 24px;
  max-width: calc(1080px + var(--sidebar-w));
  min-height: calc(100vh - var(--top-h) - 70px);
}

/* ---------- Footer ---------- */
.v2-footer {
  margin-left: var(--sidebar-w);
  max-width: calc(1080px + var(--sidebar-w));
  padding: 16px 24px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--theme-text-muted); font-size: 12.5px;
}
.v2-footer-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--theme-text-primary); }
.v2-footer-brand img { width: 22px; height: 22px; border-radius: 6px; }
.v2-footer-links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.v2-footer-links a { font-weight: 600; }
.v2-footer-links a:hover { color: var(--theme-primary-dark); }
.v2-footer-links .tg { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--r-sm); background: #e7f9ee; color: #128c4a; }

.v2-ticker { display: flex; align-items: center; gap: 8px; background: var(--theme-text); color: var(--white); font-size: 13px; font-weight: 600; padding: 7px 8px 7px 12px; border-radius: var(--r); overflow: hidden; }
.v2-ticker-track { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.v2-ticker-move { display: inline-flex; gap: 48px; padding-left: 100%; animation: v2tick 30s linear infinite; }
.v2-ticker-move span { display: inline-flex; gap: 8px; align-items: center; }
.v2-ticker-move i { color: #facc15; }
.v2-ticker:hover .v2-ticker-move { animation-play-state: paused; }
@keyframes v2tick { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .v2-ticker-move { animation: none; padding-left: 0; } }
.v2-ticker-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: var(--r-sm); padding: 6px 10px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; background: var(--theme-primary); color: var(--white); text-decoration: none; }
.v2-ticker-btn.wa, .v2-btn-wa { background: #25d366; color: var(--white); }
@media (max-width: 480px) { .v2-ticker-btn { padding: 6px 8px; } .v2-ticker-btn span { display: none; } }

.v2-dlg { width: min(400px, calc(100% - 32px)); border: 0; border-radius: var(--r-lg); padding: 22px 20px 20px; box-shadow: var(--shadow); color: var(--theme-text-primary); background: var(--theme-card-bg); }
.v2-dlg::backdrop { background: rgba(17,13,28,.55); }
.v2-dlg h3 { margin: 10px 0 8px; font-size: 18px; }
.v2-dlg p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; color: var(--theme-text-muted); }
.v2-dlg-x { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: var(--r-sm); background: var(--theme-app-bg); color: var(--theme-text); cursor: pointer; }
.v2-dlg-ic { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: var(--r); background: var(--grad); color: var(--white); font-size: 18px; }
.v2-dlg-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; margin: 10px 0 8px; border: 1px solid var(--theme-border); border-radius: var(--r); font-size: 14px; }
.v2-dlg-free { padding: 10px 12px; margin-bottom: 14px; border-radius: var(--r); background: #dcfce7; color: #14532d; font-size: 13px; }

@media (max-width: 991px) {
  .v2-topbar, .v2-main, body.v2 .app-content, .v2-footer { margin-left: 0; }
  .v2-topbar { padding: 0 12px; gap: 10px; }
  .v2-top-plan { display: none; }
  .v2-top-menu { display: inline-flex; }
  .v2-sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(17,13,28,.2); width: 280px; }
  body.nav-open .v2-sidebar { transform: none; }
  body.nav-open .v2-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(17,13,28,.45); }
  .v2-main, body.v2 .app-content { padding: 14px 12px 18px; }
  .v2-footer { padding: 4px 12px calc(var(--bottom-h) + 22px); justify-content: center; text-align: center; }
  .v2-bottomnav {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 45;
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--theme-card-bg); border-top: 1px solid var(--theme-input-border);
    box-shadow: 0 -6px 20px -14px rgba(30,21,51,.3);
  }
  .v2-bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; font-weight: 700; color: var(--theme-text-muted);
  }
  .v2-bottomnav a .ico { font-size: 18px; }
  .v2-bottomnav a.active { color: var(--theme-primary); }
  .v2-bottomnav a.fab .ico {
    width: 52px; height: 52px; margin-top: -28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--grad); color: var(--white); font-size: 19px;
    border: 4px solid var(--theme-card-bg); box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--theme-primary) 60%, transparent);
  }
}

/* ---------- Layout helpers ---------- */
.v2-stack { display: flex; flex-direction: column; gap: 14px; }
.v2-grid { display: grid; gap: 10px; }
.v2-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.v2-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.v2-grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.v2-split { display: grid; gap: 14px; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); align-items: start; }
@media (max-width: 991px) { .v2-split { grid-template-columns: minmax(0,1fr); } }
.v2-split > *, .v2-stack > *, .v2-card { min-width: 0; }
.v2-card-title, .v2-card-sub { overflow-wrap: anywhere; }
@media (max-width: 767px) { .v2-grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }

.v2-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.v2-page-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
.v2-page-head p { margin: 2px 0 0; color: var(--theme-text-muted); font-size: 13px; text-wrap: pretty; }

/* ---------- Hero (purple balance card) ---------- */
.v2-hero {
  position: relative; overflow: hidden;
  padding: 18px; border-radius: var(--r-lg);
  background: var(--grad); color: var(--white);
  box-shadow: 0 14px 28px -16px color-mix(in srgb, var(--theme-primary) 80%, transparent);
  display: flex; flex-direction: column; gap: 6px;
}
.v2-hero::after { content: ''; position: absolute; right: -40px; bottom: -60px; width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,.1); pointer-events: none; }
.v2-hero::before { content: ''; position: absolute; right: 18px; bottom: 16px; width: 56px; height: 8px; background: radial-gradient(circle, rgba(255,255,255,.7) 1.5px, transparent 2px) 0 0 / 8px 8px repeat-x; pointer-events: none; }
.v2-hero > * { position: relative; z-index: 1; }
.v2-hero-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.v2-hero-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; opacity: .95; }
.v2-hero-label .ico { width: 28px; height: 28px; border-radius: var(--r-sm); background: rgba(255,255,255,.18); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.v2-hero-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.v2-hero-value small { font-size: 14px; font-weight: 600; opacity: .8; }
.v2-hero-sub { margin: 0; font-size: 13px; opacity: .88; text-wrap: pretty; }
.v2-hero-divider { height: 1px; background: rgba(255,255,255,.2); margin: 6px 0 2px; }
.v2-hero .v2-meter { background: rgba(255,255,255,.22); }
.v2-hero .v2-meter > span { background: var(--white); }

/* ---------- Profile band (home) ---------- */
.v2-band { display: flex; align-items: center; gap: 12px; color: var(--white); }
.v2-band .av { width: 52px; height: 52px; flex: none; border-radius: 50%; background: var(--white); color: var(--theme-primary-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; overflow: hidden; border: 2px solid rgba(255,255,255,.6); }
.v2-band .av img { width: 100%; height: 100%; object-fit: cover; }
.v2-band div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.v2-band strong { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-band small { font-size: 12.5px; opacity: .9; }
.v2-uid { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.18); font-size: 11.5px; font-weight: 700; border: 0; color: inherit; cursor: pointer; font-family: inherit; }

/* ---------- Cards ---------- */
.v2-card, body.v2 .tile, body.v2 .card {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-input-border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.v2-card.flush { padding: 0; overflow: hidden; }
.v2-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--theme-input-border); }
.v2-card-head .v2-card-title { margin: 0; }
.v2-card-body { padding: 16px; }
.v2-card-title { margin: 0 0 12px; display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 800; }
.v2-card-title i { color: var(--theme-primary); font-size: 14px; }
.v2-card-sub { margin: -6px 0 12px; color: var(--theme-text-muted); font-size: 12.5px; }
.v2-link { font-size: 12.5px; font-weight: 700; color: var(--theme-primary); }
.v2-link:hover { color: var(--theme-primary-dark); }
.v2-hint { color: var(--theme-text-muted); font-size: 12.5px; }

/* Stat cards */
.v2-stat {
  background: var(--theme-card-bg); border: 1px solid var(--theme-input-border);
  border-radius: var(--r-lg); padding: 12px 14px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.v2-stat-label { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--theme-text-muted); }
.v2-stat-value { font-size: 20px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-stat-value.ok { color: var(--ok); }
.v2-stat-value.brand { color: var(--theme-primary); }
.v2-stat-icon { display: none; }

/* Icon tiles */
.v2-tile { width: 40px; height: 40px; flex: none; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.tile-purple { background: #f1ebff; color: #7c3aed; }
.tile-green  { background: #e5f7ef; color: #0f9d6c; }
.tile-blue   { background: #e8f0ff; color: #3b6cf6; }
.tile-orange { background: #fff1e3; color: #ea6c0b; }
.tile-pink   { background: #ffe9f1; color: #e0407e; }
.tile-red    { background: #ffeaea; color: #e03131; }
.tile-gray   { background: #f0eef5; color: #6e6585; }
.tile-gold   { background: #fff5d6; color: #a86e00; }
.tile-sky    { background: #e3f4fd; color: #1d8fd1; }

/* Quick action grid */
.v2-quick { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.v2-quick a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: var(--r); background: var(--theme-card-bg); border: 1px solid var(--theme-input-border); font-size: 12px; font-weight: 700; text-align: center; transition: transform .12s, border-color .12s; }
.v2-quick a:hover { border-color: color-mix(in srgb, var(--theme-primary) 40%, transparent); transform: translateY(-1px); }
.v2-quick .v2-tile { width: 38px; height: 38px; }

/* List rows */
.v2-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.v2-list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--theme-input-border); }
.v2-list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.v2-list-row:first-child { padding-top: 0; }
.v2-card.flush .v2-list-row, .v2-list.rows .v2-list-row { padding: 12px 16px; }
a.v2-list-row { transition: background .12s; }
a.v2-list-row:hover strong { color: var(--theme-primary-dark); }
.v2-card.flush a.v2-list-row:hover { background: var(--theme-app-bg); }
.v2-list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.v2-list-body strong { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-list-body small { font-size: 12.5px; color: var(--theme-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-list-actions { display: flex; align-items: center; gap: 6px; }
.v2-list-actions form { margin: 0; }
.v2-chev { color: #c2bad6; font-size: 12px; }

/* ---------- Slider ---------- */
.v2-slider { position: relative; }
.v2-slides { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: var(--r-lg); }
.v2-slides::-webkit-scrollbar { display: none; }
.v2-slide {
  position: relative; overflow: hidden; flex: 0 0 100%; scroll-snap-align: start;
  display: flex; align-items: center; gap: 14px; min-height: 108px;
  padding: 16px 18px; border-radius: var(--r-lg); color: var(--white);
}
.v2-slide::after { content: ''; position: absolute; right: -30px; top: -40px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.12); }
.v2-slide > * { position: relative; z-index: 1; }
.v2-slide .big { width: 52px; height: 52px; flex: none; border-radius: var(--r-lg); background: rgba(255,255,255,.18); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }
.v2-slide div { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.v2-slide strong { font-size: 15.5px; font-weight: 800; line-height: 1.25; text-wrap: balance; }
.v2-slide small { font-size: 12.5px; opacity: .9; text-wrap: pretty; }
.v2-slide .go { flex: none; padding: 7px 12px; border-radius: var(--r-sm); background: var(--white); color: #1e1533; font-size: 12px; font-weight: 800; white-space: nowrap; }
.s-1 { background: linear-gradient(135deg, #6d28d9, #a855f7); }
.s-2 { background: linear-gradient(135deg, #0e7490, #22b8cf); }
.s-3 { background: linear-gradient(135deg, #c2410c, #f59f00); }
.s-4 { background: linear-gradient(135deg, #0f766e, #20c997); }
.v2-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.v2-dots button { width: 6px; height: 6px; padding: 0; border: 0; border-radius: 6px; background: #d4cde6; cursor: pointer; transition: width .2s, background .2s; }
.v2-dots button.on { width: 18px; background: var(--theme-primary); }

/* ---------- Buttons ---------- */
.v2-btn, body.v2 .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 42px;
  border: 0; border-radius: var(--r);
  background: var(--grad); color: var(--white);
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--theme-primary) 80%, transparent);
  transition: transform .12s ease, filter .12s ease;
  text-decoration: none; white-space: nowrap;
}
.v2-btn:hover, body.v2 .btn-primary:hover { filter: brightness(1.06); color: var(--white); }
.v2-btn:active { transform: translateY(1px); }
.v2-btn:disabled { opacity: .6; cursor: not-allowed; }
.v2-btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.v2-btn-xs { min-height: 30px; padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
.v2-btn-block { width: 100%; }
.v2-btn-ghost { background: var(--theme-card-bg); color: var(--theme-primary-dark); border: 1.5px solid color-mix(in srgb, var(--theme-primary) 60%, transparent); box-shadow: none; }
.v2-btn-ghost:hover { color: var(--theme-primary-dark); background: color-mix(in srgb, var(--theme-primary) 7%, var(--theme-card-bg)); }
.v2-btn-soft { background: color-mix(in srgb, var(--theme-primary) 10%, var(--theme-card-bg)); color: var(--theme-primary-dark); box-shadow: none; }
.v2-btn-soft:hover { color: var(--theme-primary-dark); }
.v2-btn-outline-white { background: transparent; color: var(--white); border: 1.5px solid rgba(255,255,255,.65); box-shadow: none; }
.v2-btn-outline-white:hover { background: rgba(255,255,255,.12); color: var(--white); }
.v2-btn-danger { background: var(--bad); box-shadow: none; }
.v2-btn.v2-btn-white,
.v2-btn.v2-btn-white:hover,
.v2-btn.v2-btn-white:focus,
.v2-btn.v2-btn-white:active,
.v2-btn.v2-btn-white:visited { background: var(--white); color: var(--theme-primary-dark); filter: none; box-shadow: 0 6px 14px -10px rgba(0,0,0,.4); }
.v2-btn.v2-btn-white i { color: var(--theme-primary); }
.v2-btn:focus-visible, .v2-icon-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--theme-primary) 40%, transparent); outline-offset: 2px; }
body.v2 .btn { border-radius: var(--r); font-weight: 700; }
.v2-icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); border: 1px solid var(--theme-input-border); background: var(--theme-card-bg); color: var(--theme-text-muted); cursor: pointer; font-size: 13px; }
.v2-icon-btn:hover { color: var(--theme-primary-dark); border-color: color-mix(in srgb, var(--theme-primary) 40%, transparent); }
.v2-icon-btn.danger:hover { color: var(--bad); border-color: var(--bad); }

/* Switch */
.v2-switch { position: relative; flex: none; width: 44px; height: 24px; padding: 0; border: 0; border-radius: 24px; background: #d9d4e6; cursor: pointer; transition: background .2s; }
.v2-switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.v2-switch.on { background: var(--ok); }
.v2-switch.on span { transform: translateX(20px); }

/* ---------- Forms ---------- */
.v2-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.v2-field > span { font-size: 12.5px; font-weight: 700; color: var(--theme-text-muted); }
.v2-input, body.v2 .form-control, body.v2 select.form-select {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1.5px solid var(--theme-input-border); border-radius: var(--r);
  background: var(--theme-app-bg); color: var(--theme-text-primary);
  font: inherit; font-size: 14px; outline: none; transition: border-color .15s, background .15s;
}
.v2-input:focus, body.v2 .form-control:focus { border-color: var(--theme-primary); background: var(--theme-card-bg); box-shadow: var(--ring); }
.v2-input-group { display: flex; align-items: stretch; border: 1.5px solid var(--theme-input-border); border-radius: var(--r); background: var(--theme-app-bg); overflow: hidden; }
.v2-input-group:focus-within { border-color: var(--theme-primary); background: var(--theme-card-bg); box-shadow: var(--ring); }
.v2-input-group .pre { display: inline-flex; align-items: center; padding: 0 10px; font-weight: 700; color: var(--theme-text-muted); border-right: 1.5px solid var(--theme-input-border); font-size: 13.5px; }
.v2-input-group .v2-input { border: 0; background: transparent; box-shadow: none; }
.v2-form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.v2-form-row .v2-field { flex: 1 1 200px; }
.v2-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.v2-form-grid > .v2-amount-chips, .v2-form-grid > .v2-btn, .v2-form-grid > .full { grid-column: 1 / -1; }
@media (max-width: 575px) { .v2-form-grid { grid-template-columns: 1fr; } }
.v2-amount-chips { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.v2-chip { min-height: 40px; border-radius: var(--r); border: 1.5px solid var(--theme-input-border); background: var(--theme-app-bg); color: var(--theme-primary-dark); font: inherit; font-weight: 700; cursor: pointer; }
.v2-chip.on { background: var(--grad); color: var(--white); border-color: transparent; }

/* Copy fields (dashed, like invitation code) */
.v2-copy, .v2-copybox { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 12px; border: 1.5px dashed color-mix(in srgb, var(--theme-primary) 50%, transparent); border-radius: var(--r); background: color-mix(in srgb, var(--theme-primary) 5%, var(--theme-card-bg)); }
.v2-hero .v2-copybox { border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.12); }
.v2-copy-input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--theme-primary-dark); font: 600 13px 'JetBrains Mono', monospace; outline: none; text-overflow: ellipsis; }
.v2-hero .v2-copy-input { color: var(--white); }
.v2-copy code, .v2-copy span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--theme-primary-dark); }
.v2-copyfield { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border: 1.5px dashed color-mix(in srgb, var(--theme-primary) 50%, transparent); border-radius: var(--r); background: color-mix(in srgb, var(--theme-primary) 5%, var(--theme-card-bg)); }
.v2-copyfield > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.v2-copyfield label { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--theme-text-muted); }
.v2-copyfield input { width: 100%; border: 0; padding: 0; background: transparent; outline: none; color: var(--theme-primary-dark); font: 700 14px 'JetBrains Mono', monospace; text-overflow: ellipsis; }
.v2-copyfield input.masked { -webkit-text-security: disc; }
.v2-share { display: flex; gap: 8px; flex-wrap: wrap; }

/* Code block */
.v2-code { margin: 0; padding: 12px 14px; border-radius: var(--r); background: #17122a; color: #e9e3ff; font: 500 12.5px/1.6 'JetBrains Mono', monospace; overflow-x: auto; white-space: pre; }
.v2-code .k { color: #c4b5fd; }
.v2-code .s { color: #86efac; }
.v2-endpoint { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r); background: var(--theme-app-bg); border: 1px solid var(--theme-input-border); min-width: 0; }
.v2-endpoint code { flex: 1; min-width: 0; font: 600 12.5px 'JetBrains Mono', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2-method { padding: 3px 7px; border-radius: 6px; background: #e5f7ef; color: #0f9d6c; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.v2-tabs { display: flex; gap: 4px; padding: 4px; border-radius: var(--r); background: var(--theme-app-bg); border: 1px solid var(--theme-input-border); overflow-x: auto; }
.v2-tabs button { flex: 1; padding: 7px 12px; border: 0; border-radius: var(--r-sm); background: transparent; font: inherit; font-size: 13px; font-weight: 700; color: var(--theme-text-muted); cursor: pointer; white-space: nowrap; }
.v2-tabs button.on { background: var(--theme-card-bg); color: var(--theme-primary-dark); box-shadow: var(--shadow-sm); }
.v2-tab-panel[hidden] { display: none; }
.v2-kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.v2-kv dt { font-weight: 700; color: var(--theme-text-muted); font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.v2-kv dd { margin: 0; }

/* ---------- Feedback ---------- */
.v2-alert { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r); font-weight: 600; font-size: 13.5px; }
.v2-alert.ok { background: #e5f7ef; color: #047857; }
.v2-alert.bad { background: #ffeaea; color: #b91c1c; }
.v2-alert.warn { background: #fff1e3; color: #b45309; }
.v2-alert.info { background: #eef2ff; color: #4338ca; }
.v2-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.v2-pill.ok { background: #e5f7ef; color: #047857; }
.v2-pill.warn { background: #fff1e3; color: #b45309; }
.v2-pill.bad { background: #ffeaea; color: #b91c1c; }
.v2-pill.brand { background: #f1ebff; color: #6d28d9; }
.v2-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 10px; text-align: center; color: var(--theme-text-muted); }
.v2-empty i { font-size: 26px; color: color-mix(in srgb, var(--theme-primary) 50%, transparent); }
.v2-empty p { margin: 0; font-size: 13.5px; }
.v2-meter { height: 7px; border-radius: 7px; background: var(--theme-input-border); overflow: hidden; }
.v2-meter > span { display: block; height: 100%; border-radius: 7px; background: var(--grad); }

.v2-toast {
  position: fixed; left: 50%; top: calc(var(--top-h) + 12px); z-index: 90;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  width: min(92vw, 360px); padding: 12px 14px;
  background: var(--theme-card-bg); border-radius: var(--r-lg);
  box-shadow: 0 18px 40px -12px rgba(30,21,51,.35);
  animation: toastIn .35s cubic-bezier(.2,.9,.3,1.3), toastOut .3s ease 3.6s forwards;
}
.v2-toast > div { display: flex; flex-direction: column; gap: 1px; }
.v2-toast strong { font-size: 14px; }
.v2-toast small { font-size: 12.5px; color: var(--theme-text-muted); }
.v2-toast-icon { width: 36px; height: 36px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--white); font-size: 16px; background: var(--ok); }
.v2-toast.bad .v2-toast-icon { background: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -16px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, -12px); visibility: hidden; } }

/* ---------- Tables ---------- */
.v2-table-wrap { overflow-x: auto; }
.v2-table, body.v2 table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.v2-table th, body.v2 table.table th { text-align: left; padding: 9px 14px; background: var(--theme-app-bg); color: var(--theme-text-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; border: 0; }
.v2-table td, body.v2 table.table td { padding: 11px 14px; border-top: 1px solid var(--theme-input-border); vertical-align: middle; }

/* ---------- Subscription ---------- */
.plan-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.plan-card.featured { background: var(--grad); color: var(--white); border-color: transparent; box-shadow: 0 16px 30px -18px color-mix(in srgb, var(--theme-primary) 90%, transparent); }
.plan-card.current { outline: 2px solid var(--ok); outline-offset: -2px; }
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-ico { width: 36px; height: 36px; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.plan-card.featured .plan-ico { background: rgba(255,255,255,.2); color: var(--white); }
.plan-tag { position: static; }
.plan-name { font-size: 14px; font-weight: 800; }
.plan-price { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.plan-price small { font-size: 12.5px; font-weight: 600; opacity: .7; }
.plan-limit { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--theme-app-bg); color: var(--theme-primary-dark); }
.plan-card.featured .plan-limit { background: rgba(255,255,255,.18); color: var(--white); }
.plan-feats { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px dashed var(--theme-input-border); display: flex; flex-direction: column; gap: 7px; flex: 1; }
.plan-card.featured .plan-feats { border-top-color: rgba(255,255,255,.3); }
.plan-feat { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.4; }
.plan-feat i { margin-top: 3px; font-size: 11px; color: var(--ok); }
.plan-card.featured .plan-feat i { color: var(--white); }
.plan-feat.off { opacity: .5; }
.plan-feat.off i { color: var(--theme-text-muted); }
.plan-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
@media (max-width: 575px) { .plan-grid { grid-template-columns: 1fr; } }

/* ---------- Theme picker ---------- */
.theme-card.current { outline: 2px solid var(--theme-primary); outline-offset: -1px; }
.theme-frame { position: relative; height: 320px; overflow: hidden; border-radius: var(--r); background: var(--theme-app-bg); }
.theme-frame iframe { width: 390px; height: 780px; border: 0; transform: scale(.41); transform-origin: top left; position: absolute; left: 50%; margin-left: -80px; pointer-events: none; }
.theme-lock { position: absolute; top: 8px; right: 8px; display: inline-flex; gap: 6px; align-items: center; padding: 4px 9px; border-radius: 6px; background: rgba(17,13,28,.75); color: var(--white); font-size: 11.5px; font-weight: 700; }

/* ---------- Admin VIP accent ---------- */
body.is-admin .v2-top-plan { background: linear-gradient(135deg, #f6d365, #d4a017); color: #3b2a00; }
body.is-admin .v2-side-user { background: linear-gradient(135deg, #1e1533, #4c1d95); }

/* ---------- Legacy page overrides ---------- */
body.v2 .app-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding: 0; background: transparent; box-shadow: none; }
body.v2 .app-title h1 { font-size: 19px; font-weight: 800; margin: 0; }
body.v2 .app-breadcrumb { display: none; }
body.v2 .tile { margin-bottom: 14px; }
body.v2 #loading_ajax { display: none; position: fixed; inset: 0; z-index: 3000; background: rgba(17,13,28,.35); }
body.v2 .badge { border-radius: 6px; }

/* ---------- Add-merchant steps ---------- */
.v2-steps { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.v2-step { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--theme-text-muted); white-space: nowrap; }
.v2-step b, .v2-step i { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; background: var(--theme-app-bg); border: 1.5px solid var(--theme-border); font-style: normal; }
.v2-step.active { color: var(--theme-primary-dark); }
.v2-step.active b { background: var(--theme-primary); border-color: var(--theme-primary); color: var(--white); }
.v2-step.done { color: var(--ok); }
.v2-step.done i { background: var(--ok); border-color: var(--ok); color: var(--white); }
.v2-step-line { flex: 1; height: 2px; background: var(--theme-border); border-radius: 2px; }
.v2-hint { display: flex; gap: 8px; align-items: flex-start; line-height: 1.5; }
p.v2-hint { margin: 10px 0 0; }

/* ---------- Modal ---------- */
.v2-modal-back { position: fixed; inset: 0; z-index: 4000; background: rgba(17,13,28,.55); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .2s ease; }
.v2-modal { width: 100%; max-width: 340px; background: var(--theme-card-bg); border-radius: var(--r-lg); padding: 24px 20px 20px; text-align: center; display: flex; flex-direction: column; gap: 8px; animation: popIn .35s cubic-bezier(.2,.9,.3,1.25); }
.v2-modal h3 { margin: 6px 0 0; font-size: 18px; font-weight: 800; color: var(--theme-text); }
.v2-modal p { margin: 0 0 8px; color: var(--theme-text-muted); font-size: 13.5px; word-break: break-word; }
.v2-success-ring { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--ok) 15%, transparent); }
.v2-success-ring i { width: 52px; height: 52px; border-radius: 50%; background: var(--ok); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 24px; animation: popIn .45s .1s both cubic-bezier(.2,.9,.3,1.4); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } }

/* Entrance */
@media (prefers-reduced-motion: no-preference) {
  .v2-main > .v2-stack > * { animation: rise .4s cubic-bezier(.2,.8,.3,1) both; }
  .v2-main > .v2-stack > *:nth-child(2) { animation-delay: .04s; }
  .v2-main > .v2-stack > *:nth-child(3) { animation-delay: .08s; }
  .v2-main > .v2-stack > *:nth-child(4) { animation-delay: .12s; }
  .v2-main > .v2-stack > *:nth-child(n+5) { animation-delay: .16s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
