/* ==========================================================================
   N8R5K WORLD — Design System
   Created by N8R5K — Nathan Hladil
   Dark "financial terminal meets strategy game" UI. No external fonts/CDNs.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  --bg: #0a0e16;
  --bg-2: #0f1523;
  --panel: #121a2b;
  --panel-2: #182238;
  --panel-hover: #1c2740;
  --border: #1f2a40;
  --border-2: #2a3852;
  --text: #e6edf7;
  --text-2: #b7c2d4;
  --muted: #8b98ad;
  --gold: #f5b700;
  --gold-2: #ffd34d;
  --cyan: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --purple: #a78bfa;
  --orange: #f97316;
  --pink: #ec4899;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sidebar-w: 250px;
  --topbar-h: 60px;
  --bottom-nav-h: 60px;

  --gold-rgb: 245, 183, 0;
  --cyan-rgb: 56, 189, 248;
  --green-rgb: 34, 197, 94;
  --red-rgb: 239, 68, 68;
  --purple-rgb: 167, 139, 250;
  --orange-rgb: 249, 115, 22;
  --bg-rgb: 10, 14, 22;
  --bg2-rgb: 15, 21, 35;
  --panel-rgb: 18, 26, 43;

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: .15s;
  --t-med: .25s;
}

body[data-theme="midnight"] {
  --bg: #070b1a;
  --bg-2: #0b1230;
  --panel: #0f1738;
  --panel-2: #152049;
  --panel-hover: #1a2757;
  --border: #1c2a55;
  --border-2: #29396f;
  --text: #e8edff;
  --text-2: #b9c4ea;
  --muted: #8794c4;
  --bg-rgb: 7, 11, 26;
  --bg2-rgb: 11, 18, 48;
  --panel-rgb: 15, 23, 56;
}

body[data-theme="ember"] {
  --bg: #120c0a;
  --bg-2: #1a110e;
  --panel: #211613;
  --panel-2: #2b1d18;
  --panel-hover: #33231d;
  --border: #3a2822;
  --border-2: #4d352c;
  --text: #f6ece6;
  --text-2: #d8c6bb;
  --muted: #a89286;
  --gold: #ffb020;
  --gold-2: #ffcb5c;
  --cyan: #5cc8f5;
  --bg-rgb: 18, 12, 10;
  --bg2-rgb: 26, 17, 14;
  --panel-rgb: 33, 22, 19;
  --gold-rgb: 255, 176, 32;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 .5em;
  line-height: 1.25;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
h5 { font-size: 14px; }
h6 { font-size: 13px; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--cyan);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: #7dd3fc; }

img, svg, video, canvas { max-width: 100%; display: inline-block; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
small { font-size: 12px; }
strong, b { font-weight: 700; }
code, pre, .mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow: auto;
  font-size: 12.5px;
}
code { font-size: .92em; }
ul, ol { margin: 0 0 1em; padding-left: 20px; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }
::selection { background: rgba(var(--gold-rgb), .35); color: #fff; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a4a68; }

/* Focus */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* --------------------------------------------------------------------------
   3. Layout: app shell, sidebar, main, topbar, content
   -------------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  border-right: 1px solid var(--border);
  z-index: 200;
  transition: transform var(--t-med) var(--ease);
}
.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0 12px;
  overscroll-behavior: contain;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, .65);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 190;
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.sidebar-backdrop.show { opacity: 1; }

.main {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 150;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: rgba(var(--bg-rgb), .82);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.app-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}
.app-footer a { color: var(--text-2); }
.app-footer a:hover { color: var(--gold-2); }

/* Bare layout (auth / landing / about for guests) */
body.layout-bare {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(var(--gold-rgb), .09), transparent 60%),
    radial-gradient(800px 500px at 90% 110%, rgba(var(--cyan-rgb), .08), transparent 60%),
    var(--bg);
}
.bare-shell { min-height: 100vh; display: flex; flex-direction: column; }
.bare-content {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.bare-content.top { align-items: flex-start; }
.bare-content > .container { width: 100%; }
.container { width: 100%; max-width: 1100px; margin: 0 auto; }
.container.narrow { max-width: 760px; }

/* --------------------------------------------------------------------------
   4. Sidebar internals
   -------------------------------------------------------------------------- */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  flex: 0 0 auto;
}
.sidebar-brand:hover { color: var(--text); }
.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  filter: drop-shadow(0 4px 10px rgba(var(--gold-rgb), .35));
}
.brand-logo svg { width: 100%; height: 100%; display: block; }
.brand-text { min-width: 0; line-height: 1.15; }
.brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .08em;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.brand-creator {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.nav-section { padding: 8px 0 2px; }
.nav-label {
  padding: 8px 20px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 8px;
  padding: 9px 12px 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  min-height: 40px;
}
.nav-link:hover { background: var(--panel-hover); color: var(--text); }
.nav-link svg { width: 19px; height: 19px; flex: 0 0 19px; stroke: currentColor; opacity: .9; }
.nav-link .nav-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-link.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(var(--gold-rgb), .16), rgba(var(--gold-rgb), .02));
}
.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(var(--gold-rgb), .6);
}
.nav-link.active svg { color: var(--gold-2); opacity: 1; }
.nav-link.locked { opacity: .55; }
.nav-link.locked:hover { opacity: .8; }
.nav-lock {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px 1px 5px;
  flex: 0 0 auto;
}
.nav-lock svg { width: 11px; height: 11px; flex: 0 0 11px; }
.nav-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sidebar-player {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: rgba(var(--bg2-rgb), .8);
}
.sidebar-player-top { display: flex; align-items: center; gap: 10px; }
.sidebar-player-info { min-width: 0; flex: 1 1 auto; }
.sidebar-player-name {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-player-title { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-player-cash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-2);
}
.sidebar-player-cash .num { color: var(--gold-2); font-weight: 700; }
.sidebar-player-xp { margin-top: 8px; }
.sidebar-player-xp .xp-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* --------------------------------------------------------------------------
   5. Topbar internals: hamburger, money chips, icon buttons, dropdown
   -------------------------------------------------------------------------- */
