/* ==========================================================================
   Goldify — User-facing design system  (theme.css)
   --------------------------------------------------------------------------
   Loaded ONLY by includes/header.php for the user-facing app.
   The /admin area has its own stylesheets and never loads this file.

   Contents
     1.  Design tokens (dark-first) + light theme
     2.  Base / reset layer
     3.  Typography helpers
     4.  Buttons (Bootstrap-compatible + gx-btn)
     5.  Form controls
     6.  Surfaces: card / panel / stat / divider
     7.  Tabs / chips / segmented
     8.  Tables
     9.  Badges / pills
     10. Empty states / skeletons
     11. App chrome: appbar / bottom nav / drawer / language menu
     12. Animation utilities + reduced motion
   ========================================================================== */

/* -------------------------------------------------------------------------
   0. FONT FACE  (local Kanit, path resolved relative to this file)
   ---------------------------------------------------------------------- */
@font-face {
  font-family: "myfont";
  src: url("../../font/Kanit-Regular.ttf") format("truetype");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "myfont";
  src: url("../../font/Kanit-Medium.ttf") format("truetype");
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: "myfont";
  src: url("../../font/Kanit-SemiBold.ttf") format("truetype");
  font-weight: 600 650; font-display: swap;
}
@font-face {
  font-family: "myfont";
  src: url("../../font/Kanit-Bold.ttf") format("truetype");
  font-weight: 700 900; font-display: swap;
}

/* -------------------------------------------------------------------------
   1. DESIGN TOKENS
   ---------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* Surfaces */
  --bg-primary:    #0b0e11;
  --bg-secondary:  #121722;
  --bg-tertiary:   #161b26;
  --panel:         #131824;
  --panel-hover:   #1b2230;
  --panel-raised:  #1e2532;
  --border:        #262d3a;
  --border-subtle: #1c222d;

  /* Text */
  --text-primary:   #eef1f6;
  --text-secondary: #a7b0c0;
  --text-muted:     #6b7688;
  --text-inverse:   #0b0e11;

  /* Brand + semantic accents */
  --accent:        #2f6fed;
  --accent-hover:  #3b7bf5;
  --accent-soft:   rgba(47, 111, 237, 0.14);
  --accent-border: rgba(47, 111, 237, 0.42);
  --gold:          #f0b90b;

  --positive:        #0ecb81;
  --positive-soft:   rgba(14, 203, 129, 0.14);
  --negative:        #f6465d;
  --negative-soft:   rgba(246, 70, 93, 0.14);
  --warning:         #f5a623;
  --warning-soft:    rgba(245, 166, 35, 0.14);
  --info:            #4c8dff;

  /* Directional trade colours — overridden per user setting in header.php */
  --buy:  var(--accent);
  --sell: var(--negative);

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-3: 0 24px 60px -20px rgba(0,0,0,.6);
  --ring: 0 0 0 3px var(--accent-soft);

  /* Motion */
  --dur-1: .12s;
  --dur-2: .2s;
  --dur-3: .34s;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* Layout */
  --appbar-h: 58px;
  --bottomnav-h: 62px;
  --content-max: 1280px;

  /* Type */
  --font-sans: "myfont", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", "Noto Sans", "Noto Sans Thai", "Noto Sans SC",
               "Noto Sans KR", "Noto Sans CJK KR", Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo,
               Consolas, monospace;

  /* ---- Legacy aliases: keep pages that reference (not redefine) these consistent ---- */
  --bg-main: var(--bg-primary);
  --bg-dark: var(--bg-primary);
  --bg-card: var(--panel);
  --card-bg: var(--panel);
  --card-dark: var(--panel);
  --bg-card-hover: var(--panel-hover);
  --bg-hover: var(--panel-hover);
  --border-color: var(--border);
  --text-main: var(--text-primary);
  --text-slate: var(--text-secondary);
  --primary: var(--accent);
  --primary-blue: var(--accent);
  --primary-gold: var(--gold);
  --primary-hover: var(--accent-hover);
  --buy-blue: var(--buy);
  --sell-red: var(--sell);
  --success: var(--positive);
  --success-green: var(--positive);
  --danger: var(--negative);
  --danger-red: var(--negative);
  --error-red: var(--negative);
  --warning-orange: var(--warning);
  --blue-crayola: var(--accent);
  --eerie-black-1: var(--bg-primary);
  --eerie-black-2: var(--bg-secondary);
  --raisin-black: var(--panel);
  --cadet-blue-crayola: var(--text-muted);
  --roman-silver: var(--text-muted);
  --white: #ffffff;
  --radius-12: var(--radius-md);
  --radius-24: var(--radius-lg);
  --transition-1: var(--dur-2) var(--ease);
}

