:root {
  /* Brand */
  --brand-rgb: 0, 232, 245;
  --brand: #00e8f5;
  --brand-dark: #00b8c9;
  --brand-light: #5ef4ff;
  --brand-accent: #7c5cff;
  --brand-soft: rgba(var(--brand-rgb), 0.1);

  /* Surfaces */
  --sidebar: #080c14;
  --sidebar-hover: #101826;
  --sidebar-active: rgba(var(--brand-rgb), 0.14);
  --bg: #0b1019;
  --topbar-bg: #0f1623;
  --surface: #121c2b;
  --panel: var(--surface);
  --text: #eef3f8;
  --muted: #93a3ba;
  --border: #1a2738;
  --panel-border: rgba(var(--brand-rgb), 0.18);
  --line: #00e8f5;

  /* Semantic status colors */
  --success-rgb: 74, 222, 128;
  --warning-rgb: 251, 191, 36;
  --danger-rgb: 248, 113, 113;
  --success: rgb(var(--success-rgb));
  --warning: rgb(var(--warning-rgb));
  --danger: rgb(var(--danger-rgb));
  --danger-strong: #e5484d;
  --red: var(--danger);

  /* Elevation (softened) */
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.38);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --glow: 0 0 14px rgba(var(--brand-rgb), 0.08);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Spacing scale */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;

  /* Type scale */
  --fs-xs: 0.75rem;
  --fs-sm: 0.85rem;
  --fs-md: 0.95rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.55rem;

  /* Controls / sizing */
  --control-h: 2.75rem;
  --root-fs: 100%;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { font-size: var(--root-fs); }
body {
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  background: linear-gradient(180deg, #0a0f18 0%, #080c14 100%);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(var(--brand-rgb), 0.08);
}
.sidebar-brand {
  padding: 1.1rem 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand a { display: block; line-height: 0; }
.sidebar-logo-full {
  width: 100%;
  max-width: 168px;
  height: auto;
  display: block;
}
.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  display: none;
}
.sidebar-tagline {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.62);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sidebar-brand-text { display: none; }
.sidebar-logo { display: none; }
.sidebar nav, .sidebar-nav { flex: 1; padding: 0.75rem 0; display: flex; flex-direction: column; }
.nav-section-title {
  padding: 0.35rem 1.35rem 0.55rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.38);
}
.sidebar-profile {
  margin-top: auto;
  padding: 0.85rem 1rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
}
.sidebar-profile-card strong { font-size: 0.88rem; }
.sidebar-profile-card .sub { font-size: 0.75rem; color: rgba(255,255,255,0.55); }
.sidebar-profile-card .btn { width: 100%; margin-top: 0.35rem; }
.sidebar-profile-fallback {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  text-align: center;
}

.subnav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.subnav a {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.subnav a:hover { color: var(--brand-light); background: var(--brand-soft); }
.subnav a.active { color: var(--brand); background: var(--brand-soft); }

.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-rail { order: -1; }
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) { .metrics-strip { grid-template-columns: repeat(2, 1fr); } }
.metric-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow);
}
.metric-pill .k {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.metric-pill strong { font-size: 1.05rem; }

.balance-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) { .balance-row { grid-template-columns: 1fr; } }
.balance-hero { margin-bottom: 0; }
.balance-hero-inner {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1rem;
  align-items: end;
  padding: 1.1rem 1.2rem;
}
@media (max-width: 640px) { .balance-hero-inner { grid-template-columns: 1fr; } }
.balance-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.balance-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-light);
  line-height: 1.1;
  margin-bottom: 0.5rem;
}
.balance-side {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0.75rem;
}
.mini-balance { padding: 0.85rem 1rem; margin-bottom: 0; }
.mini-value { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.35rem; }
.sparkline { width: 100%; height: 64px; display: block; }

.dash-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 1100px) { .dash-cards-row { grid-template-columns: repeat(2, 1fr); } }
.dash-card {
  padding: 0.9rem 1rem;
  margin-bottom: 0;
  border-radius: 12px;
}
.dash-card.accent {
  background: rgba(var(--brand-rgb), 0.08);
  border-color: rgba(var(--brand-rgb), 0.35);
}
.dash-card-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.dash-card-value {
  font-size: 1.55rem;
  font-weight: 800;
  margin: 0.35rem 0;
}
.text-link {
  color: var(--brand);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}
.text-link:hover { text-decoration: underline; }
.text-link.light { color: #e6edf3; }

.dashboard-rail { position: sticky; top: 1rem; }
.rail-card { padding: 1rem; }
.rail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.rail-head strong { color: var(--text); font-size: 1rem; }
.rail-metric {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0.65rem 0 0.85rem;
  color: var(--brand-light);
}
.rail-metric span {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.btn-gradient {
  background: var(--brand);
  color: #07090d;
  border: none;
}
.btn-gradient:hover { background: var(--brand-light); }
.btn.block { display: block; width: 100%; text-align: center; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.82rem 1.25rem;
  color: #8fa0b8;
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar a.active {
  background: var(--sidebar-active);
  color: var(--brand-light);
  border-left-color: var(--brand);
  box-shadow: inset 0 0 20px rgba(var(--brand-rgb), 0.06);
}
.sidebar a .nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.95;
}
.sidebar a .nav-icon svg { width: 18px; height: 18px; display: block; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.progress-track {
  height: 6px;
  background: #0a1018;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.45rem 0 0.55rem;
  border: 1px solid var(--border);
}
.progress-track.light { background: rgba(0,0,0,0.2); border-color: rgba(255,255,255,0.15); }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  border-radius: 999px;
}

.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.topbar-end {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-shrink: 0;
}
.topbar-title { min-width: 140px; }
.topbar-title h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar-crumb {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.topbar .search-wrap { flex: 1; min-width: 180px; max-width: 320px; }
.topbar input[type="search"],
.topbar input[type="text"],
.topbar input[type="number"] {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}
.ref-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 260px;
}
.ref-bar label { font-size: 0.78rem; color: var(--muted); white-space: nowrap; font-weight: 600; text-transform: uppercase; }
.ref-bar input {
  flex: 1;
  min-width: 160px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  background: var(--bg);
  color: var(--text);
}
.ref-bar .btn-copy { flex-shrink: 0; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.65rem 0.35rem 0.35rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  max-width: min(280px, 42vw);
}
.user-chip .meta {
  min-width: 0;
  overflow: hidden;
  line-height: 1.25;
}
.user-chip .meta strong {
  display: block;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip .meta span {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .admin-id { width: 120px; }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.view-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.view-mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}
.view-mode-btn:hover { color: var(--text); background: var(--brand-soft); }
.view-mode-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
}
.view-mode-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(var(--brand-rgb), 0.35);
  background: rgba(var(--brand-rgb), 0.08);
  font-size: 0.85rem;
}
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle svg { width: 22px; height: 22px; display: block; }
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1100;
}
body.nav-open .nav-backdrop { display: block; }

