:root {
  --bg: #060a12;
  --panel: rgba(13, 20, 36, 0.72);
  --panel-solid: #0d1424;
  --line: rgba(120, 160, 255, 0.14);
  --text: #e8eefb;
  --muted: #7d8fb2;
  --accent: #22e6a4;
  --accent2: #4da3ff;
  --danger: #ff5c7a;
  --warn: #ffcf5c;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

.bg-grid {
  position: fixed; inset: 0; z-index: -3;
  background-image:
    linear-gradient(rgba(77,163,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77,163,255,.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 20%, transparent 75%);
}
.aurora { position: fixed; border-radius: 50%; filter: blur(120px); z-index: -2; opacity: .5; }
.a1 { width: 480px; height: 480px; background: rgba(34,230,164,.16); top: -160px; right: -80px; animation: drift 14s ease-in-out infinite alternate; }
.a2 { width: 420px; height: 420px; background: rgba(77,163,255,.14); bottom: -140px; left: -60px; animation: drift 18s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translate(0,0); } to { transform: translate(60px,40px); } }

/* ---- AUTH ---- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.logo { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.logo-mark {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #04100b;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 30px rgba(34,230,164,.4);
}
.logo-name { font-size: 22px; font-weight: 700; letter-spacing: .5px; }
.logo-sub { display: block; color: var(--muted); font-size: 12px; }
.logo.small { margin-bottom: 20px; }
.logo.small .logo-mark { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: rgba(255,255,255,.04); padding: 6px; border-radius: 12px; margin-bottom: 22px; }
.auth-tab { padding: 10px; border: 0; background: transparent; color: var(--muted); font-family: inherit; font-weight: 600; border-radius: 9px; cursor: pointer; }
.auth-tab.active { background: var(--panel-solid); color: var(--text); box-shadow: 0 4px 14px rgba(0,0,0,.4); }

form label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 1px; }
input, select {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 14px; outline: none;
  transition: border .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,230,164,.15); }

.btn-primary {
  width: 100%; margin-top: 20px; padding: 13px; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04100b; font-family: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform .15s, box-shadow .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(34,230,164,.35); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.auth-error { margin-top: 14px; padding: 10px 14px; background: rgba(255,92,122,.12); border: 1px solid rgba(255,92,122,.3); color: var(--danger); border-radius: 10px; font-size: 13px; }
.auth-note { margin-top: 20px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dot-ok { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* ---- APP LAYOUT ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; padding: 22px 16px; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: rgba(8,12,24,.6); backdrop-filter: blur(12px);
  position: sticky; top: 0; height: 100vh;
}
nav { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 0; background: transparent; color: var(--muted); font-family: inherit; font-size: 14px; font-weight: 600;
  border-radius: 10px; cursor: pointer; text-align: left; transition: all .18s;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.nav-item.active { color: var(--text); background: rgba(34,230,164,.12); box-shadow: inset 0 0 0 1px rgba(34,230,164,.35); }
.nav-ico { font-size: 16px; }

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 14px; }
.user-chip { display: flex; align-items: center; justify-content: space-between; color: var(--text); font-weight: 600; font-size: 14px; }
.link-btn { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 12px; font-family: inherit; }

.main { flex: 1; padding: 26px 34px; max-width: 1100px; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.topbar h1 { font-size: 26px; font-weight: 700; }
.view-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: rgba(34,230,164,.1); border: 1px solid rgba(34,230,164,.3); color: var(--accent);
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,230,164,.5);} 50% { opacity: .4; box-shadow: 0 0 0 6px rgba(34,230,164,0);} }
.pill.off { background: rgba(255,92,122,.1); border-color: rgba(255,92,122,.3); color: var(--danger); }
.pill.off .pulse { background: var(--danger); }

.view { display: none; }
.view.active { display: block; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

/* ---- KPI ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; backdrop-filter: blur(10px);
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 600; margin-top: 8px; }
.kpi-trend { font-size: 12px; color: var(--muted); margin-top: 6px; }
.green { color: var(--accent); }
.red { color: var(--danger); }

/* ---- PANELS ---- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 22px; backdrop-filter: blur(10px);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h3 { font-size: 16px; font-weight: 600; }
.panel-badge {
  font-size: 11px; padding: 4px 10px; border-radius: 999px; font-weight: 600;
  background: rgba(77,163,255,.12); color: var(--accent2); border: 1px solid rgba(77,163,255,.3);
}
canvas { width: 100%; }

/* ---- TABLE ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid rgba(120,160,255,.07); font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.tbl tr:hover td { background: rgba(255,255,255,.03); }

.badge-side { padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-side.Buy { background: rgba(34,230,164,.15); color: var(--accent); }
.badge-side.Sell { background: rgba(255,92,122,.15); color: var(--danger); }

/* ---- BOT FORM / LIST ---- */
.bot-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
.field-hint { font-size: 11px; color: var(--accent2); margin-top: 6px; line-height: 1.4; }
.bot-form .btn-primary { grid-column: 1 / -1; margin-top: 6px; }

.bot-list { display: flex; flex-direction: column; gap: 12px; }
.bot-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
}
.bot-card .bc-name { font-weight: 600; font-size: 15px; }
.bc-state {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; vertical-align: middle;
  background: rgba(255,255,255,.06); color: var(--muted);
}
.bc-state.on { background: rgba(34,230,164,.14); color: var(--accent); box-shadow: 0 0 0 1px rgba(34,230,164,.35); }
.bot-card .bc-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.bc-actions { display: flex; gap: 8px; align-items: center; }
.btn-mini {
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.05);
  color: var(--text); font-family: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer; transition: all .15s;
}
.btn-mini:hover { background: rgba(255,255,255,.12); }
.btn-mini.go { border-color: rgba(34,230,164,.4); color: var(--accent); }
.btn-mini.stop { border-color: rgba(255,92,122,.4); color: var(--danger); }
.btn-mini.danger { border-color: rgba(255,92,122,.3); color: var(--danger); }