/* Light theme — explicit opt-in wins in both directions */
:root[data-theme="light"] {
  color-scheme: light;
  --bg-primary:   #f4f6fa;
  --bg-secondary: #eef1f6;
  --bg-tertiary:  #e7ebf2;
  --panel:        #ffffff;
  --panel-hover:  #f2f5f9;
  --panel-raised: #ffffff;
  --border:       #dde2ea;
  --border-subtle:#e8ecf2;
  --text-primary:   #0e1420;
  --text-secondary: #47526a;
  --text-muted:     #7a8699;
  --text-inverse:   #ffffff;
  --accent-soft:   rgba(47, 111, 237, 0.10);
  --positive-soft: rgba(14, 179, 116, 0.12);
  --negative-soft: rgba(228, 60, 84, 0.12);
  --warning-soft:  rgba(214, 141, 20, 0.14);
  --shadow-1: 0 1px 2px rgba(16,24,40,.06);
  --shadow-2: 0 10px 28px -12px rgba(16,24,40,.18);
  --shadow-3: 0 24px 60px -20px rgba(16,24,40,.22);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg-primary:   #f4f6fa;
    --bg-secondary: #eef1f6;
    --bg-tertiary:  #e7ebf2;
    --panel:        #ffffff;
    --panel-hover:  #f2f5f9;
    --panel-raised: #ffffff;
    --border:       #dde2ea;
    --border-subtle:#e8ecf2;
    --text-primary:   #0e1420;
    --text-secondary: #47526a;
    --text-muted:     #7a8699;
    --text-inverse:   #ffffff;
    --accent-soft:   rgba(47, 111, 237, 0.10);
    --positive-soft: rgba(14, 179, 116, 0.12);
    --negative-soft: rgba(228, 60, 84, 0.12);
    --warning-soft:  rgba(214, 141, 20, 0.14);
    --shadow-1: 0 1px 2px rgba(16,24,40,.06);
    --shadow-2: 0 10px 28px -12px rgba(16,24,40,.18);
    --shadow-3: 0 24px 60px -20px rgba(16,24,40,.22);
  }
}

/* -------------------------------------------------------------------------
   2. BASE
   ---------------------------------------------------------------------- */
html { font-size: 10px; -webkit-text-size-adjust: 100%; }

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); color: var(--text-primary); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

a { color: inherit; }

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.gx-tabnum { font-variant-numeric: tabular-nums; }
.gx-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Shared page shell used by redesigned pages */
.gx-page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--bottomnav-h) + var(--sp-7));
}
.gx-page-head {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-2) 0 var(--sp-5);
}
.gx-page-head h1, .gx-page-head h2, .gx-page-head h3 {
  margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em;
}
.gx-page-head .gx-page-head__icon { color: var(--accent); font-size: 20px; display: inline-flex; }

.gx-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 var(--sp-3);
}

/* -------------------------------------------------------------------------
   3. TYPOGRAPHY HELPERS
   ---------------------------------------------------------------------- */
.gx-text-pos { color: var(--positive) !important; }
.gx-text-neg { color: var(--negative) !important; }
.gx-text-muted { color: var(--text-muted) !important; }
.gx-text-2 { color: var(--text-secondary) !important; }