.hamburger { display: none; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); border-color: var(--border); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
}

.money-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  white-space: nowrap;
}
.money-chip:hover { border-color: rgba(var(--gold-rgb), .5); background: var(--panel-hover); color: var(--text); }
.money-chip svg { width: 16px; height: 16px; color: var(--gold); }
.money-chip .chip-label { font-family: var(--font-sans); font-size: 10.5px; color: var(--muted); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.money-chip.bank svg { color: var(--cyan); }
.money-chip .flash-up { color: var(--green); }
.money-chip .flash-down { color: var(--red); }

.dropdown { position: relative; }
.dropdown-toggle { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; }
.dropdown-toggle .avatar { cursor: pointer; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(.98);
  transform-origin: top right;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), visibility var(--t-fast);
}
.dropdown-menu.left { right: auto; left: 0; transform-origin: top left; }
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dropdown-header { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown-header .dd-name { font-weight: 700; font-size: 14px; }
.dropdown-header .dd-sub { font-size: 12px; color: var(--muted); }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  min-height: 40px;
}
.dropdown-item:hover { background: var(--panel-hover); color: var(--text); }
.dropdown-item svg { width: 17px; height: 17px; opacity: .85; }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: rgba(var(--red-rgb), .12); }
.dropdown-divider { height: 1px; background: var(--border); margin: 5px 0; }

/* --------------------------------------------------------------------------
   6. Bottom nav (mobile)
   -------------------------------------------------------------------------- */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 180;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  grid-template-columns: repeat(5, 1fr);
  background: rgba(var(--bg2-rgb), .96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--gold-2); }
.bottom-nav-item.active svg { filter: drop-shadow(0 0 6px rgba(var(--gold-rgb), .6)); }
.bottom-nav-item:active { color: var(--text); }

/* --------------------------------------------------------------------------
   7. Cards, stats, grids
   -------------------------------------------------------------------------- */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset;
  transition: border-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  overflow: hidden;
}
.card:hover { border-color: var(--border-2); }
.card.glow {
  border-color: rgba(var(--gold-rgb), .45);
  box-shadow: 0 0 0 1px rgba(var(--gold-rgb), .15), 0 10px 40px rgba(var(--gold-rgb), .12);
}
.card.accent-cyan, .card.accent-green, .card.accent-red, .card.accent-purple, .card.accent-gold, .card.accent-orange { border-top-width: 3px; }
.card.accent-cyan { border-top-color: var(--cyan); }
.card.accent-green { border-top-color: var(--green); }
.card.accent-red { border-top-color: var(--red); }
.card.accent-purple { border-top-color: var(--purple); }
.card.accent-gold { border-top-color: var(--gold); }
.card.accent-orange { border-top-color: var(--orange); }
.card.interactive { cursor: pointer; }
.card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-header > div:first-child { min-width: 0; }
.card-title { font-size: 15px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 18px; height: 18px; color: var(--gold); }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 18px; }
.card-body.compact { padding: 12px 14px; }
.card-body.flush { padding: 0; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: rgba(var(--bg2-rgb), .5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}

.stat {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  transition: border-color var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.stat:hover { border-color: var(--border-2); }
.stat::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(160px 80px at 100% 0%, rgba(var(--gold-rgb), .08), transparent 70%);
  pointer-events: none;
}
.stat.cyan::after { background: radial-gradient(160px 80px at 100% 0%, rgba(var(--cyan-rgb), .1), transparent 70%); }
.stat.green::after { background: radial-gradient(160px 80px at 100% 0%, rgba(var(--green-rgb), .1), transparent 70%); }
.stat.red::after { background: radial-gradient(160px 80px at 100% 0%, rgba(var(--red-rgb), .1), transparent 70%); }
.stat.purple::after { background: radial-gradient(160px 80px at 100% 0%, rgba(var(--purple-rgb), .12), transparent 70%); }
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value.gold { color: var(--gold-2); }
.stat-value.sm { font-size: 19px; }
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--muted);
}
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta.up::before { content: "▲"; font-size: 9px; }
.stat-delta.down::before { content: "▼"; font-size: 9px; }
.stat-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--gold-rgb), .12);
  color: var(--gold);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat.cyan .stat-icon { background: rgba(var(--cyan-rgb), .14); color: var(--cyan); }