/* ---- REASONING ---- */
.reason-summary { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.reason-summary b { font-family: 'JetBrains Mono', monospace; }
.reason-box { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-height: 520px; overflow-y: auto; padding-right: 4px; }
.reason-card {
  background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.rc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.rc-sym { font-weight: 700; font-family: 'JetBrains Mono', monospace; font-size: 14px; }
.rc-price { color: var(--muted); font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.rc-dec { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; letter-spacing: .5px; }
.rc-dec.long { background: rgba(34,230,164,.15); color: var(--accent); }
.rc-dec.short { background: rgba(255,92,122,.15); color: var(--danger); }
.rc-dec.skip { background: rgba(125,143,178,.15); color: var(--muted); }
.rc-ind { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 8px; }
.rc-bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.06); overflow: hidden; margin-bottom: 10px; }
.rc-bar-fill { height: 100%; border-radius: 99px; }
.rc-bar-fill.long { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.rc-bar-fill.short { background: linear-gradient(90deg, var(--danger), #ff8fa6); }
.rc-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.rc-list li { font-size: 12px; padding-left: 16px; position: relative; line-height: 1.4; }
.rc-list li.ok::before { content: '◆'; position: absolute; left: 0; color: var(--accent); font-size: 9px; top: 3px; }
.rc-list li.no { color: var(--warn); }
.rc-list li.no::before { content: '◈'; position: absolute; left: 0; color: var(--warn); font-size: 9px; top: 3px; }

@media (max-width: 900px) {
  .reason-box { grid-template-columns: 1fr; }
}

/* ---- LIVE ---- */
.live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.feed-item {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
.feed-item .fi-main { font-weight: 600; }
.feed-item .fi-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.fi-pnl.green { font-weight: 700; }
.fi-pnl.red { font-weight: 700; }
.flash { animation: flash .6s ease; }
@keyframes flash { 0% { background: rgba(34,230,164,.25); } 100% { background: rgba(255,255,255,.03); } }
.flash.red { animation: flashRed .6s ease; }
@keyframes flashRed { 0% { background: rgba(255,92,122,.3); } 100% { background: rgba(255,255,255,.03); } }

/* ---- WEIGHTS ---- */
.weights-box { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.weight-card { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.weight-card .wc-sym { font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.weight-card .wc-n { color: var(--muted); font-size: 11px; }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.06); margin-top: 10px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .live-grid, .bot-form { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px; }
}