/* -------------------------------------------------------------------------
   4. BUTTONS  (Bootstrap classes kept working + gx-btn system)
   ---------------------------------------------------------------------- */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: filter var(--dur-2) var(--ease), transform var(--dur-1) var(--ease),
              background-color var(--dur-2) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background-color: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success { background-color: var(--positive); border-color: var(--positive); color: #04110b; }
.btn-danger  { background-color: var(--negative); border-color: var(--negative); }
.btn-outline-primary { color: var(--accent); border-color: var(--accent-border); }

.gx-btn {
  --_bg: var(--panel-hover);
  --_fg: var(--text-primary);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--_bg); color: var(--_fg);
  font: inherit; font-weight: 650; font-size: 14px; letter-spacing: .01em;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: filter var(--dur-2) var(--ease), transform var(--dur-1) var(--ease),
              background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.gx-btn:hover { filter: brightness(1.08); }
.gx-btn:active { transform: translateY(1px) scale(.995); }
.gx-btn:disabled, .gx-btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.gx-btn--block { width: 100%; }
.gx-btn--lg { min-height: 52px; font-size: 15px; border-radius: var(--radius-md); }
.gx-btn--sm { min-height: 34px; padding: 0 var(--sp-3); font-size: 13px; }
.gx-btn--primary { --_bg: var(--accent); --_fg: #fff; border-color: transparent; }
.gx-btn--buy  { --_bg: var(--buy);  --_fg: #fff; border-color: transparent; }
.gx-btn--sell { --_bg: var(--sell); --_fg: #fff; border-color: transparent; }
.gx-btn--ghost { --_bg: transparent; border-color: var(--border); }
.gx-btn--soft { --_bg: var(--accent-soft); --_fg: var(--accent); border-color: transparent; }

/* -------------------------------------------------------------------------
   5. FORM CONTROLS
   ---------------------------------------------------------------------- */
.gx-field { display: block; margin-bottom: var(--sp-4); }
.gx-field > label, .gx-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
  margin-bottom: var(--sp-2); letter-spacing: .02em;
}
.gx-input, .gx-select {
  width: 100%; min-height: 46px; padding: 0 var(--sp-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font: inherit; font-size: 15px;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
              background-color var(--dur-2) var(--ease);
}
.gx-input::placeholder { color: var(--text-muted); }
.gx-input:focus, .gx-select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
  background: var(--panel);
}
.gx-input[readonly] { background: var(--bg-tertiary); color: var(--text-muted); cursor: not-allowed; }

/* -------------------------------------------------------------------------
   6. SURFACES
   ---------------------------------------------------------------------- */
.gx-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}
.gx-card--tight { padding: var(--sp-4); border-radius: var(--radius-md); }
.gx-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.gx-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted);
}
.gx-divider { height: 1px; background: var(--border-subtle); border: 0; margin: var(--sp-4) 0; }

.gx-stat { display: flex; flex-direction: column; gap: 3px; }
.gx-stat__k { font-size: 11px; color: var(--text-muted); letter-spacing: .03em; }
.gx-stat__v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Key/value rows */
.gx-kv { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); padding: 7px 0; }
.gx-kv__k { color: var(--text-muted); font-size: 13px; }
.gx-kv__v { font-weight: 650; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------------
   7. TABS / SEGMENTED / CHIPS
   ---------------------------------------------------------------------- */
.gx-tabs {
  display: flex; gap: 2px; padding: 3px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.gx-tab {
  flex: 1; min-height: 38px; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: 0 var(--sp-3);
  border-radius: var(--radius-xs); border: 0; background: transparent;
  color: var(--text-muted); font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.gx-tab:hover { color: var(--text-secondary); }
.gx-tab.is-active, .gx-tab[aria-selected="true"] {
  background: var(--panel-raised); color: var(--text-primary); box-shadow: var(--shadow-1);
}

/* Scrollable filter row */
.gx-chiprow {
  display: flex; gap: var(--sp-2); overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 2px; scrollbar-width: none;
}
.gx-chiprow::-webkit-scrollbar { display: none; }
.gx-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 34px; padding: 0 var(--sp-4);
  border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--panel); color: var(--text-secondary);
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: all var(--dur-2) var(--ease);
}
.gx-chip:hover { border-color: var(--text-muted); }
.gx-chip.is-active {
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border);
}

/* -------------------------------------------------------------------------
   8. TABLES
   ---------------------------------------------------------------------- */
.gx-tablewrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
}
.gx-table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 13px; }
.gx-table thead th {
  position: sticky; top: 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600; font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  text-align: right; padding: 11px var(--sp-4); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.gx-table thead th:first-child { text-align: left; }
.gx-table tbody td {
  padding: 13px var(--sp-4); text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}
.gx-table tbody td:first-child { text-align: left; }
.gx-table tbody tr:last-child td { border-bottom: 0; }
.gx-table tbody tr { transition: background-color var(--dur-2) var(--ease); }
.gx-table tbody tr:hover { background: var(--panel-hover); }

/* -------------------------------------------------------------------------
   9. BADGES / PILLS
   ---------------------------------------------------------------------- */
.gx-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--radius-xs);
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  background: var(--panel-hover); color: var(--text-secondary);
}
.gx-badge--pos { background: var(--positive-soft); color: var(--positive); }
.gx-badge--neg { background: var(--negative-soft); color: var(--negative); }
.gx-badge--warn { background: var(--warning-soft); color: var(--warning); }
.gx-badge--accent { background: var(--accent-soft); color: var(--accent); }
.gx-badge--gold { background: rgba(240,185,11,.14); color: var(--gold); }