.stat.green .stat-icon { background: rgba(var(--green-rgb), .14); color: var(--green); }
.stat.red .stat-icon { background: rgba(var(--red-rgb), .14); color: var(--red); }
.stat.purple .stat-icon { background: rgba(var(--purple-rgb), .16); color: var(--purple); }
.stat-foot { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.gap-sm { gap: 10px; }
.grid.gap-lg { gap: 24px; }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.sidebar-right { grid-template-columns: minmax(0, 1fr) 340px; }
.grid.sidebar-left { grid-template-columns: 340px minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

/* --------------------------------------------------------------------------
   8. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 55%, #d99e00);
  color: #1a1200;
  box-shadow: 0 4px 14px rgba(var(--gold-rgb), .25), 0 1px 0 rgba(255, 255, 255, .25) inset;
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 6px 20px rgba(var(--gold-rgb), .35), 0 1px 0 rgba(255, 255, 255, .25) inset; color: #1a1200; }
.btn-primary.loading::after { border-color: rgba(0, 0, 0, .25); border-top-color: #1a1200; }

.btn-secondary {
  background: var(--panel-2);
  border-color: var(--border-2);
  color: var(--text);
}
.btn-secondary:hover { background: var(--panel-hover); border-color: #3a4a68; color: var(--text); }

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

.btn-danger { background: rgba(var(--red-rgb), .14); border-color: rgba(var(--red-rgb), .4); color: #fca5a5; }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }

.btn-success { background: rgba(var(--green-rgb), .14); border-color: rgba(var(--green-rgb), .4); color: #86efac; }
.btn-success:hover { background: var(--green); border-color: var(--green); color: #052e16; }

.btn-cyan { background: rgba(var(--cyan-rgb), .14); border-color: rgba(var(--cyan-rgb), .4); color: #7dd3fc; }
.btn-cyan:hover { background: var(--cyan); border-color: var(--cyan); color: #082f49; }

.btn-outline-gold { background: transparent; border-color: rgba(var(--gold-rgb), .5); color: var(--gold-2); }
.btn-outline-gold:hover { background: rgba(var(--gold-rgb), .12); border-color: var(--gold); color: var(--gold-2); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 7px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; border-radius: 10px; }
.btn-lg svg { width: 20px; height: 20px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-pill { border-radius: 999px; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn.active { background: rgba(var(--gold-rgb), .18); border-color: rgba(var(--gold-rgb), .5); color: var(--gold-2); position: relative; z-index: 1; }

/* --------------------------------------------------------------------------
   9. Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.card .table-wrap, .card-body.flush .table-wrap { border: 0; border-radius: 0; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.table th, .table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .015); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr { transition: background var(--t-fast) var(--ease); }
.table-hover tbody tr:hover td { background: var(--panel-hover); }
.table-compact th, .table-compact td { padding: 7px 10px; font-size: 12.5px; }
.table td.num, .table th.num, .table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table td.wrap { white-space: normal; }
.table .row-title { font-weight: 600; color: var(--text); }
.table .row-sub { font-size: 12px; color: var(--muted); }
.table tr.highlight td { background: rgba(var(--gold-rgb), .08); }
.table tr.clickable { cursor: pointer; }
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.pagination { display: inline-flex; gap: 4px; }
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}
.pagination a:hover { background: var(--panel-hover); color: var(--text); }
.pagination .active { background: rgba(var(--gold-rgb), .18); border-color: rgba(var(--gold-rgb), .5); color: var(--gold-2); }

/* --------------------------------------------------------------------------
   10. Badges, pills, chips, prices
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.5;
  background: var(--panel-2);
  color: var(--text-2);
  border: 1px solid var(--border-2);
  white-space: nowrap;
  vertical-align: middle;
}
.badge svg { width: 12px; height: 12px; }
.badge-up, .badge-green { background: rgba(var(--green-rgb), .14); color: #86efac; border-color: rgba(var(--green-rgb), .35); }
.badge-down, .badge-red { background: rgba(var(--red-rgb), .14); color: #fca5a5; border-color: rgba(var(--red-rgb), .35); }
.badge-neutral { background: var(--panel-2); color: var(--muted); border-color: var(--border-2); }
.badge-gold { background: rgba(var(--gold-rgb), .16); color: var(--gold-2); border-color: rgba(var(--gold-rgb), .4); }
.badge-cyan { background: rgba(var(--cyan-rgb), .14); color: #7dd3fc; border-color: rgba(var(--cyan-rgb), .35); }
.badge-purple { background: rgba(var(--purple-rgb), .16); color: #c4b5fd; border-color: rgba(var(--purple-rgb), .4); }
.badge-orange { background: rgba(var(--orange-rgb), .16); color: #fdba74; border-color: rgba(var(--orange-rgb), .4); }
.badge-outline { background: transparent; }
.badge-lg { font-size: 12.5px; padding: 4px 10px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.gold { background: rgba(var(--gold-rgb), .14); border-color: rgba(var(--gold-rgb), .4); color: var(--gold-2); }
.pill.cyan { background: rgba(var(--cyan-rgb), .12); border-color: rgba(var(--cyan-rgb), .35); color: #7dd3fc; }
.pill.green { background: rgba(var(--green-rgb), .12); border-color: rgba(var(--green-rgb), .35); color: #86efac; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  text-decoration: none;
}
.chip:hover { background: var(--panel-hover); color: var(--text); border-color: var(--border-2); }
.chip.active, .chip.selected { background: rgba(var(--gold-rgb), .16); border-color: rgba(var(--gold-rgb), .5); color: var(--gold-2); }
.chip svg { width: 14px; height: 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.price-up { color: var(--green); }
.price-down { color: var(--red); }
.price-flat { color: var(--muted); }
.price-up.arrow::before { content: "▲ "; font-size: .75em; }
.price-down.arrow::before { content: "▼ "; font-size: .75em; }

.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(var(--gold-rgb), .25), rgba(var(--gold-rgb), .06));
  border: 1px solid rgba(var(--gold-rgb), .45);
  color: var(--gold-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.tier-bronze, .tier-silver, .tier-gold, .tier-platinum {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #120c05;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}
.tier-bronze { background: linear-gradient(135deg, #b87333, #e0a06a 50%, #8a5a2b); }
.tier-silver { background: linear-gradient(135deg, #9aa6b8, #e2e8f0 50%, #8b98ad); }
.tier-gold { background: linear-gradient(135deg, #d99e00, #ffe082 50%, #f5b700); }
.tier-platinum { background: linear-gradient(135deg, #7dd3fc, #f0f9ff 50%, #a5f3fc); }

/* --------------------------------------------------------------------------
   11. Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  min-height: 44px;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }
.tab .tab-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  font-size: 10.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tab.active .tab-count { background: rgba(var(--gold-rgb), .18); border-color: rgba(var(--gold-rgb), .5); color: var(--gold-2); }
.tabs.pills { border: 0; gap: 6px; }
.tabs.pills .tab { border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; margin: 0; min-height: 36px; }
.tabs.pills .tab.active { background: rgba(var(--gold-rgb), .16); border-color: rgba(var(--gold-rgb), .5); color: var(--gold-2); }
.tab-panel { animation: fade-up .25s var(--ease); }
.tab-panel[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   12. Modals & toasts
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 6, 12, .72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
  overflow-y: auto;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .03) inset;
  transform: translateY(14px) scale(.98);
  opacity: 0;
  transition: transform var(--t-med) var(--ease), opacity var(--t-med) var(--ease);
}
.modal-backdrop.show .modal { transform: none; opacity: 1; }
.modal.sm { max-width: 400px; }
.modal.lg { max-width: 760px; }
.modal.xl { max-width: 1000px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.modal-title { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: 0 0 auto;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.modal-close:hover { background: var(--panel-hover); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: rgba(var(--bg2-rgb), .5);
  border-radius: 0 0 14px 14px;
  flex: 0 0 auto;
}
body.modal-open { overflow: hidden; }

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--cyan);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  color: var(--text);
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition: transform .35s var(--ease), opacity .35s var(--ease);
  pointer-events: auto;
  cursor: pointer;
}
.toast.show { transform: none; opacity: 1; }
.toast.hide { transform: translateX(calc(100% + 24px)); opacity: 0; }
.toast .toast-icon { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; color: var(--cyan); }
.toast .toast-msg { flex: 1 1 auto; min-width: 0; word-wrap: break-word; }
.toast.success { border-left-color: var(--green); }
.toast.success .toast-icon { color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.error .toast-icon { color: var(--red); }
.toast.warning { border-left-color: var(--orange); }
.toast.warning .toast-icon { color: var(--orange); }
.toast.info { border-left-color: var(--cyan); }
.toast.gold { border-left-color: var(--gold); }
.toast.gold .toast-icon { color: var(--gold); }

/* --------------------------------------------------------------------------
   13. Progress, ticker
   -------------------------------------------------------------------------- */
.progress {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  box-shadow: 0 0 10px rgba(var(--gold-rgb), .45);
  transition: width .6s var(--ease);
}
.progress.xp .progress-bar { background: linear-gradient(90deg, #7c3aed, var(--purple)); box-shadow: 0 0 10px rgba(var(--purple-rgb), .5); }
.progress.cyan .progress-bar { background: linear-gradient(90deg, #0284c7, var(--cyan)); box-shadow: 0 0 10px rgba(var(--cyan-rgb), .5); }
.progress.green .progress-bar { background: linear-gradient(90deg, #15803d, var(--green)); box-shadow: 0 0 10px rgba(var(--green-rgb), .5); }
.progress.red .progress-bar { background: linear-gradient(90deg, #b91c1c, var(--red)); box-shadow: 0 0 10px rgba(var(--red-rgb), .5); }
.progress.sm { height: 5px; }
.progress.lg { height: 14px; }
.progress.striped .progress-bar {
  background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
  background-size: 16px 16px;
  animation: progress-stripes 1s linear infinite;
}
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

.ticker {
  position: relative;
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ticker::before, .ticker::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  z-index: 2;
  pointer-events: none;
}
.ticker::before { left: 0; background: linear-gradient(90deg, var(--bg-2), transparent); }
.ticker::after { right: 0; background: linear-gradient(270deg, var(--bg-2), transparent); }
.ticker-track {
  display: inline-flex;
  align-items: center;
  animation: ticker-scroll var(--ticker-duration, 45s) linear infinite;
  will-change: transform;
}
.ticker:hover .ticker-track, .ticker.paused .ticker-track { animation-play-state: paused; }
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  font-size: 13px;
  border-right: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-2);
  height: 38px;
}
.ticker-item:hover { background: rgba(255, 255, 255, .03); color: var(--text); }
.ticker-symbol { font-weight: 800; color: var(--text); letter-spacing: .04em; }
.ticker-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: 0 0 7px; }
.ticker-price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ticker-change { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.ticker-change.up { color: var(--green); }
.ticker-change.down { color: var(--red); }
.ticker-change.flat { color: var(--muted); }

/* --------------------------------------------------------------------------
   14. Forms
   -------------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.label .req { color: var(--red); margin-left: 2px; }
.label .label-hint { float: right; font-weight: 400; color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: #3a4a68; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(var(--gold-rgb), .18);
  background: var(--bg);
}
.input:disabled, .select:disabled, .textarea:disabled { opacity: .55; cursor: not-allowed; }
.input.num, .input.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.input.sm, .select.sm { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.input.lg, .select.lg { min-height: 48px; font-size: 15px; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(var(--red-rgb), .2); }
.input.is-valid { border-color: var(--green); }
.textarea { min-height: 100px; resize: vertical; }
.select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b98ad' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.select option { background: var(--panel-2); color: var(--text); }
.input[type="number"]::-webkit-inner-spin-button { opacity: .5; }
input[type="range"] { accent-color: var(--gold); width: 100%; }

.checkbox, .radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.45;
  min-height: 24px;
}
.checkbox input, .radio input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--gold);
  flex: 0 0 18px;
  cursor: pointer;
}
.checkbox:hover, .radio:hover { color: var(--text); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: var(--border-2); position: relative; transition: background var(--t-fast) var(--ease); flex: 0 0 40px; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-fast) var(--ease); }
.switch input:checked + .track { background: var(--gold); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }

.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group > .input, .input-group > .select { flex: 1 1 auto; min-width: 0; border-radius: 0; }
.input-group > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group > :last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group-text {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.input-group-text + .input, .input-group-text + .select { border-left: 0; }
.input-group > .input + .input-group-text, .input-group > .input + .btn { border-left: 0; }
.input-group .btn { border-radius: 0; height: auto; min-height: 42px; }
.input-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group .btn-secondary { border-color: var(--border-2); }
.input-group.prefix-money .input-group-text { color: var(--gold); }

.help-text { margin-top: 6px; font-size: 12px; color: var(--muted); }
.error-text { margin-top: 6px; font-size: 12.5px; color: #fca5a5; display: flex; align-items: center; gap: 5px; }
.error-text svg { width: 14px; height: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-row .form-group { margin-bottom: 0; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin: 0; flex: 1 1 160px; }
.quick-amounts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* --------------------------------------------------------------------------
   15. Alerts, empty state, skeleton
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}
.alert svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }
.alert .alert-body { flex: 1 1 auto; min-width: 0; }
.alert .alert-title { font-weight: 700; margin-bottom: 2px; }
.alert .alert-close { margin-left: auto; color: inherit; opacity: .6; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; flex: 0 0 24px; }
.alert .alert-close:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.alert.info { background: rgba(var(--cyan-rgb), .1); border-color: rgba(var(--cyan-rgb), .35); color: #bae6fd; }
.alert.info svg { color: var(--cyan); }
.alert.success { background: rgba(var(--green-rgb), .1); border-color: rgba(var(--green-rgb), .35); color: #bbf7d0; }
.alert.success svg { color: var(--green); }
.alert.error, .alert.danger { background: rgba(var(--red-rgb), .1); border-color: rgba(var(--red-rgb), .35); color: #fecaca; }
.alert.error svg, .alert.danger svg { color: var(--red); }
.alert.warning { background: rgba(var(--orange-rgb), .1); border-color: rgba(var(--orange-rgb), .35); color: #fed7aa; }
.alert.warning svg { color: var(--orange); }
.alert.gold { background: rgba(var(--gold-rgb), .1); border-color: rgba(var(--gold-rgb), .4); color: #fde68a; }
.alert.gold svg { color: var(--gold); }
.alert a { color: inherit; text-decoration: underline; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}
.empty-state .empty-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  color: var(--muted);
  margin-bottom: 14px;
}
.empty-state .empty-icon svg { width: 28px; height: 28px; }
.empty-state .empty-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.empty-state .empty-text { font-size: 13.5px; max-width: 380px; margin: 0 auto 14px; }
.empty-state .empty-text:last-child { margin-bottom: 0; }

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--panel-2);
  border-radius: 6px;
  color: transparent !important;
  min-height: 1em;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent);
  animation: shimmer 1.4s infinite;
}
.skeleton.line { height: 14px; margin: 6px 0; }
.skeleton.title { height: 22px; width: 50%; }
.skeleton.circle { border-radius: 50%; }
.skeleton.block { height: 120px; border-radius: var(--radius); }

.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--border-2);
  border-top-color: var(--gold);
  animation: spin .8s linear infinite;
  vertical-align: middle;
}
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }
.spinner.lg { width: 36px; height: 36px; border-width: 3px; }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 40px; gap: 10px; color: var(--muted); }

/* --------------------------------------------------------------------------
   16. Avatars, presence, lists, key-value, dividers
   -------------------------------------------------------------------------- */
.avatar {
  --hue: 210;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: hsl(var(--hue), 55%, 45%);
  background-image: linear-gradient(135deg, hsl(var(--hue), 60%, 55%), hsl(var(--hue), 55%, 36%));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: uppercase;
  overflow: hidden;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, .08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  user-select: none;
  vertical-align: middle;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.xs { width: 24px; height: 24px; font-size: 9.5px; border-width: 1px; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.avatar.xl { width: 88px; height: 88px; font-size: 30px; border-width: 3px; }
.avatar.square { border-radius: 12px; }
.avatar.square img { border-radius: 10px; }
.avatar.ring { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--gold); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-left: -8px; border-color: var(--panel); }
.avatar-stack .avatar:first-child { margin-left: 0; }

.online-dot, .offline-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 9px;
  vertical-align: middle;
}
.online-dot { background: var(--green); box-shadow: 0 0 0 0 rgba(var(--green-rgb), .6); animation: pulse-dot 2s infinite; }
.offline-dot { background: var(--border-2); }
.avatar .online-dot, .avatar .offline-dot { position: absolute; right: 0; bottom: 0; border: 2px solid var(--panel); width: 11px; height: 11px; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background var(--t-fast) var(--ease);
  min-height: 52px;
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, .list-item.clickable:hover { background: var(--panel-hover); color: var(--text); }
.list-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  flex: 0 0 36px;
}
.list-icon svg { width: 18px; height: 18px; }
.list-icon.gold { background: rgba(var(--gold-rgb), .14); color: var(--gold); border-color: rgba(var(--gold-rgb), .3); }
.list-icon.cyan { background: rgba(var(--cyan-rgb), .14); color: var(--cyan); border-color: rgba(var(--cyan-rgb), .3); }
.list-icon.green { background: rgba(var(--green-rgb), .14); color: var(--green); border-color: rgba(var(--green-rgb), .3); }
.list-icon.red { background: rgba(var(--red-rgb), .14); color: var(--red); border-color: rgba(var(--red-rgb), .3); }
.list-icon.purple { background: rgba(var(--purple-rgb), .16); color: var(--purple); border-color: rgba(var(--purple-rgb), .3); }
.list-main { flex: 1 1 auto; min-width: 0; }
.list-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-right { flex: 0 0 auto; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13.5px; }
.list-right .sub { display: block; font-family: var(--font-sans); font-weight: 400; font-size: 11.5px; color: var(--muted); }

.kv { display: flex; flex-direction: column; }
.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13.5px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-key { color: var(--muted); flex: 0 1 auto; }
.kv-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); text-align: right; }
.kv-val.gold { color: var(--gold-2); }
.kv.compact .kv-row { padding: 5px 0; font-size: 12.5px; }
.kv.total .kv-row:last-child { border-top: 1px solid var(--border-2); margin-top: 4px; padding-top: 10px; font-size: 15px; }

.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }
.divider.text { display: flex; align-items: center; gap: 12px; height: auto; background: none; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.divider.text::before, .divider.text::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--border); }
.divider.vertical { width: 1px; height: auto; align-self: stretch; margin: 0 8px; }

/* --------------------------------------------------------------------------
   17. Tooltip, kbd, section titles, page header, countdown
   -------------------------------------------------------------------------- */
.tooltip { position: relative; }
.tooltip[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  padding: 6px 10px;
  background: #05080f;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  z-index: 400;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.tooltip[data-tip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border-2);
  opacity: 0;
  pointer-events: none;
  z-index: 400;
  transition: opacity var(--t-fast) var(--ease);
}
.tooltip[data-tip]:hover::after, .tooltip[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.tooltip[data-tip]:hover::before, .tooltip[data-tip]:focus-visible::before { opacity: 1; }
.tooltip.tip-bottom[data-tip]::after { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -4px); }
.tooltip.tip-bottom[data-tip]:hover::after { transform: translate(-50%, 0); }
.tooltip.tip-bottom[data-tip]::before { bottom: auto; top: calc(100% + 3px); border-top-color: transparent; border-bottom-color: var(--border-2); }

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.6;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}
.section-title:first-child { margin-top: 0; }
.section-title h2, .section-title h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.section-title h2 svg, .section-title h3 svg { width: 18px; height: 18px; color: var(--gold); }
.section-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 24px; display: flex; align-items: center; gap: 10px; }
.page-header h1 svg { width: 24px; height: 24px; color: var(--gold); }
.page-header .page-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.page-header .page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--gold-2);
  white-space: nowrap;
}
.countdown svg { width: 14px; height: 14px; }
.countdown.urgent { color: var(--red); animation: pulse 1.2s infinite; }
.countdown.done { color: var(--green); }
.countdown.big { font-size: 28px; letter-spacing: .02em; }