.content { padding: 1.25rem 1.5rem 1rem; flex: 1; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-hint {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.panel-toolbar .struct-search,
.panel-toolbar input[type="search"] {
  height: var(--control-h);
  min-width: 160px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
}
.panel-toolbar .btn-sm {
  height: var(--control-h);
  padding: 0 0.85rem;
}
.panel-body.compact { padding: 0.85rem 1.15rem; }
.panel-body.flush { padding: 0; }
.panel-body.flush .data-table th:first-child,
.panel-body.flush .data-table td:first-child { padding-left: 1.25rem; }
.panel-body.flush .data-table th:last-child,
.panel-body.flush .data-table td:last-child { padding-right: 1.25rem; }

.app-footer {
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.app-footer a { color: var(--brand); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
}
.stat-card .icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  position: relative;
  flex-shrink: 0;
}
.stat-card .icon::after {
  content: "";
  width: 20px;
  height: 20px;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}
.stat-card .icon.icon-users::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M16 11c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 3-1.34 3-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5C15 14.17 10.33 13 8 13zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M16 11c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 3-1.34 3-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5C15 14.17 10.33 13 8 13zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z'/%3E%3C/svg%3E"); }
.stat-card .icon.icon-wallet::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M21 7H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2zm-9 3h4v2h-4v-2z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M21 7H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2zm-9 3h4v2h-4v-2z'/%3E%3C/svg%3E"); }
.stat-card .icon.icon-pool::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 3L2 12h3v8h14v-8h3L12 3zm0 3.84L17 12h-2v6H9v-6H7l5-5.16z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 3L2 12h3v8h14v-8h3L12 3zm0 3.84L17 12h-2v6H9v-6H7l5-5.16z'/%3E%3C/svg%3E"); }
.stat-card .icon.icon-out::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M16 12H4v-2h12V7l4 5-4 5v-3z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M16 12H4v-2h12V7l4 5-4 5v-3z'/%3E%3C/svg%3E"); }
.stat-card .icon.icon-in::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M8 12h12v2H8v3l-4-5 4-5v3z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M8 12h12v2H8v3l-4-5 4-5v3z'/%3E%3C/svg%3E"); }
.stat-card .icon.icon-user::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E"); }
.stat-card .icon.icon-table::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M3 3h8v8H3V3zm10 0h8v8h-8V3zM3 13h8v8H3v-8zm10 0h8v8h-8v-8z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M3 3h8v8H3V3zm10 0h8v8h-8V3zM3 13h8v8H3v-8zm10 0h8v8h-8v-8z'/%3E%3C/svg%3E"); }
.stat-card .label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .value { font-size: 1.35rem; font-weight: 700; color: var(--text); }

.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
  border: 1px solid var(--border);
}
.panel-header {
  background: linear-gradient(90deg, #0a1018, #0f131a);
  color: var(--text);
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--panel-border);
}
.panel-header > span:first-child {
  flex: 1 1 auto;
  min-width: 120px;
}
.panel-body { padding: 1rem 1.25rem; }

.sponsor-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.sponsor-card .label-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
  flex-shrink: 0;
  border: 2px solid rgba(var(--brand-rgb), 0.25);
}
.avatar.sm { width: 40px; height: 40px; font-size: 0.9rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.35rem; }

.user-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 1rem 1.15rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.user-header .meta h2 { margin: 0 0 0.25rem; font-size: 1.25rem; }
.user-header .meta .sub { color: var(--muted); font-size: 0.85rem; }
.team-badges { display: flex; gap: 1rem; margin-left: auto; }
.team-badge {
  text-align: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #07090d;
  border-radius: 50%;
  width: 72px; height: 72px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 0.72rem;
  line-height: 1.2;
  box-shadow: var(--shadow-sm);
}
.team-badge strong { font-size: 1.1rem; display: block; }

.structure-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.struct-search {
  height: var(--control-h);
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  min-width: 180px;
  font-size: 0.82rem;
}
.struct-search::placeholder { color: var(--muted); }
.depth-label {
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
}
.depth-label select {
  height: var(--control-h);
  padding: 0 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  background: var(--bg);
  color: var(--text);
}

