:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-glow-1: rgba(59, 130, 246, 0.14);
  --bg-glow-2: rgba(16, 185, 129, 0.08);
  --surface: #111a2e;
  --surface-2: #17233c;
  --surface-3: #1e2d4d;
  --surface-glass: rgba(17, 26, 46, 0.84);
  --border: rgba(148, 163, 184, 0.14);
  --border-hover: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-glow: rgba(59, 130, 246, 0.34);
  --accent-text: #ffffff;
  --ok: #34d399;
  --ok-bg: rgba(16, 185, 129, 0.14);
  --warn: #fbbf24;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --shadow-sm: 0 4px 14px rgba(2, 6, 23, 0.28);
  --shadow-md: 0 12px 32px rgba(2, 6, 23, 0.42);
  --shadow-lg: 0 22px 54px rgba(2, 6, 23, 0.62);
  --ctrl-h: 44px;
  --ctrl-h-sm: 36px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #efeae2;
  --bg-glow-1: rgba(44, 92, 197, 0.05);
  --bg-glow-2: rgba(27, 127, 83, 0.04);
  --surface: #f7f4ee;
  --surface-2: #ede7dc;
  --surface-3: #e3dbce;
  --surface-glass: rgba(247, 244, 238, 0.92);
  --border: rgba(27, 30, 40, 0.11);
  --border-hover: rgba(27, 30, 40, 0.24);
  --text: #1b1e28;
  --text-secondary: #2e3442;
  --text-muted: #545b6b;
  --accent: #2c5cc5;
  --accent-strong: #224aa3;
  --accent-soft: rgba(44, 92, 197, 0.11);
  --accent-glow: rgba(44, 92, 197, 0.22);
  --accent-text: #ffffff;
  --ok: #1b7f53;
  --ok-bg: rgba(27, 127, 83, 0.12);
  --warn: #a66308;
  --warn-bg: rgba(166, 99, 8, 0.12);
  --danger: #be2b3c;
  --danger-bg: rgba(190, 43, 60, 0.11);
  --shadow-sm: 0 2px 10px rgba(27, 30, 40, 0.06);
  --shadow-md: 0 10px 26px rgba(27, 30, 40, 0.09);
  --shadow-lg: 0 18px 44px rgba(27, 30, 40, 0.14);
}

html.theme-transition,
html.theme-transition body,
html.theme-transition .card,
html.theme-transition .sidebar,
html.theme-transition .btn,
html.theme-transition input,
html.theme-transition textarea,
html.theme-transition .ui-select-trigger,
html.theme-transition .country-trigger,
html.theme-transition .preset-card {
  transition:
    background-color 240ms var(--ease),
    border-color 240ms var(--ease),
    color 240ms var(--ease),
    box-shadow 240ms var(--ease);
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 420px at 14% -8%, var(--bg-glow-1), transparent 60%),
    radial-gradient(760px 380px at 88% 0%, var(--bg-glow-2), transparent 58%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.end-col { justify-content: flex-end; }
.w-full { width: 100%; }

/* ── App Shell & Sidebar ─────────────────────────────────────── */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.06rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: block;
  box-shadow: 0 6px 18px var(--accent-glow);
  flex-shrink: 0;
}

.brand-sub {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.sidebar-balance {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 13px 14px;
  margin-bottom: 8px;
}

.sidebar-balance-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sidebar-balance-val {
  font-size: 1.32rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
}

.sidebar-balance-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease), transform 140ms var(--ease);
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-btn:active {
  transform: scale(0.985);
}

.nav-btn.active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.32);
  color: var(--accent);
}

[data-theme="dark"] .nav-btn.active {
  color: #93c5fd;
}

.nav-btn.active svg {
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-chip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease);
}

.user-chip:hover {
  border-color: var(--border-hover);
  background: var(--surface-3);
}

.footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.main {
  width: 100%;
  max-width: 1720px;
  min-width: 0;
  margin: 0 auto;
  padding: 26px clamp(18px, 2.5vw, 36px) 56px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  font-weight: 750;
  letter-spacing: -0.025em;
}

.page-sub {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ── Unified Interactive Controls (Inputs, Selects, Buttons) ─── */

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--ctrl-h);
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 180ms var(--ease),
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    transform 140ms var(--ease),
    color 180ms var(--ease);
}

.btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-hover);
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  color: var(--accent-text);
  box-shadow: 0 6px 18px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4b8df8, var(--accent));
  border-color: transparent;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.28);
}

.btn-danger:hover {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.22);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-sm {
  min-height: var(--ctrl-h-sm);
  padding: 0 12px;
  font-size: 0.85rem;
  border-radius: 10px;
}

.btn.is-copied {
  background: var(--ok-bg) !important;
  color: var(--ok) !important;
  border-color: rgba(52, 211, 153, 0.45) !important;
  box-shadow: none !important;
}

.icon-sun,
.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: inline-block;
}

[data-theme="light"] .icon-moon {
  display: inline-block;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="search"],
textarea {
  width: 100%;
  min-height: var(--ctrl-h);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  transition:
    background-color 180ms var(--ease),
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease);
}

input:hover,
textarea:hover {
  border-color: var(--border-hover);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.72;
}

textarea.mono {
  padding: 14px;
  min-height: 200px;
  line-height: 1.55;
  resize: vertical;
  border-radius: var(--r-lg);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-right: 44px;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.pw-toggle:hover,
.pw-toggle.active {
  background: var(--surface-3);
  color: var(--text);
}

.pw-toggle svg {
  width: 18px;
  height: 18px;
}

/* ── Unified Custom Select Dropdown ──────────────────────────── */

.sr-only-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ui-select {
  position: relative;
  width: 100%;
}

.ui-select-trigger,
.country-trigger {
  width: 100%;
  min-height: var(--ctrl-h);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition:
    background-color 180ms var(--ease),
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease);
}

.ui-select-trigger:hover,
.country-trigger:hover {
  border-color: var(--border-hover);
  background: var(--surface-3);
}

.ui-select-trigger.open,
.country-trigger.open,
.ui-select-trigger:focus-visible,
.country-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ui-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ctrl-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 180ms var(--ease);
}

.open .ctrl-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.ui-select-menu,
.country-popover {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 45;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: popIn 160ms var(--ease);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ui-select-menu {
  right: auto;
  min-width: max(100%, 240px);
  width: max-content;
  max-width: min(380px, 90vw);
  max-height: 280px;
  overflow-y: auto;
}

.ui-select-option,
.country-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.91rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.ui-select-option:hover,
.country-option:hover {
  background: var(--surface-2);
}

.ui-select-option.active,
.country-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

[data-theme="dark"] .ui-select-option.active,
[data-theme="dark"] .country-option.active {
  color: #93c5fd;
}

.ctrl-check {
  width: 16px;
  height: 16px;
  opacity: 0;
  flex-shrink: 0;
}

.ui-select-option.active .ctrl-check,
.country-option.active .ctrl-check {
  opacity: 1;
}

/* ── Country Picker with SVG Flags ───────────────────────────── */

.country-picker {
  position: relative;
  width: 100%;
}

.country-trigger-main,
.country-option-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.country-trigger-name,
.country-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-trigger-right,
.country-option-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.flag-svg {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  flex-shrink: 0;
  display: block;
}

.iso-pill {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.country-popover {
  min-width: 310px;
  padding: 10px;
}

.country-search-wrap {
  margin-bottom: 8px;
}

.country-search-input {
  min-height: 38px !important;
  font-size: 0.9rem !important;
  border-radius: 10px !important;
}

.country-regions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.region-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 140ms var(--ease);
}

.region-chip:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.region-chip.active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--accent);
}

[data-theme="dark"] .region-chip.active {
  color: #93c5fd;
}

.country-list {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.country-empty {
  padding: 14px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* ── Cards, KPIs, Progress, Badges ───────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  min-width: 0;
}

.kpi-grid .card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-head h2,
.card-head h3 {
  margin: 0;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.48rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.kpi-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meter-progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 7px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  margin-top: 6px;
  display: block;
}

.meter-progress::-webkit-progress-bar {
  background: var(--surface-3);
  border-radius: 999px;
}

.meter-progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-radius: 999px;
  transition: width 320ms var(--ease);
}

.meter-progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-radius: 999px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--accent-soft);
  color: var(--accent);
}

[data-theme="dark"] .badge-info {
  color: #93c5fd;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}

.status-dot.pulse {
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.65);
  animation: pulseDot 2.2s infinite;
}

@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ── Client Workspace Split Screen ───────────────────────────── */

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.sticky-panel {
  position: sticky;
  top: 22px;
}