/* --------------------------------------------------------------------------
   18. Notifications, chat, map, order book
   -------------------------------------------------------------------------- */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
  transition: background var(--t-fast) var(--ease);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--panel-hover); color: var(--text); }
.notif-item.unread { background: rgba(var(--cyan-rgb), .06); border-left-color: var(--cyan); }
.notif-item.unread .notif-title { color: var(--text); font-weight: 700; }
.notif-title { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.notif-body { font-size: 13px; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }

.chat-box {
  display: flex;
  flex-direction: column;
  height: 560px;
  max-height: calc(100vh - var(--topbar-h) - 120px);
  min-height: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13.5px; }
.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
}
.chat-msg {
  max-width: 78%;
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: fade-up .2s var(--ease);
}
.chat-msg.own {
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  background: rgba(var(--gold-rgb), .14);
  border-color: rgba(var(--gold-rgb), .35);
}
.chat-msg.system { align-self: center; max-width: 90%; background: transparent; border: 0; color: var(--muted); font-size: 12px; text-align: center; font-style: italic; }
.chat-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.chat-meta .chat-name { font-weight: 700; color: var(--cyan); }
.chat-msg.own .chat-meta .chat-name { color: var(--gold-2); }
.chat-meta .chat-time { opacity: .8; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: rgba(var(--bg2-rgb), .5); }
.chat-input-row .input { flex: 1 1 auto; min-height: 42px; }
.chat-input-row .btn { flex: 0 0 auto; height: 42px; }
.chat-online-list { display: flex; flex-direction: column; gap: 2px; }