.view-toggle { display: flex; gap: 0.25rem; }
.view-toggle button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  height: var(--control-h);
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.view-toggle button.active { background: var(--brand); color: #07090d; border-color: var(--brand); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: #0a1018;
  color: var(--brand);
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--panel-border);
}
.data-table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(var(--brand-rgb), 0.04); }
.data-table a { color: var(--brand); text-decoration: none; font-weight: 600; }
.data-table a:hover { text-decoration: underline; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.user-cell-meta { line-height: 1.3; }
.user-cell-meta strong { display: block; font-size: 0.9rem; }
.user-cell-meta span { color: var(--muted); font-size: 0.78rem; }
.money { font-weight: 700; color: var(--brand-light); }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-left: 0.35rem; }

.tables-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem 1rem;
}
.table-slot-bar {
  display: grid;
  grid-template-columns: 2rem 1fr 2rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
}
.t-label { color: var(--muted); font-weight: 700; }
.t-track {
  height: 8px;
  background: #0a1018;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.t-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  border-radius: 999px;
}
.t-count { text-align: right; font-weight: 600; }

.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}
.empty-state.sm { padding: 1rem; font-size: 0.82rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-panel {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--brand-soft); color: var(--brand); }
.modal-body { padding: 1rem 1.15rem 1.15rem; }
.modal-user-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.modal-balance { font-size: 1.5rem; font-weight: 700; color: var(--brand-light); }
.modal-sub { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.modal-section-title {
  margin: 1rem 0 0.65rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.modal-tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.5rem;
}
.modal-table-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  text-align: center;
  font-size: 0.72rem;
}
.modal-table-chip.active { border-color: var(--brand); background: var(--brand-soft); }
.modal-table-chip strong { display: block; margin-bottom: 0.2rem; }
.tx-list { display: flex; flex-direction: column; gap: 0.35rem; }
.tx-row {
  display: grid;
  grid-template-columns: 8.5rem 5rem 1fr;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  background: var(--bg);
}
.tx-date { color: var(--muted); }
.tx-amount { font-weight: 700; color: var(--brand-light); }
.tx-comment { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lvl-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: #07090d;
  font-size: 0.7rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--brand);
  color: #07090d;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.15s, filter 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--brand-light); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--brand);
  color: var(--brand);
}
.btn-outline:hover { background: var(--brand-soft); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
.btn-danger { background: var(--danger); color: #1a0606; }
.btn-danger:hover { background: var(--danger-strong); color: #fff; }
.btn:disabled,
.btn[disabled],
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.25);
  pointer-events: none;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  flex-wrap: wrap;
}
.pagination .btn { min-width: 5.5rem; }
.pagination .info { color: var(--muted); font-size: 0.85rem; }

/* Radial tree (Syndicate-style) */
.structure-body { padding: 0; }
.radial-tree-wrap {
  position: relative;
  min-height: 620px;
  background: radial-gradient(circle at center, rgba(var(--brand-rgb), 0.04) 0%, var(--bg) 65%);
}
.tree-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, 0.55);
  color: var(--text);
  font-size: 0.95rem;
}
.tree-loading.hidden { display: none; }
.radial-node.depth-2 .node-avatar { width: 42px; height: 42px; font-size: 0.78rem; }
.radial-node.depth-3 .node-avatar,
.radial-node.depth-4 .node-avatar,
.radial-node.depth-5 .node-avatar,
.radial-node.depth-6 .node-avatar,
.radial-node.depth-7 .node-avatar,
.radial-node.depth-8 .node-avatar,
.radial-node.depth-9 .node-avatar,
.radial-node.depth-10 .node-avatar,
.radial-node.depth-11 .node-avatar,
.radial-node.depth-12 .node-avatar,
.radial-node.depth-13 .node-avatar,
.radial-node.depth-14 .node-avatar,
.radial-node.depth-15 .node-avatar { width: 36px; height: 36px; font-size: 0.68rem; border-width: 2px; }
.radial-node.depth-2 .node-name { max-width: 76px; font-size: 0.68rem; }
.radial-node.depth-3 .node-name,
.radial-node.depth-4 .node-name,
.radial-node.depth-5 .node-name,
.radial-node.depth-6 .node-name,
.radial-node.depth-7 .node-name,
.radial-node.depth-8 .node-name,
.radial-node.depth-9 .node-name,
.radial-node.depth-10 .node-name,
.radial-node.depth-11 .node-name,
.radial-node.depth-12 .node-name,
.radial-node.depth-13 .node-name,
.radial-node.depth-14 .node-name,
.radial-node.depth-15 .node-name { max-width: 62px; font-size: 0.62rem; }
.radial-node.empty-slot .node-avatar.empty {
  background: rgba(255, 255, 255, 0.04);
  border: 2px dashed rgba(var(--brand-rgb), 0.35);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}