.gx-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--bg-secondary); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums;
}

.gx-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); display: inline-block; }
.gx-dot--live { box-shadow: 0 0 0 0 rgba(14,203,129,.6); animation: gxPulse 1.6s infinite; }

/* -------------------------------------------------------------------------
   10. EMPTY STATES / SKELETONS
   ---------------------------------------------------------------------- */
.gx-empty {
  text-align: center; padding: var(--sp-8) var(--sp-5);
  border: 1px dashed var(--border); border-radius: var(--radius-md); color: var(--text-muted);
}
.gx-empty i { font-size: 40px; display: block; margin-bottom: var(--sp-3); opacity: .6; }
.gx-empty p { margin: 0 0 var(--sp-4); font-size: 14px; }

.gx-skeleton {
  position: relative; overflow: hidden;
  background: var(--panel-hover); border-radius: var(--radius-xs); color: transparent;
}
.gx-skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  transform: translateX(-100%); animation: gxShimmer 1.4s infinite;
}

/* -------------------------------------------------------------------------
   11. APP CHROME
   ---------------------------------------------------------------------- */
/* Top app bar */
.gx-appbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
  height: var(--appbar-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg-secondary) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .gx-appbar { background: var(--bg-secondary); } }
.gx-appbar__inner {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 0 var(--sp-4);
}
.gx-appbar__left { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.gx-appbar__actions { display: flex; align-items: center; gap: 2px; }

.gx-brand { display: inline-flex; align-items: center; gap: var(--sp-2); text-decoration: none; }
.gx-brand__mark { display: block; flex: 0 0 auto; }
.gx-brand__word {
  font-weight: 800; font-size: 16px; letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.gx-iconbtn {
  position: relative;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--text-secondary);
  font-size: 19px; cursor: pointer; text-decoration: none;
  transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.gx-iconbtn:hover { background: var(--panel-hover); color: var(--text-primary); }
.gx-iconbtn__badge {
  position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: var(--radius-pill); background: var(--negative); color: #fff;
  font-size: 9px; font-weight: 800; line-height: 15px; text-align: center;
  border: 2px solid var(--bg-secondary);
}

/* Account chip (logged-in, left of appbar) */
.gx-acctchip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 5px 10px 5px 6px; border-radius: var(--radius-pill);
  background: var(--panel); border: 1px solid var(--border);
  text-decoration: none; color: var(--text-primary); min-width: 0;
}
.gx-acctchip__av {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #00c6ff); color: #fff;
  font-size: 12px; font-weight: 800;
}
.gx-acctchip__name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gx-acctchip__tier {
  font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--radius-xs); background: var(--accent-soft); color: var(--accent);
}

/* Bottom navigation (mobile) */
.gx-bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
  display: flex; align-items: stretch;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .gx-bottomnav { background: var(--bg-secondary); } }
.gx-bottomnav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--text-muted); font-size: 10px; font-weight: 600;
  transition: color var(--dur-2) var(--ease);
}
.gx-bottomnav__item i { font-size: 20px; transition: transform var(--dur-2) var(--ease); }
.gx-bottomnav__item:hover { color: var(--text-secondary); }
.gx-bottomnav__item[aria-current="page"] { color: var(--accent); }
.gx-bottomnav__item[aria-current="page"] i { transform: translateY(-1px) scale(1.06); }

@media (min-width: 1024px) {
  .gx-bottomnav { display: none; }
  :root { --bottomnav-h: 0px; }
}

/* Slide-in drawer + scrim */
.gx-scrim {
  position: fixed; inset: 0; z-index: 1050;
  background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-3) var(--ease);
}
.gx-scrim.is-open { opacity: 1; pointer-events: auto; }