.map-wrap {
  position: relative;
  height: calc(100vh - var(--topbar-h) - 48px);
  min-height: 440px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  touch-action: none;
}
.map-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.map-canvas:active { cursor: grabbing; }
.map-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}
.map-hud .card { background: rgba(var(--panel-rgb), .92); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.map-controls { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.map-controls .icon-btn { background: rgba(var(--panel-rgb), .92); border-color: var(--border); }
.map-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100%;
  background: rgba(var(--panel-rgb), .97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-left: 1px solid var(--border-2);
  transform: translateX(100%);
  transition: transform var(--t-med) var(--ease);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.map-panel.open { transform: none; box-shadow: -10px 0 40px rgba(0, 0, 0, .4); }
.map-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.map-panel-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; }
.map-panel-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.order-book {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ob-side { background: var(--panel); min-width: 0; }
.ob-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.ob-head span:not(:first-child), .ob-row span:not(:first-child) { text-align: right; }
.ob-title { padding: 8px 12px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.ob-bids .ob-title { color: var(--green); }
.ob-asks .ob-title { color: var(--red); }
.ob-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.ob-row > span { position: relative; z-index: 1; }
.ob-row::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(var(--depth, 0) * 1%);
  max-width: 100%;
  pointer-events: none;
  transition: width .4s var(--ease);
}
.ob-bids .ob-row::before { right: 0; background: rgba(var(--green-rgb), .14); }
.ob-asks .ob-row::before { left: 0; background: rgba(var(--red-rgb), .14); }
.ob-row:hover { background: rgba(255, 255, 255, .04); }
.ob-bids .ob-price { color: var(--green); font-weight: 700; }
.ob-asks .ob-price { color: var(--red); font-weight: 700; }
.ob-row.mine .ob-price::after { content: "●"; font-size: 7px; margin-left: 4px; color: var(--gold); vertical-align: middle; }
.ob-spread {
  grid-column: 1 / -1;
  padding: 8px 12px;
  background: var(--panel-2);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.ob-spread strong { color: var(--gold-2); }
.ob-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* --------------------------------------------------------------------------
   19. Animations
   -------------------------------------------------------------------------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(var(--green-rgb), .55); } 70% { box-shadow: 0 0 0 6px rgba(var(--green-rgb), 0); } 100% { box-shadow: 0 0 0 0 rgba(var(--green-rgb), 0); } }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes progress-stripes { from { background-position: 16px 0; } to { background-position: 0 0; } }
@keyframes flash-green { 0% { background: rgba(var(--green-rgb), .35); } 100% { background: transparent; } }
@keyframes flash-red { 0% { background: rgba(var(--red-rgb), .35); } 100% { background: transparent; } }
@keyframes glow-gold { 0%, 100% { box-shadow: 0 0 0 0 rgba(var(--gold-rgb), .0); } 50% { box-shadow: 0 0 22px 2px rgba(var(--gold-rgb), .35); } }

.animate-in { animation: fade-up .4s var(--ease) both; }
.animate-in.delay-1 { animation-delay: .06s; }
.animate-in.delay-2 { animation-delay: .12s; }
.animate-in.delay-3 { animation-delay: .18s; }
.animate-in.delay-4 { animation-delay: .24s; }
.fade-in { animation: fade-in .3s var(--ease) both; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
.flash-up { animation: flash-green 1s var(--ease); }
.flash-down { animation: flash-red 1s var(--ease); }
.glow-anim { animation: glow-gold 2.2s ease-in-out infinite; }

/* --------------------------------------------------------------------------
   20. Utilities
   -------------------------------------------------------------------------- */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 24px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.p-0 { padding: 0; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.text-muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.text-gold { color: var(--gold-2); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-cyan { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-orange { color: var(--orange); }
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 12.5px; }
.text-md { font-size: 14px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 21px; }
.text-2xl { font-size: 28px; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }
.uppercase { text-transform: uppercase; letter-spacing: .06em; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; }
.clickable { cursor: pointer; }
.block { display: block; }
.relative { position: relative; }
.opacity-50 { opacity: .5; }
.opacity-75 { opacity: .75; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
.rounded-full { border-radius: 999px; }
.border { border: 1px solid var(--border); }
.bg-panel { background: var(--panel); }
.bg-panel-2 { background: var(--panel-2); }
.shadow { box-shadow: var(--shadow); }
.overflow-auto { overflow: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hide-mobile { }
.show-mobile { display: none !important; }
.icon-16 { width: 16px; height: 16px; }
.icon-20 { width: 20px; height: 20px; }
.icon-24 { width: 24px; height: 24px; }
.icon-32 { width: 32px; height: 32px; }

/* --------------------------------------------------------------------------
   21. Auth card (login/register)
   -------------------------------------------------------------------------- */
.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: rgba(var(--panel-rgb), .92);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  padding: 32px 30px 26px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, .02) inset;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-up .45s var(--ease) both;
}
.auth-card.wide { max-width: 520px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-decoration: none; color: var(--text); }
.auth-logo .brand-logo { width: 56px; height: 56px; flex-basis: 56px; }
.auth-logo .brand-name { font-size: 19px; letter-spacing: .14em; }
.auth-title { font-size: 20px; font-weight: 800; text-align: center; margin: 0 0 4px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.auth-links { text-align: center; font-size: 13px; color: var(--muted); margin-top: 18px; }
.auth-links a { font-weight: 600; }
.auth-creator { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 18px; opacity: .85; }
.auth-creator a { color: var(--muted); }
.auth-creator a:hover { color: var(--gold-2); }
.auth-side-note { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 10px; }

/* --------------------------------------------------------------------------
   22. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.sidebar-right, .grid.sidebar-left { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .main { grid-column: 1; }
  .sidebar {
    transform: translateX(-100%);
    width: min(300px, 86vw);
    box-shadow: none;
    border-right-color: var(--border-2);
  }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, .55); }
  .sidebar-backdrop { display: block; pointer-events: none; }
  .sidebar-backdrop.show { pointer-events: auto; }
  .hamburger { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px; }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-link { min-height: 44px; }
  .map-panel { width: 320px; }
}

@media (max-width: 768px) {
  :root { --topbar-h: 56px; }
  body.layout-app { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav { display: grid; }
  .sidebar-player { display: none; }
  .content { padding: 14px; }
  .app-footer { padding: 16px 14px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-title { font-size: 15px; }
  .money-chip { height: 34px; padding: 0 10px 0 8px; font-size: 12px; }
  .money-chip .chip-label { display: none; }
  .money-chip.bank { display: none; }
  .icon-btn { width: 40px; height: 40px; }

  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: minmax(0, 1fr); }
  .grid.mobile-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { gap: 12px; }
  .span-2, .span-3 { grid-column: auto; }

  .stat { padding: 14px 16px; }
  .stat-value { font-size: 21px; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; }
  .card-body { padding: 14px; }
  .card-footer { padding: 10px 14px; flex-wrap: wrap; }

  .page-header { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 16px; }
  .page-header h1 { font-size: 21px; }
  .page-header .page-actions .btn { flex: 1 1 auto; }
  .section-title { flex-wrap: wrap; }

  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .input, .select, .textarea { min-height: 44px; font-size: 16px; }
  .input.sm, .select.sm { min-height: 38px; font-size: 14px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .form-row { grid-template-columns: 1fr; }

  .table th, .table td { padding: 10px 12px; }
  .table-wrap { border-radius: var(--radius-sm); }

  .tabs { margin-bottom: 14px; }
  .tab { padding: 10px 12px; font-size: 13px; }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; border-bottom: 0; transform: translateY(40px); }
  .modal.lg, .modal.xl, .modal.sm { max-width: 100%; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-radius: 0; flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }

  .toast-stack { top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; left: 10px; width: auto; }
  .toast { transform: translateY(-20px); }
  .toast.hide { transform: translateY(-20px); }

  .chat-box { height: calc(100vh - var(--topbar-h) - var(--bottom-nav-h) - 60px); max-height: none; }
  .chat-msg { max-width: 88%; }

  .map-wrap { height: calc(100vh - var(--topbar-h) - var(--bottom-nav-h) - 28px); min-height: 380px; border-radius: var(--radius-sm); }
  .map-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62%;
    border-left: 0;
    border-top: 1px solid var(--border-2);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .map-panel.open { transform: none; box-shadow: 0 -10px 40px rgba(0, 0, 0, .45); }
  .map-panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border-2); margin: 8px auto 0; }

  .order-book { grid-template-columns: 1fr; }
  .ob-row { min-height: 34px; align-items: center; }

  .ticker { height: 34px; }
  .ticker-item { padding: 0 14px; font-size: 12px; height: 34px; }

  .list-item { padding: 10px 12px; }
  .kv-row { padding: 8px 0; }
  .tooltip[data-tip]::after, .tooltip[data-tip]::before { display: none; }
  .dropdown-menu { min-width: 200px; }

  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
  .show-mobile.flex { display: flex !important; }
  span.show-mobile, a.show-mobile.inline { display: inline !important; }
  .auth-card { padding: 26px 20px 20px; border-radius: 16px; }
  .bare-content { padding: 20px 14px; }
}

@media (max-width: 480px) {
  .grid.mobile-2 { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 20px; }
  .topbar-title { display: none; }
  .content { padding: 12px; }
  .card + .card { margin-top: 12px; }
}

/* --------------------------------------------------------------------------
   23. Reduced motion & print
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .ticker-track { animation: none; }
  .online-dot { animation: none; }
}

@media print {
  .sidebar, .sidebar-backdrop, .topbar, .bottom-nav, .toast-stack, .modal-backdrop, .ticker, .app-footer, .hamburger, .page-actions, .section-actions { display: none !important; }
  .app-shell { display: block; }
  .main { min-height: 0; }
  body { background: #fff; color: #000; }
  .card, .stat, .table-wrap { border-color: #ccc; background: #fff; color: #000; box-shadow: none; }
  .content { max-width: none; padding: 0; }
  a { color: #000; }
}