.section-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-label:first-child {
  margin-top: 0;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.preset-card {
  text-align: left;
  padding: 14px;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 180ms var(--ease);
}

.preset-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-3);
  transform: translateY(-1px);
}

.preset-card:active {
  transform: scale(0.985);
}

.preset-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.preset-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.preset-icon svg {
  width: 17px;
  height: 17px;
}

.preset-name {
  font-weight: 700;
  font-size: 0.93rem;
}

.preset-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.seg-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.seg-btn {
  min-height: 34px;
  padding: 0 13px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.pill:hover {
  border-color: var(--border-hover);
  background: var(--surface-3);
  color: var(--text);
}

.pill:active {
  transform: scale(0.97);
}

.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="dark"] .pill.active {
  color: #93c5fd;
}

.pill .flag-svg {
  width: 18px;
  height: 14px;
}

.recent-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.recent-title {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
}

/* ── Proxy Output List & Quick Fields ────────────────────────── */

.proxy-lines-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 2px;
}

.proxy-line-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.83rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease), transform 120ms var(--ease);
}

.proxy-line-item:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.proxy-line-item:active {
  transform: scale(0.992);
}

.proxy-line-item.is-copied {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.proxy-line-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.proxy-line-copy {
  flex-shrink: 0;
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--text-muted);
}

.proxy-line-item.is-copied .proxy-line-copy {
  color: var(--ok);
}

.quick-fields-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.quick-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quick-field-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: all 150ms var(--ease);
}

.quick-field-btn:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.quick-field-key {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quick-field-val {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Analytics Chart & Breakdown ─────────────────────────────── */

.analytics-chart-wrap {
  position: relative;
  width: 100%;
  padding-top: 6px;
}

.chart-svg {
  width: 100%;
  height: 240px;
  display: block;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-dasharray: 3 4;
}

.chart-axis-text {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--sans);
}

.chart-bar-res {
  fill: var(--accent);
  transition: opacity 140ms var(--ease);
}

.chart-bar-isp {
  fill: #8b5cf6;
  transition: opacity 140ms var(--ease);
}

.chart-bar-clean {
  fill: #f59e0b;
  transition: opacity 140ms var(--ease);
}

.chart-bar-mob {
  fill: var(--ok);
  transition: opacity 140ms var(--ease);
}

.chart-bar-hit {
  fill: transparent;
  cursor: pointer;
}

.chart-bar-group:hover .chart-bar-res,
.chart-bar-group:hover .chart-bar-isp,
.chart-bar-group:hover .chart-bar-clean,
.chart-bar-group:hover .chart-bar-mob {
  opacity: 0.82;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-swatch.res { background: var(--accent); }
.legend-swatch.isp { background: #8b5cf6; }
.legend-swatch.clean { background: #f59e0b; }
.legend-swatch.mob { background: var(--ok); }

.bundle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .bundle-grid { grid-template-columns: 1fr; }
}

.bundle-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.bundle-card:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.bundle-card.active {
  border-color: var(--accent);
  background: var(--accent-soft, rgba(59, 130, 246, 0.12));
}

.bundle-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.bundle-card-price {
  font-size: 1.15rem;
  font-weight: 700;
}

.chart-tooltip {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.pool-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.pool-stat-card {
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}

/* ── Code Snippets & Banners ─────────────────────────────────── */

.info-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.28);
  margin-bottom: 18px;
}

.code-block {
  margin: 12px 0 0;
  padding: 16px;
  border-radius: var(--r-lg);
  background: #090e1a;
  color: #e2e8f0;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

/* ── Tables ──────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.91rem;
}

th,
td {
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-weight: 650;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr {
  transition: background-color 140ms var(--ease);
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ── Auth Pages (Login / Register) ───────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}

.auth-theme-corner {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 30;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin: 14px 0 6px;
  font-size: 1.48rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.login-card .muted {
  margin: 0 0 20px;
}

/* ── Alerts, Toasts, Modals ──────────────────────────────────── */

.alert {
  padding: 12px 15px;
  border-radius: var(--r-md);
  margin-bottom: 14px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 550;
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.35);
}

.alert-err {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

.alert-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.35);
}

.check-result {
  padding: 12px 14px;
  border-radius: var(--r-md);
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.check-result.is-ok {
  background: var(--ok-bg);
  border-color: rgba(52, 211, 153, 0.38);
}

.check-result.is-warn {
  background: var(--warn-bg);
  border-color: rgba(251, 191, 36, 0.38);
}

.check-result.is-err {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.38);
}

.check-result-title {
  font-weight: 700;
}

.check-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--text-secondary);
}

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toastIn 200ms var(--ease);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}