.gx-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 1060;
  width: min(84vw, 340px);
  display: flex; flex-direction: column;
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform var(--dur-3) var(--ease);
  overflow-y: auto; overscroll-behavior: contain;
}
.gx-drawer.is-open { transform: translateX(0); }
.gx-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4); border-bottom: 1px solid var(--border);
}
.gx-drawer__body { padding: var(--sp-3); flex: 1; }
.gx-drawer__foot { padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.gx-drawer__group { padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.gx-drawer__grouplabel {
  font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
}
.gx-drawer__link {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 46px; padding: 0 var(--sp-3); border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 600;
  transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.gx-drawer__link i { font-size: 18px; width: 22px; text-align: center; color: var(--text-muted); }
.gx-drawer__link:hover { background: var(--panel-hover); color: var(--text-primary); }
.gx-drawer__link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.gx-drawer__link[aria-current="page"] i { color: var(--accent); }

/* Language menu (shared: appbar dropdown + drawer list) */
.gx-langmenu { display: grid; gap: 2px; }
.gx-langmenu__item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: 42px; padding: 0 var(--sp-3); border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 600;
  background: transparent; border: 0; width: 100%; cursor: pointer;
}
.gx-langmenu__item:hover { background: var(--panel-hover); color: var(--text-primary); }
.gx-langmenu__item.is-active { color: var(--accent); }
.gx-langmenu__item.is-active::after { content: "\F26E"; font-family: "bootstrap-icons"; }

/* Bootstrap dropdown skin (used by appbar language + notifications) */
.gx-appbar .dropdown-menu {
  background: var(--panel-raised); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-3); padding: 6px;
  margin-top: 8px;
}
.gx-appbar .dropdown-item { color: var(--text-secondary); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; }
.gx-appbar .dropdown-item:hover, .gx-appbar .dropdown-item:focus { background: var(--panel-hover); color: var(--text-primary); }

/* -------------------------------------------------------------------------
   12. ANIMATION UTILITIES
   ---------------------------------------------------------------------- */
@keyframes gxFadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes gxPulse {
  0% { box-shadow: 0 0 0 0 rgba(14,203,129,.55); }
  70% { box-shadow: 0 0 0 7px rgba(14,203,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(14,203,129,0); }
}
@keyframes gxSpin { to { transform: rotate(360deg); } }
@keyframes gxShimmer { to { transform: translateX(100%); } }
@keyframes gxFlashUp   { 0% { background-color: var(--positive-soft); } 100% { background-color: transparent; } }
@keyframes gxFlashDown { 0% { background-color: var(--negative-soft); } 100% { background-color: transparent; } }

.gx-fade-up { animation: gxFadeUp var(--dur-3) var(--ease) both; }
.gx-flash-up   { animation: gxFlashUp .6s var(--ease); }
.gx-flash-down { animation: gxFlashDown .6s var(--ease); }
.gx-spin { animation: gxSpin .9s linear infinite; }
.gx-price-up { color: var(--positive); transition: color var(--dur-3) var(--ease); }
.gx-price-down { color: var(--negative); transition: color var(--dur-3) var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   13. EXTENDED PRIMITIVES  (wave 3 — account / money / auth / workspace)
   ========================================================================== */

/* ---- View header with optional back link ---------------------------- */
.gx-page-head__back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: -6px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; font-size: 18px; flex: 0 0 auto;
  transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.gx-page-head__back:hover { background: var(--panel-hover); color: var(--text-primary); }
.gx-page-head__spacer { margin-left: auto; }
.gx-page-head__action {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.gx-page-head__action:hover { filter: brightness(1.1); }

.gx-page--narrow { max-width: 620px; }

/* ---- Section grouping ---------------------------------------------- */
.gx-group { margin-bottom: var(--sp-6); }
.gx-group > .gx-section-label { margin-left: 2px; }

/* ---- Forms ------------------------------------------------------------ */
.gx-form { display: block; }
.gx-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
@media (max-width: 420px) { .gx-form-row { grid-template-columns: 1fr; } }

textarea.gx-input { min-height: 92px; padding-top: 12px; padding-bottom: 12px; resize: vertical; line-height: 1.5; }
select.gx-input, .gx-input select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7688' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--sp-4) center; padding-right: 38px;
}

/* Input + trailing addon (MAX button, currency unit, copy…) */
.gx-inputgroup {
  display: flex; align-items: stretch;
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.gx-inputgroup:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.gx-inputgroup > input, .gx-inputgroup > .gx-input {
  flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none;
  min-height: 46px; padding: 0 var(--sp-4); color: var(--text-primary); font: inherit; font-size: 15px; outline: none;
}
.gx-inputgroup__unit { display: inline-flex; align-items: center; padding: 0 var(--sp-4); color: var(--text-muted); font-size: 13px; font-weight: 700; }
.gx-inputgroup__btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 var(--sp-4); border: 0;
  background: var(--accent-soft); color: var(--accent); font: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
  transition: filter var(--dur-2) var(--ease);
}
.gx-inputgroup__btn:hover { filter: brightness(1.12); }
.gx-inputgroup__btn--solid { background: var(--accent); color: #fff; }

.gx-hint { margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.gx-hint--neg { color: var(--negative); }
.gx-req { color: var(--negative); }

/* Sticky submit bar (mobile-friendly form footer) */
.gx-formbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); z-index: 900;
  padding: 10px var(--sp-4);
  background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .gx-formbar { background: var(--bg-secondary); } }
.gx-page:has(.gx-formbar) { padding-bottom: calc(var(--bottomnav-h) + 128px); }
@media (min-width: 1024px) {
  .gx-formbar { position: static; padding: 0; margin-top: var(--sp-5); background: none; border: 0; backdrop-filter: none; }
  .gx-page:has(.gx-formbar) { padding-bottom: var(--sp-7); }
}

/* ---- Settings list rows (title/desc + control) --------------------- */
.gx-list {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
}
.gx-list__row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 16px var(--sp-4); border-bottom: 1px solid var(--border-subtle);
}
.gx-list__row:last-child { border-bottom: 0; }
.gx-list__row--tap { text-decoration: none; color: inherit; transition: background-color var(--dur-2) var(--ease); cursor: pointer; }
.gx-list__row--tap:hover { background: var(--panel-hover); }
.gx-list__row--stack { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
.gx-list__ic { width: 30px; text-align: center; color: var(--text-muted); font-size: 18px; flex: 0 0 auto; }
.gx-list__main { flex: 1; min-width: 0; }
.gx-list__title { font-size: 14px; font-weight: 650; }
.gx-list__desc { font-size: 12px; color: var(--text-muted); line-height: 1.45; margin-top: 3px; }
.gx-list__val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gx-list__chev { color: var(--text-muted); font-size: 13px; flex: 0 0 auto; }

/* ---- iOS-style switch --------------------------------------------- */
.gx-switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: 0 0 auto; }
.gx-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.gx-switch__track {
  position: absolute; inset: 0; border-radius: var(--radius-pill);
  background: var(--panel-hover); border: 1px solid var(--border); transition: background-color var(--dur-2) var(--ease);
}
.gx-switch__track::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur-2) var(--ease);
}
.gx-switch input:checked + .gx-switch__track { background: var(--positive); border-color: transparent; }
.gx-switch input:checked + .gx-switch__track::before { transform: translateX(18px); }
.gx-switch input:focus-visible + .gx-switch__track { box-shadow: var(--ring); }

