/* FoxAlgo design system -- shared by the admin panel and the member terminal.
   Dark first: traders stare at this for hours, and both sites should feel like
   one product. No external fonts or CDNs, so nothing leaks and nothing breaks
   when a network is slow. */

:root {
  --bg:        #0b0e14;
  --surface:   #131824;
  --surface-2: #1a2131;
  --surface-3: #222b3d;
  --border:    #232c3e;
  --border-2:  #2f3a50;
  --text:      #e7eaf1;
  --text-2:    #aab3c5;
  --muted:     #7e879b;
  --accent:    #ff7a29;
  --accent-2:  #ff9a5c;
  --accent-dim:rgba(255,122,41,.12);
  --up:        #17c98a;
  --down:      #f2555f;
  --blue:      #4d8dff;
  --amber:     #f7b955;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 620; letter-spacing: -.02em; line-height: 1.25; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
small { font-size: .8rem; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); }
.dim { color: var(--text-2); }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--surface);
  border-right: 1px solid var(--border); padding: 18px 12px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 9px; padding: 4px 10px 20px; }
.logo b { font-size: 1.15rem; letter-spacing: -.03em; }
.logo .mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #ff5b7a); color: #fff;
  font-weight: 800; font-size: 15px; flex: 0 0 28px;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: .92rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-dim); color: var(--accent-2); }
.nav .sep { margin: 12px 11px 6px; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; font-size: .8rem; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.topbar h1 { margin: 0; }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card > h2, .card > h3 { margin-top: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: -18px -18px 16px; padding: 14px 18px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; }
.stat .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.stat .value { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em;
  font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .78rem; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 99px; font-size: .74rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge.ok    { background: rgba(23,201,138,.14); color: var(--up); }
.badge.warn  { background: rgba(247,185,85,.15); color: var(--amber); }
.badge.bad   { background: rgba(242,85,95,.14); color: var(--down); }
.badge.info  { background: rgba(77,141,255,.14); color: var(--blue); }
.badge.accent{ background: var(--accent-dim); color: var(--accent-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  flex: 0 0 7px; }
.dot.live { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ----------------------------------------------------------------- forms */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  font-size: .95rem; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder { color: var(--muted); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.field { margin-bottom: 14px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 12px; }
.check input { margin-top: 3px; flex: 0 0 auto; }
.check label { margin: 0; font-weight: 500; color: var(--text); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 17px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: #fff; font-weight: 600; font-size: .9rem;
  cursor: pointer; font-family: inherit; white-space: nowrap; transition: filter .12s;
}
.btn:hover { filter: brightness(1.08); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { background: var(--down); }
.btn.buy { background: var(--up); } .btn.sell { background: var(--down); }
.btn.sm { padding: 6px 11px; font-size: .8rem; }
.btn.wide { width: 100%; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- alerts */
.alert { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: .9rem; border: 1px solid; display: flex; gap: 9px; align-items: flex-start; }
.alert.ok   { background: rgba(23,201,138,.09); border-color: rgba(23,201,138,.3); color: #7ee9c0; }
.alert.err  { background: rgba(242,85,95,.09); border-color: rgba(242,85,95,.3); color: #ffa8ad; }
.alert.warn { background: rgba(247,185,85,.09); border-color: rgba(247,185,85,.3); color: #ffd08a; }
.alert.info { background: rgba(77,141,255,.08); border-color: rgba(77,141,255,.28); color: #a8c6ff; }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left; padding: 9px 14px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 2rem; margin-bottom: 8px; opacity: .5; }

/* ------------------------------------------------------------ auth pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1000px 500px at 50% -10%, rgba(255,122,41,.10), transparent 70%), var(--bg); }
.auth { width: 100%; max-width: 400px; }
.auth .brand { text-align: center; margin-bottom: 22px; }
.auth .brand .mark { width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 12px;
  display: grid; place-items: center; font-size: 22px; font-weight: 800; color: #fff;
  background: linear-gradient(140deg, var(--accent), #ff5b7a); }
.auth .brand b { font-size: 1.4rem; letter-spacing: -.03em; display: block; }
.auth .brand span { color: var(--muted); font-size: .85rem; }
.auth .card { padding: 24px; box-shadow: var(--shadow); }
.auth-foot { text-align: center; margin-top: 16px; font-size: .84rem; color: var(--muted); }

/* --------------------------------------------------------------- helpers */
.pill-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px;
  border-radius: 10px; overflow-x: auto; }
.pill-tabs button {
  flex: 1; padding: 8px 14px; border: none; background: transparent; color: var(--text-2);
  border-radius: 7px; font-weight: 600; font-size: .85rem; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.pill-tabs button.on { background: var(--surface-3); color: var(--text); }
.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border-2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mobile-only { display: none; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: sticky; top: 0; z-index: 50;
    flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .logo { padding: 0; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; flex: 1;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 7px 11px; font-size: .85rem; }
  .nav .sep, .sidebar-foot { display: none; }
  .main { padding: 16px 14px 80px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .card { padding: 15px; }
  .card-head { margin: -15px -15px 13px; padding: 12px 15px; }
  .table-wrap { margin: 0 -15px -15px; }
  th, td { padding: 9px 12px; }
  .stat .value { font-size: 1.28rem; }
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }
}
@media (max-width: 420px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
}


/* --------------------------------------------------------------- light mode
   The whole palette is variables, so a theme is a variable swap and nothing
   else has to know which one is active. */
html[data-theme="light"] {
  --bg:        #f5f6f9;
  --surface:   #ffffff;
  --surface-2: #f1f3f7;
  --surface-3: #e5e8ef;
  --border:    #e2e6ee;
  --border-2:  #d2d8e4;
  --text:      #16202f;
  --text-2:    #4a5468;
  --muted:     #78829a;
  --accent:    #e8620c;
  --accent-2:  #c9520a;
  --accent-dim:rgba(232,98,12,.10);
  --up:        #0f9f6e;
  --down:      #d92d3c;
  --blue:      #2f6fdd;
  --amber:     #b7791f;
  --shadow:    0 4px 20px rgba(20,30,50,.10);
}
html[data-theme="light"] body { color-scheme: light; }
html[data-theme="light"] .auth-wrap {
  background: radial-gradient(1000px 500px at 50% -10%, rgba(232,98,12,.09), transparent 70%), var(--bg);
}
html[data-theme="light"] .sidebar,
html[data-theme="light"] .term-head { box-shadow: 0 1px 0 rgba(20,30,50,.04); }
html[data-theme="light"] .chain-table td.itm { background: rgba(20,30,50,.035); }
html[data-theme="light"] .side-toggle button#t-buy.on  { color: #fff; }
html[data-theme="light"] .side-toggle button#t-sell.on { color: #fff; }
html[data-theme="light"] .swipe-thumb { color: #fff; }