.toast-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex-shrink: 0;
}

.toast-ok .toast-dot { background: var(--ok); }
.toast-warn .toast-dot { background: var(--warn); }
.toast-err .toast-dot { background: var(--danger); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
}

.modal {
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-2xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: popIn 180ms var(--ease);
}

/* ── Responsive Breakpoints ──────────────────────────────────── */

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .sticky-panel {
    position: static;
  }
  .preset-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 16px 14px 40px;
  }
  .card {
    padding: 15px 14px;
    border-radius: var(--r-lg);
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .btn-row > .btn {
    flex: 1 1 auto;
  }
  .login-card {
    padding: 24px 20px;
    border-radius: var(--r-xl);
  }
  .country-popover {
    min-width: 0;
    width: 100%;
  }
  .nav-btn {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-btn {
    width: auto;
    flex: 1 1 auto;
    justify-content: center;
  }
  .two-col-grid {
    grid-template-columns: 1fr;
  }
  .quick-fields-grid {
    grid-template-columns: 1fr;
  }
}

.w-full { width: 100%; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head-row h2 { margin-bottom: 0; }

.topup-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
  align-items: start;
}

.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topup-gb-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.topup-price-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.topup-price-row,
.topup-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topup-total-val {
  font-size: 1.35rem;
  color: var(--text-primary);
}

.currency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.currency-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.12s ease, background 0.16s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.currency-card:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.currency-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.currency-card.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.currency-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.92rem;
}

.currency-card-sub {
  font-size: 0.82rem;
}

.invoice-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: start;
}

.invoice-qr-wrap {
  background: #fff;
  padding: 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.invoice-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.invoice-warn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.4;
}

.invoice-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.invoice-copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.invoice-amount {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  word-break: break-all;
}

.invoice-addr {
  font-size: 0.84rem;
  word-break: break-all;
}

.invoice-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .invoice-box {
    grid-template-columns: 1fr;
  }
  .invoice-qr-wrap {
    justify-self: center;
  }
}

/* ── Bilingual RU/EN Visibility & Auth-State Visibility ────────── */
html[data-lang="en"] .lang-ru { display: none; }
html[data-lang="ru"] .lang-en,
html:not([data-lang]) .lang-en { display: none; }

body[data-auth="1"] .auth-guest-only { display: none; }
body[data-auth="0"] .auth-user-only,
body:not([data-auth]) .auth-user-only { display: none; }

.sidebar-balance-val,
.topup-total-val,
.invoice-amount,
#inv-countdown,
td.mono {
  font-variant-numeric: tabular-nums;
}

/* ── Compact 2-Column Generator Workspace ──────────────────────── */
.gen-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(340px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.gen-workspace > .card {
  margin-bottom: 0;
}

.compact-details {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  background: var(--surface-2);
}

.compact-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.compact-details[open] summary {
  margin-bottom: 10px;
}

@media (max-width: 1040px) {
  .gen-workspace {
    grid-template-columns: 1fr;
  }
}

/* ── Admin Account Sub-tabs & Quick Bar ────────────────────────── */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.subtab-btn {
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease), color 140ms var(--ease);
}

.subtab-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Shared Navigation Links & Prose Docs ──────────────────────── */
a.nav-btn,
a.brand-mark {
  text-decoration: none;
  color: inherit;
}

.doc-prose p {
  margin: 0 0 12px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.doc-prose ul {
  margin: 0 0 14px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.doc-prose h2,
.doc-prose h3 {
  margin-top: 16px;
}

.doc-prose > h2:first-child,
.doc-prose > h3:first-child {
  margin-top: 0;
}

.doc-prose a {
  color: var(--accent);
  text-decoration: none;
}

.doc-prose a:hover {
  text-decoration: underline;
}

.doc-prose code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.85em;
}

.auth-footer-links a,
.sidebar-legal-links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.auth-footer-links a:hover,
.sidebar-legal-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.auth-footer-links {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.82rem;
}

.sidebar-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  margin-top: 8px;
  color: var(--text-muted);
}

.terms-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.terms-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