/* ---- Selectable option cards (radio) ------------------------------ */
.gx-optionrow { display: grid; gap: var(--sp-2); }
.gx-option {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 14px var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; transition: all var(--dur-2) var(--ease);
}
.gx-option input { position: absolute; opacity: 0; pointer-events: none; }
.gx-option__mark {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--text-muted); flex: 0 0 auto; position: relative;
  transition: border-color var(--dur-2) var(--ease);
}
.gx-option__body { flex: 1; min-width: 0; }
.gx-option__title { font-size: 14px; font-weight: 650; }
.gx-option__desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.gx-option:has(input:checked) { border-color: var(--accent-border); background: var(--accent-soft); }
.gx-option:has(input:checked) .gx-option__mark { border-color: var(--accent); }
.gx-option:has(input:checked) .gx-option__mark::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent);
}

/* ---- Alerts / callouts ------------------------------------------- */
.gx-alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: 13px var(--sp-4); border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--panel); font-size: 13px; color: var(--text-secondary);
}
.gx-alert i { font-size: 17px; flex: 0 0 auto; line-height: 1.4; }
.gx-alert strong { color: var(--text-primary); }
.gx-alert--info { border-color: var(--accent-border); background: var(--accent-soft); }
.gx-alert--info i { color: var(--accent); }
.gx-alert--pos { border-color: rgba(14,203,129,.4); background: var(--positive-soft); }
.gx-alert--pos i { color: var(--positive); }
.gx-alert--warn { border-color: rgba(245,166,35,.4); background: var(--warning-soft); }
.gx-alert--warn i { color: var(--warning); }
.gx-alert--neg { border-color: rgba(246,70,93,.4); background: var(--negative-soft); }
.gx-alert--neg i { color: var(--negative); }