.radial-tree-viewport {
  width: 100%;
  height: 620px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  position: relative;
  user-select: none;
}
.tree-hint {
  position: absolute;
  left: 0.75rem;
  bottom: 0.5rem;
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  pointer-events: none;
  z-index: 5;
}
.radial-tree-viewport.dragging { cursor: grabbing; }
.radial-tree-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  will-change: transform;
  backface-visibility: hidden;
}
.radial-tree-svg {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}
.radial-tree-nodes {
  position: absolute;
  left: 0;
  top: 0;
}
.radial-node {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  cursor: pointer;
  z-index: 2;
}
.radial-node .node-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(26, 40, 48, 0.12);
  transition: transform 0.15s, box-shadow 0.15s;
}
.radial-node.root .node-avatar {
  width: 80px;
  height: 80px;
  font-size: 1.2rem;
  border-color: var(--brand);
  box-shadow: 0 0 24px rgba(var(--brand-rgb), 0.35);
}
.radial-node:hover .node-avatar,
.radial-node.highlight .node-avatar {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(var(--brand-rgb), 0.45);
}
.radial-node .node-name {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.radial-node.root .node-name { max-width: 120px; font-size: 0.82rem; }
.radial-node .node-expand {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: 2px solid #fff;
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
}
.radial-node .node-expand.collapsed { background: var(--red); }
.radial-node .node-extra {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--brand-accent);
  color: #07090d;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
}
.radial-slot .node-slot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px dashed rgba(var(--brand-rgb), 0.45);
  color: rgba(var(--brand-rgb), 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin: 0 auto;
}
.radial-tree-controls {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 10;
}
.radial-tree-controls button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.radial-tree-controls button:hover { background: var(--brand-soft); border-color: var(--brand); }
.radial-tooltip {
  position: absolute;
  z-index: 20;
  background: #07090d;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  border: 1px solid var(--panel-border);
  max-width: 240px;
  line-height: 1.45;
}
.radial-tooltip strong { display: block; margin-bottom: 0.25rem; font-size: 0.92rem; }
.radial-tooltip .tip-row { color: #b0bec5; }
.tree-ring { fill: none; stroke: #1e2633; stroke-width: 1; stroke-dasharray: 6 6; opacity: 0.9; }
.tree-ring-label {
  fill: var(--brand-light, #6eb5ff);
  font-size: 11px;
  font-weight: 700;
  font-family: system-ui, sans-serif;
  pointer-events: none;
}
.tree-ring-count {
  fill: var(--muted, #8892a4);
  font-size: 10px;
  font-family: system-ui, sans-serif;
  pointer-events: none;
}
.tree-ring-overflow {
  fill: var(--warn, #e8a838);
  font-size: 9px;
  font-family: system-ui, sans-serif;
  pointer-events: none;
}
.radial-node .node-lvl {
  font-size: 0.58rem;
  color: var(--brand-light, #6eb5ff);
  font-weight: 700;
  margin-top: 2px;
  pointer-events: none;
}
.radial-node .node-depth {
  font-size: 0.56rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: 1px;
  pointer-events: none;
}
.tree-sector { stroke: rgba(var(--brand-rgb), 0.28); stroke-width: 1.5; }
.tree-line { stroke: var(--line); stroke-width: 2; fill: none; opacity: 0.85; }
.tree-line-empty { stroke: rgba(var(--brand-rgb), 0.35); stroke-dasharray: 5 5; opacity: 0.5; }

.matrix-root-slots {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.matrix-root-slots-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.matrix-root-slots-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}
.matrix-slot {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  background: var(--surface);
  text-align: left;
}
.matrix-slot.filled {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.matrix-slot.filled:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.matrix-slot.empty {
  border-style: dashed;
  opacity: 0.75;
}
.matrix-slot .slot-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 0.2rem;
}
.matrix-slot .slot-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
}
.matrix-slot .slot-id {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}
.tree-more-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-style: italic;
  white-space: nowrap;
}

.hidden { display: none !important; }

/* Demo page */
.demo-hero {
  background: rgba(var(--brand-rgb), 0.06);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.demo-hero-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.demo-hero-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-light);
  line-height: 1.1;
}
.demo-hero-sub {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.demo-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}
.demo-progress-track {
  flex: 1;
  height: 8px;
  background: #0a1018;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.demo-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  transition: width 0.35s ease;
}
.demo-progress-text { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.demo-layout {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 1100px) { .demo-layout { grid-template-columns: 1fr; } }

.demo-sidebar-panel,
.demo-ledger-panel { margin-bottom: 0; }
.demo-sidebar-panel .panel-body,
.demo-ledger-panel .panel-body { max-height: 62vh; overflow: auto; }

.demo-sidebar { padding: 0; }
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-left: 3px solid transparent;
}
.step-item .step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}
.step-item.done { color: var(--brand-dark); border-left-color: rgba(var(--brand-rgb), 0.35); }
.step-item.done .step-num { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.step-item.current { background: var(--brand-soft); color: var(--text); border-left-color: var(--brand); }
.step-item.current .step-num { background: var(--brand); color: #07090d; border-color: var(--brand); }

.demo-main .panel { margin-bottom: 0.85rem; }
.table-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.55rem;
}
@media (max-width: 640px) { .table-grid { grid-template-columns: repeat(3, 1fr); } }

.table-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.5rem;
  text-align: center;
  font-size: 0.78rem;
  transition: border-color 0.15s, background 0.15s;
}
.table-cell.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 16px rgba(var(--brand-rgb), 0.12);
}
.table-cell-no { font-weight: 700; margin-bottom: 0.35rem; }
.table-cell-status { margin-top: 0.35rem; color: var(--muted); font-size: 0.7rem; }
.slot-dots { display: flex; justify-content: center; gap: 0.3rem; }
.slot-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a2020;
  border: 1px solid #5a3030;
}
.slot-dot.on {
  background: var(--brand);
  border-color: var(--brand-light);
  box-shadow: 0 0 6px rgba(var(--brand-rgb), 0.45);
}

.demo-controls-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.demo-status-line { margin-top: 0.75rem; color: var(--muted); font-size: 0.85rem; }

.demo-ledger { padding: 0; }
.event-item {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.event-item:last-child { border-bottom: none; }
.event-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.event-body { display: flex; flex-direction: column; gap: 0.15rem; }
.event-body strong { color: var(--brand-light); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.event-body span { color: var(--text); }

.input-select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}
select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(284px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 1200;
    box-shadow: var(--shadow);
    overflow-y: auto;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar a { padding: 0.95rem 1.25rem; font-size: 1rem; }
  .ref-bar label { display: none; }
  .topbar-title { flex: 1 1 auto; min-width: 120px; }
  .topbar .search-wrap { order: 10; flex: 1 1 100%; max-width: none; }
  .ref-bar { order: 11; flex: 1 1 100%; min-width: 0; }
  .topbar-end {
    order: 12;
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .user-chip { max-width: none; flex: 1; }
}

/* ── Shared page chrome ── */
.page-intro {
  margin: -0.15rem 0 1.15rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}
.page-intro p { margin: 0; line-height: 1.5; }
.page-header-compact {
  margin-bottom: 1rem;
}
.page-header-compact .page-title {
  font-size: 1.35rem;
  margin-bottom: 0;
}
.page-header-compact .page-subtitle {
  margin-top: 0.3rem;
}
.nav-group + .nav-group { margin-top: 0.35rem; }
.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pill-cyan { background: var(--brand-soft); color: var(--brand-light); border: 1px solid rgba(var(--brand-rgb), 0.25); }
.pill-muted { background: rgba(255,255,255,0.06); color: var(--muted); }
.text-pos { color: var(--success); font-weight: 600; }
.text-neg { color: var(--danger); font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; font-size: 0.82rem; }
.muted { color: var(--muted); }
.btn-block { width: 100%; justify-content: center; }
.table-scroll { overflow-x: auto; }
.avatar.xl {
  width: 72px;
  height: 72px;
  font-size: 1.4rem;
  border: 2px solid rgba(var(--brand-rgb), 0.35);
  box-shadow: 0 0 24px rgba(var(--brand-rgb), 0.2);
}

/* ── Finances ── */
.finance-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) { .finance-layout { grid-template-columns: 1fr; } }
.finance-balance-panel {
  padding: 1.5rem 1.75rem;
  background: rgba(var(--brand-rgb), 0.06);
  border-color: rgba(var(--brand-rgb), 0.2);
}
.finance-hero .finance-label { color: var(--muted); font-size: 0.85rem; }
.finance-amount {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0.35rem 0;
  color: var(--brand-light);
}
.finance-sub { color: var(--muted); font-size: 0.8rem; }
.finance-actions { display: flex; gap: 0.65rem; margin-top: 1.25rem; flex-wrap: wrap; }
.finance-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.finance-stats-grid .stat-card { margin: 0; }

/* ── Packages ── */
.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.pkg-card {
  position: relative;
  padding: 1.35rem 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.pkg-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.pkg-glow {
  position: absolute;
  top: -40%;
  right: -30%;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.35;
  pointer-events: none;
}
.pkg-cyan .pkg-glow { background: var(--brand); }
.pkg-purple .pkg-glow { background: #a855f7; }
.pkg-green .pkg-glow { background: #22c55e; }
.pkg-gold .pkg-glow { background: #eab308; }
.pkg-white .pkg-glow { background: #e2e8f0; }
.pkg-cyan { border-color: rgba(var(--brand-rgb), 0.25); }
.pkg-purple { border-color: rgba(168, 85, 247, 0.3); }
.pkg-green { border-color: rgba(34, 197, 94, 0.3); }
.pkg-gold { border-color: rgba(234, 179, 8, 0.3); }
.pkg-white { border-color: rgba(226, 232, 240, 0.2); }
.pkg-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand-light);
  margin-bottom: 0.5rem;
}
.pkg-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.pkg-price { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.pkg-desc { color: var(--muted); font-size: 0.78rem; line-height: 1.45; margin: 0 0 0.85rem; min-height: 2.5em; }
.pkg-progress {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.pkg-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  border-radius: 4px;
}
.pkg-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.pkg-tag { color: var(--brand-light); }
.pkg-card .btn { margin-top: 0.25rem; }
.tables-pkg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
@media (max-width: 640px) { .tables-pkg-grid { grid-template-columns: repeat(3, 1fr); } }
.table-pkg-cell {
  text-align: center;
  padding: 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.table-pkg-cell.has-slots { border-color: rgba(var(--brand-rgb), 0.3); background: var(--brand-soft); }
.table-pkg-cell .t-no { display: block; font-weight: 700; font-size: 0.8rem; margin-bottom: 0.35rem; }

/* ── HRPT Statuses ── */
.status-hero { margin-bottom: 1rem; }
.status-hero-title { margin: 0 0 0.5rem; font-size: 1.1rem; }
.status-hero-body { display: flex; flex-direction: column; gap: 1rem; }
.status-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.status-hero-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.status-hero-tier {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0.25rem 0;
}
.status-hero-wallet { margin: 0; font-size: 0.85rem; }
.status-hero-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.status-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.status-metrics .label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.status-metrics strong { font-size: 1.05rem; }
.status-progress {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  overflow: hidden;
}
.status-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  border-radius: 6px;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.status-card {
  position: relative;
  padding: 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}
.status-card.is-active {
  border-color: rgba(var(--brand-rgb), 0.55);
  box-shadow: 0 0 0 1px rgba(var(--brand-rgb), 0.25);
}
.status-card.is-reached { opacity: 0.92; }
.status-glow {
  position: absolute;
  top: -40%;
  right: -30%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  filter: blur(36px);
  opacity: 0.3;
  pointer-events: none;
}
.status-cyan .status-glow { background: var(--brand); }
.status-purple .status-glow { background: #a855f7; }
.status-green .status-glow { background: #22c55e; }
.status-gold .status-glow { background: #eab308; }
.status-cyan { border-color: rgba(var(--brand-rgb), 0.25); }
.status-purple { border-color: rgba(168, 85, 247, 0.3); }
.status-green { border-color: rgba(34, 197, 94, 0.3); }
.status-gold { border-color: rgba(234, 179, 8, 0.3); }
.status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand-light);
  margin-bottom: 0.35rem;
}
.status-min {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.status-benefits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.status-benefits li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.status-benefits strong {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}
.status-disclaimer {
  font-size: 0.78rem;
  line-height: 1.5;
  max-width: 52rem;
}

/* ── Profile ── */
.profile-panel {
  padding: 1.5rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.profile-panel .empty-state { padding: 2rem 1rem; }
.identity-links .profile-form { max-width: none; }
.identity-links .btn-sm { align-self: flex-end; margin-top: 0.35rem; }
.profile-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.profile-hero h2 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.profile-hero p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.profile-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
  max-width: 720px;
}
@media (max-width: 640px) { .profile-form { grid-template-columns: 1fr; } }
.profile-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.profile-form input {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
.form-hint {
  grid-column: 1 / -1;
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Alerts ── */
.alerts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.alert-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: start;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  transition: border-color 0.15s;
}
.alert-card:hover { border-color: rgba(var(--brand-rgb), 0.2); }
.alert-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 0.35rem;
  box-shadow: 0 0 10px currentColor;
}
.alert-success .alert-icon { background: var(--success); color: var(--success); }
.alert-info .alert-icon { background: var(--brand); color: var(--brand); }
.alert-warn .alert-icon { background: var(--warning); color: var(--warning); }
.alert-body strong { display: block; margin-bottom: 0.25rem; }
.alert-body p { margin: 0 0 0.35rem; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.alert-body time { font-size: 0.75rem; color: var(--muted); opacity: 0.8; }
.alert-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  line-height: 1;
}
.alert-dismiss:hover { color: var(--text); }

/* ── News ── */
.news-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) { .news-grid { grid-template-columns: 1fr; } }
.news-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3);
}
.news-card.featured {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
}
@media (max-width: 900px) { .news-card.featured { grid-template-columns: 1fr; } }
.news-visual {
  min-height: 140px;
  background: linear-gradient(135deg, rgba(var(--brand-rgb), 0.1), rgba(124, 92, 255, 0.18));
}
.news-card.featured .news-visual { min-height: 200px; }
.news-body { padding: 1.15rem 1.25rem; }
.news-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-light);
}
.news-body h3 { margin: 0.5rem 0 0.4rem; font-size: 1.05rem; line-height: 1.35; }
.news-body p { margin: 0 0 0.65rem; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.news-body time { font-size: 0.78rem; color: var(--muted); }

/* ── Training ── */
.page-training .training-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.page-training .training-intro p { margin: 0; }
.training-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.training-panel {
  margin-bottom: 0.75rem;
}
.training-embed {
  position: relative;
  min-height: min(72vh, 900px);
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0a0f1a;
}
.training-embed iframe {
  display: block;
  width: 100%;
  height: min(72vh, 900px);
  border: 0;
  background: #0a0f1a;
}
.training-workspace { margin-bottom: 0.75rem; }
.training-sync-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(10, 15, 26, 0.88);
  backdrop-filter: blur(4px);
}
.training-sync-card {
  max-width: 22rem;
  padding: 1.5rem;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.training-sync-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.training-sync-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.training-gate {
  padding: clamp(1.5rem, 4vw, 2.25rem);
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.training-gate-inner {
  max-width: 32rem;
  margin: 0 auto;
}
.training-gate-icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: rgba(var(--brand-rgb), 0.12);
  border: 1px solid rgba(var(--brand-rgb), 0.22);
}
.training-gate h2 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  line-height: 1.3;
}
.training-gate-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.98rem;
}
.training-gate-steps {
  text-align: left;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: rgba(var(--brand-rgb), 0.06);
  border: 1px solid rgba(var(--brand-rgb), 0.14);
  font-size: 0.92rem;
  line-height: 1.5;
}
.training-gate-steps li { margin: 0.35rem 0; }
.training-gate-telegram {
  margin: 1.25rem 0;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}
.training-gate-telegram p {
  margin: 0 0 0.75rem;
  font-weight: 600;
}
.training-open-btn {
  display: inline-flex;
  margin-top: 0.5rem;
  min-width: 14rem;
  justify-content: center;
}
.training-gate-alt {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}
.training-gate-alt .btn { margin-top: 0.65rem; }
.training-gate-note {
  margin-top: 1rem;
  color: var(--danger, #c0392b);
  font-size: 0.9rem;
}
.training-paywall-price {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  background: rgba(var(--brand-rgb), 0.08);
  border: 1px solid rgba(var(--brand-rgb), 0.18);
}
.training-paywall-price .label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.training-paywall-price .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}
.training-paywall-note {
  margin-top: 1rem;
  color: var(--danger, #c0392b);
}
.training-hint {
  font-size: 0.78rem;
  line-height: 1.45;
  max-width: 52rem;
  margin: 0;
}
.training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.training-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  transition: border-color 0.15s;
}
.training-card:hover { border-color: rgba(var(--brand-rgb), 0.25); }
.training-thumb {
  position: relative;
  border-radius: 8px;
  background: linear-gradient(145deg, #1a2744, #0d1528);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.play-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(var(--brand-rgb), 0.2);
  border: 2px solid var(--brand);
  position: relative;
}
.play-icon::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 10px;
  border: 7px solid transparent;
  border-left-color: var(--brand-light);
}
.training-body h3 { margin: 0 0 0.45rem; font-size: 0.95rem; line-height: 1.35; }
.training-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.training-progress {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}
.training-progress > div {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
}
.training-pct { font-size: 0.72rem; color: var(--muted); }

/* ── FAQ ── */
.faq-list { padding: 0.5rem 0; }
.faq-item {
  border-bottom: 1px solid var(--border);
}
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  color: var(--brand-light);
  font-size: 1.25rem;
  font-weight: 400;
  flex-shrink: 0;
}
.faq-item[open] summary::after { content: "−"; }
.faq-item summary:hover { color: var(--brand-light); }
.faq-answer {
  padding: 0 1.25rem 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ── Documents ── */
.doc-grid { display: flex; flex-direction: column; gap: 0.65rem; }
.doc-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  transition: border-color 0.15s, background 0.15s;
}
.doc-card:hover {
  border-color: rgba(var(--brand-rgb), 0.2);
  background: rgba(var(--brand-rgb), 0.03);
}
.doc-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--brand-soft);
  border: 1px solid rgba(var(--brand-rgb), 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--brand-light);
}
.doc-body h3 { margin: 0 0 0.2rem; font-size: 0.95rem; }
.doc-size { font-size: 0.78rem; color: var(--muted); }