/* ---- Copy field -------------------------------------------------- */
.gx-copy {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-3) 10px var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}
.gx-copy__val { flex: 1; min-width: 0; font-size: 13px; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gx-copy__btn {
  border: 0; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-xs);
  padding: 7px 11px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; flex: 0 0 auto;
}

/* ---- Metric grid ------------------------------------------------- */
.gx-metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.gx-metric-grid--3 { grid-template-columns: repeat(3, 1fr); }
.gx-metric {
  padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--panel);
}
.gx-metric__k { font-size: 11px; color: var(--text-muted); letter-spacing: .03em; }
.gx-metric__v { font-size: 20px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---- Progress bar (tier) --------------------------------------- */
.gx-progress { height: 6px; border-radius: var(--radius-pill); background: var(--panel-hover); overflow: hidden; }
.gx-progress__fill { height: 100%; border-radius: var(--radius-pill); background: var(--accent); transition: width .8s var(--ease); }

/* ---- Timeline (guided steps) --------------------------------- */
.gx-timeline { position: relative; padding-left: 30px; }
.gx-timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.gx-tl-step { position: relative; margin-bottom: var(--sp-4); }
.gx-tl-step:last-child { margin-bottom: 0; }
.gx-tl-step__n {
  position: absolute; left: -30px; top: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 4px var(--bg-primary);
}

/* ---- Auth pages (login / register) --------------------------- */
.gx-auth {
  position: relative; min-height: calc(100vh - var(--appbar-h));
  display: flex; flex-direction: column; align-items: center;
  padding: var(--sp-7) var(--sp-4) calc(var(--bottomnav-h) + var(--sp-8));
  overflow: hidden;
}
.gx-auth__bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image:
    radial-gradient(60% 50% at 50% 0%, var(--accent-soft), transparent 70%),
    linear-gradient(var(--border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 100% 100%, 42px 42px, 42px 42px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%);
  mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.gx-auth__inner { position: relative; z-index: 1; width: 100%; max-width: 400px; }
.gx-auth__brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: var(--sp-6); }
.gx-auth__brand h1 { margin: 14px 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.gx-auth__brand p { margin: 0; font-size: 13px; color: var(--text-muted); }
.gx-auth__card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-6); box-shadow: var(--shadow-2); }
.gx-auth__alt { display: block; text-align: center; margin-top: var(--sp-4); font-size: 13px; color: var(--text-muted); text-decoration: none; }
.gx-auth__alt b { color: var(--accent); }
.gx-auth__eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--text-muted); font-size: 17px; cursor: pointer; padding: 6px;
}

/* ---- Two-column layout on desktop --------------------------- */
@media (min-width: 900px) {
  .gx-cols { display: grid; grid-template-columns: 300px 1fr; gap: var(--sp-6); align-items: start; }
  .gx-cols__aside { position: sticky; top: calc(var(--appbar-h) + var(--sp-4)); }
}

/* ==========================================================================
   14. TRADING WORKSPACE (desktop ≥ 1024px)
   ========================================================================== */
@media (min-width: 1024px) {
  .tv-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 372px;
    align-items: start;
    gap: var(--sp-4);
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-4) var(--sp-4) var(--sp-7) !important;
  }
  .tv-page .inst-header {
    grid-column: 1 / -1;
    position: static;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  .tv-main {
    grid-column: 1; min-width: 0;
    border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
  }
  #tradingview_container { height: 560px !important; min-height: 0 !important; border-bottom: 1px solid var(--border); }
  .tv-recent { padding: var(--sp-4); }

  /* the fixed mobile order rail becomes a sticky right-column ticket */
  .tv-page .order-rail {
    position: sticky !important;
    top: calc(var(--appbar-h) + var(--sp-4));
    grid-column: 2; inset: auto;
    background: var(--panel) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md);
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    padding: var(--sp-4) !important;
  }
  .tv-page .order-rail::before {
    content: attr(data-label);
    display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: var(--sp-3);
  }
  .order-rail__btns { flex-direction: column-reverse; }
  .order-rail .gx-btn--lg { width: 100%; }
  .tv-page .fast-box { flex-wrap: wrap; }
}

/* Desktop content shouldn't hug the screen edge on wide monitors */
@media (min-width: 1280px) {
  .gx-page, .mkt-toolbar, .mkt-list { max-width: var(--content-max); margin-left: auto; margin-right: auto; }
}