/* ── Auth (login / register) ── */
.auth-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) { .auth-split { grid-template-columns: 1fr; } }
.auth-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(160deg, #0a1628 0%, #0d1f3c 50%, #0a1220 100%);
  overflow: hidden;
}
@media (max-width: 900px) { .auth-visual { min-height: 220px; padding: 1.5rem; } }
.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.28;
  pointer-events: none;
}
.auth-orb-1 {
  width: 320px;
  height: 320px;
  background: var(--brand);
  top: -80px;
  left: -60px;
}
.auth-orb-2 {
  width: 280px;
  height: 280px;
  background: #7c3aed;
  bottom: -60px;
  right: -40px;
}
.auth-visual-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 360px;
}
.auth-logo { max-width: 200px; margin-bottom: 1.5rem; }
.auth-visual h1 {
  font-size: 1.65rem;
  margin: 0 0 0.75rem;
  line-height: 1.3;
}
.auth-visual p { color: var(--muted); margin: 0; font-size: 0.95rem; line-height: 1.5; }
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-elevated, var(--bg));
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.75rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.auth-card h2 { margin: 0 0 0.35rem; font-size: 1.5rem; }
.auth-sub { color: var(--muted); font-size: 0.88rem; margin: 0 0 1.25rem; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.auth-form input {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}
.auth-message {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  background: rgba(var(--danger-rgb), 0.12);
  border: 1px solid rgba(var(--danger-rgb), 0.35);
  color: #fca5a5;
}
.auth-message.info {
  background: rgba(var(--brand-rgb), 0.08);
  border-color: rgba(var(--brand-rgb), 0.25);
  color: var(--brand-light);
}
.auth-footer-link {
  text-align: center;
  margin: 1.25rem 0 0.5rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.auth-footer-link a { color: var(--brand-light); }
.auth-bot-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}
.auth-bot-hint a { color: var(--brand-light); }

.auth-card-wide { max-width: 440px; }
.auth-method {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.auth-method:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.auth-method h3 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}
.auth-method .form-hint {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
.auth-method .form-hint a { color: var(--brand-light); }
.auth-email-form { margin: 0; }
.auth-field-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.auth-field-row {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
}
.auth-field-row input {
  flex: 1;
  min-width: 0;
  height: var(--control-h);
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.auth-field-row input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}
.auth-field-row .btn {
  flex-shrink: 0;
  height: var(--control-h);
  padding: 0 1rem;
}
@media (max-width: 480px) {
  .auth-field-row { flex-direction: column; }
  .auth-field-row .btn { width: 100%; }
}
.auth-form-inline { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.auth-form-inline label { flex: 1; min-width: 180px; margin-bottom: 0; }
.telegram-login-host {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.telegram-login-host:empty {
  padding: 0.75rem 1rem;
  border: 1px dashed rgba(var(--brand-rgb), 0.22);
  border-radius: var(--radius-sm);
  background: rgba(var(--brand-rgb), 0.04);
}
.telegram-login-host:empty::before {
  content: "Виджет Telegram загружается…";
  font-size: 0.82rem;
  color: var(--muted);
}
.telegram-login-host iframe { display: block; border: none; border-radius: var(--radius-sm); }

/* ── Commission tabs ── */
.commission-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.commission-tabs button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.commission-tabs button:hover:not(.active) {
  color: var(--brand-light);
  background: rgba(var(--brand-rgb), 0.06);
}
.commission-tabs button.active {
  background: var(--brand-soft);
  color: var(--brand-light);
  box-shadow: inset 0 0 0 1px rgba(var(--brand-rgb), 0.25);
}
.commission-panel { display: none; }
.commission-panel.active { display: block; }
.commission-panel .panel-toolbar { margin-bottom: 0.85rem; }
.commission-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
.alert-body .btn { margin-top: 0.75rem; }
.modal-body .profile-form .btn-block { margin-top: 0.35rem; }
.pill-warn { background: rgba(var(--warning-rgb), 0.15); color: var(--warning); border: 1px solid rgba(var(--warning-rgb), 0.35); }
.pill-ok { background: rgba(var(--success-rgb), 0.12); color: var(--success); border: 1px solid rgba(var(--success-rgb), 0.3); }
.pill-err { background: rgba(var(--danger-rgb), 0.12); color: var(--danger); border: 1px solid rgba(var(--danger-rgb), 0.3); }

/* ===== Accessibility & polish ===== */

/* Large-text mode: scales the whole rem-based UI */
html[data-text-size="lg"] { --root-fs: 118%; }

/* High-contrast mode */
html[data-contrast="high"] {
  --text: #ffffff;
  --muted: #c9d6e4;
  --bg: #05080d;
  --surface: #0d1626;
  --topbar-bg: #0a121f;
  --border: #44566c;
  --panel-border: rgba(var(--brand-rgb), 0.55);
  --brand-soft: rgba(var(--brand-rgb), 0.2);
}
html[data-contrast="high"] .panel,
html[data-contrast="high"] .stat-card,
html[data-contrast="high"] .metric-pill,
html[data-contrast="high"] .dash-card,
html[data-contrast="high"] .alert-card,
html[data-contrast="high"] .news-card,
html[data-contrast="high"] .training-card,
html[data-contrast="high"] .doc-card,
html[data-contrast="high"] .pkg-card,
html[data-contrast="high"] .auth-card { border-width: 2px; }
html[data-contrast="high"] .content a:not(.btn):not(.text-link),
html[data-contrast="high"] .auth-card a,
html[data-contrast="high"] .app-footer a { text-decoration: underline; }
html[data-contrast="high"] .panel-hint,
html[data-contrast="high"] .page-subtitle,
html[data-contrast="high"] .muted,
html[data-contrast="high"] .alert-body p { color: var(--muted); }

/* Visible focus for keyboard users */
:focus-visible {
  outline: 3px solid var(--brand-light);
  outline-offset: 2px;
  border-radius: 3px;
}
.btn:focus-visible,
.view-toggle button:focus-visible,
.commission-tabs button:focus-visible { outline-offset: 3px; }

/* Comfortable tap targets (>=44px) */
.btn { min-height: 2.75rem; }
.btn-sm { min-height: 2.25rem; }
.modal-close { width: 44px; height: 44px; font-size: 1.5rem; }
.radial-tree-controls button { width: 44px; height: 44px; font-size: 1.2rem; }
.subnav a { min-height: 2.25rem; display: inline-flex; align-items: center; }

/* Slightly larger smallest labels for readability */
.nav-section-title { font-size: 0.72rem; }
.radial-node.depth-3 .node-name,
.radial-node.depth-4 .node-name,
.radial-node.depth-5 .node-name,
.radial-node.depth-6 .node-name,
.radial-node.depth-7 .node-name,
.radial-node.depth-8 .node-name,
.radial-node.depth-9 .node-name,
.radial-node.depth-10 .node-name,
.radial-node.depth-11 .node-name,
.radial-node.depth-12 .node-name,
.radial-node.depth-13 .node-name,
.radial-node.depth-14 .node-name,
.radial-node.depth-15 .node-name { font-size: 0.66rem; }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .pkg-card:hover,
  .news-card:hover,
  .radial-node:hover .node-avatar { transform: none; }
}

/* A11y toggle controls in the topbar */
.a11y-controls { display: inline-flex; align-items: center; gap: 0.35rem; }
.a11y-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: var(--control-h);
  padding: 0 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.a11y-btn:hover { border-color: var(--brand); color: var(--brand-light); }
.a11y-btn[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-light);
}
.a11y-btn .a11y-ico { width: 18px; height: 18px; display: block; }

/* Toasts */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  max-width: 90vw;
  animation: toastIn 0.18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2rem 1rem;
  color: var(--muted);
}

/* Structure v2 — table ladder (Salebot «Мои столы») */
.table-ladder { margin-bottom: 1.25rem; }
.structure-v2-note {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.85rem;
}
.table-ladder-grid .ladder-row { cursor: pointer; transition: background 0.15s; }
.table-ladder-grid .ladder-row:hover,
.table-ladder-grid .ladder-row.selected { background: var(--brand-soft); }
.table-ladder-grid .ladder-slots-emoji { font-size: 1.1rem; letter-spacing: 0.15em; white-space: nowrap; }
.table-ladder-grid .ladder-slots-detail { font-size: 0.82rem; color: var(--muted); }
.table-ladder-grid .slot-filled { margin-right: 0.65rem; color: var(--text); }
.table-ladder-grid .slot-empty { margin-right: 0.65rem; opacity: 0.65; }
.ladder-status {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.ladder-status.status-active { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.ladder-status.status-graduated { background: rgba(148, 163, 184, 0.2); color: var(--muted); }
.ladder-status.status-never { background: rgba(148, 163, 184, 0.08); color: var(--muted); opacity: 0.7; }
.table-downline-wrap {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.table-downline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.structure-display-toggle { flex-shrink: 0; }

/* Radial: 15 столов — кольца не пересекаются */
.tables-radial-mode .tree-ring.ring-active {
  stroke: rgba(var(--brand-rgb), 0.55);
  stroke-width: 1.5;
}
.tables-radial-mode .tree-ring.ring-graduated {
  stroke: var(--muted);
  opacity: 0.45;
  stroke-dasharray: 4 8;
}
.tables-radial-mode .tree-ring.ring-never {
  stroke: #2a3544;
  opacity: 0.28;
  stroke-dasharray: 2 10;
}
.tree-ring-membership {
  fill: #22c55e;
  font-size: 10px;
}
.tree-ring-slots {
  fill: var(--muted);
  font-size: 11px;
  font-family: system-ui, sans-serif;
}
.tables-radial-mode .radial-node.empty-slot .node-avatar.empty {
  width: 40px;
  height: 40px;
  font-size: 0.72rem;
  background: transparent;
  border: 2px dashed var(--border);
  color: var(--muted);
  box-shadow: none;
}

.table-downline-head h3 { margin: 0; font-size: 1rem; }

@media (max-width: 640px) {
  /* Tables stay usable via horizontal scroll instead of crushing columns */
  .panel-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 520px; }

  /* Modals become bottom sheets */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  /* Larger touch areas on the structure tree */
  .radial-node .node-expand { width: 26px; height: 26px; font-size: 0.9rem; }

  /* Comfortable spacing for content */
  .content { padding: 1rem 1rem 0.85rem; }
  .page-title { font-size: 1.35rem; }
  .finance-amount { font-size: 2rem; }
  .balance-value { font-size: 1.65rem; }
  .training-embed,
  .training-embed iframe { min-height: 65vh; height: 65vh; }
  .page-training .training-intro { flex-direction: column; align-items: flex-start; }
}

