/* ============================================
   VELOX — Automated Trading Platform
   Design tokens + base styles
   ============================================ */

:root {
  /* Brand */
  --brand: #00B981;        /* Velox green — Robinhood/Groww feel */
  --brand-soft: #e6f8f1;
  --brand-deep: #008f63;

  /* Semantic */
  --up: #00B981;
  --down: #F43F5E;
  --up-soft: rgba(0,185,129,.12);
  --down-soft: rgba(244,63,94,.12);
  --warn: #F59E0B;
  --info: #3B82F6;

  /* Surfaces (light) */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F2F4F7;
  --surface-3: #EAEDF2;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  /* Text (light) */
  --text: #0F1419;
  --text-2: #4B5563;
  --text-3: #8A93A0;
  --text-inv: #FFFFFF;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Roboto Mono", ui-monospace, monospace;

  /* Geometry */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(15,20,25,.04), 0 1px 1px rgba(15,20,25,.03);
  --shadow: 0 1px 3px rgba(15,20,25,.06), 0 4px 16px rgba(15,20,25,.04);
  --shadow-lg: 0 8px 28px rgba(15,20,25,.10);

  /* Layout */
  --side: 232px;
  --topbar: 56px;
}

[data-theme="dark"] {
  --bg: #0B0E13;
  --surface: #11151C;
  --surface-2: #161B25;
  --surface-3: #1E2530;
  --border: #232A36;
  --border-strong: #2C3543;

  --text: #ECEEF1;
  --text-2: #A4ADBA;
  --text-3: #6B7585;
  --text-inv: #0B0E13;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.45);

  --up-soft: rgba(0,185,129,.16);
  --down-soft: rgba(244,63,94,.16);
}

/* Accent variants */
[data-accent="violet"] { --brand: #7C3AED; --brand-soft: #EDE7FE; --brand-deep: #5B21B6; }
[data-accent="blue"]   { --brand: #2563EB; --brand-soft: #DBEAFE; --brand-deep: #1D4ED8; }
[data-accent="orange"] { --brand: #EA580C; --brand-soft: #FFEDD5; --brand-deep: #C2410C; }
[data-theme="dark"][data-accent="violet"] { --brand-soft: rgba(124,58,237,.16); }
[data-theme="dark"][data-accent="blue"]   { --brand-soft: rgba(37,99,235,.16); }
[data-theme="dark"][data-accent="orange"] { --brand-soft: rgba(234,88,12,.16); }
[data-theme="dark"] { --brand-soft: rgba(0,185,129,.16); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============================================
   App shell
   ============================================ */
.app {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.side-brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--brand);
  display: grid; place-items: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.04em;
}
.side-brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.side-brand-tag {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.side-nav {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}
.side-section {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 12px 6px;
}
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.side-item:hover { background: var(--surface-2); color: var(--text); }
.side-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.side-item .ico { width: 18px; height: 18px; flex-shrink: 0; }
.side-item .badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--up);
  color: white;
  padding: 2px 6px;
  border-radius: 99px;
  font-family: var(--font-mono);
}
.side-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.side-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.side-user-name { font-size: 13px; font-weight: 600; }
.side-user-email { font-size: 11px; color: var(--text-3); }

/* Topbar */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar-tickers {
  display: flex;
  gap: 18px;
  margin-left: auto;
  font-size: 12.5px;
  align-items: center;
}
.tt-name { color: var(--text-3); font-weight: 600; font-size: 11px; letter-spacing: .02em; text-transform: uppercase; }
.tt-val { font-weight: 600; font-family: var(--font-mono); }
.tt-chg { font-size: 11px; font-weight: 600; font-family: var(--font-mono); }
.tt-chg.up { color: var(--up); }
.tt-chg.down { color: var(--down); }
.topbar-icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-2);
  position: relative;
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar-icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--down);
  border: 2px solid var(--surface);
}
.market-status {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--up-soft);
  color: var(--up);
  font-size: 11px;
  font-weight: 600;
}
.market-status .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 0 var(--up);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0,185,129,.6); }
  70% { box-shadow: 0 0 0 8px rgba(0,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,185,129,0); }
}

/* Page container */
.page {
  padding: 24px;
  max-width: 1480px;
  margin: 0 auto;
  width: 100%;
}
.page h2.page-title {
  margin: 0 0 4px 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-sub {
  color: var(--text-3);
  font-size: 13px;
  margin-bottom: 22px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-3);
  margin-left: auto;
  letter-spacing: .04em;
}

/* Generic flex/stack */
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; gap: 14px; }

/* Buttons */
.btn {
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s, transform .06s, color .12s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-buy { background: var(--up); color: white; }
.btn-buy:hover { filter: brightness(1.08); }
.btn-sell { background: var(--down); color: white; }
.btn-sell:hover { filter: brightness(1.08); }
.btn-ghost { color: var(--text-2); padding: 6px 10px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }

/* Pills / chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
}
.chip.up { background: var(--up-soft); color: var(--up); }
.chip.down { background: var(--down-soft); color: var(--down); }
.chip.warn { background: rgba(245,158,11,.12); color: var(--warn); }
.chip.info { background: rgba(59,130,246,.12); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
}
.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }

/* Live tick flash */
.tick-flash-up { animation: flashUp .55s ease-out; }
.tick-flash-down { animation: flashDown .55s ease-out; }
@keyframes flashUp {
  0% { background-color: var(--up-soft); }
  100% { background-color: transparent; }
}
@keyframes flashDown {
  0% { background-color: var(--down-soft); }
  100% { background-color: transparent; }
}

/* KPI tiles */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.kpi-label {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}
.kpi-foot { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.kpi-foot.up { color: var(--up); }
.kpi-foot.down { color: var(--down); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input, .select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
.input:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* Toasts */
.toast-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  pointer-events: auto;
  animation: toastIn .26s ease-out;
}
.toast.up { border-left-color: var(--up); }
.toast.down { border-left-color: var(--down); }
.toast.warn { border-left-color: var(--warn); }
.toast.info { border-left-color: var(--info); }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-body { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.toast-time { font-size: 10.5px; color: var(--text-3); margin-top: 4px; font-family: var(--font-mono); }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Skeleton sparkline */
.spark { width: 64px; height: 22px; }

/* Login screen */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-left {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: white;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-left::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.10), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,.15), transparent 50%);
  pointer-events: none;
}
.login-left > * { position: relative; z-index: 1; }
.login-right {
  background: var(--surface);
  display: grid;
  place-items: center;
  padding: 32px;
}
.login-card { width: 100%; max-width: 380px; }

/* Misc */
.hr { height: 1px; background: var(--border); border: none; margin: 0; }
.muted { color: var(--text-3); }
.text-right { text-align: right; }
.text-up { color: var(--up); }
.text-down { color: var(--down); }
.text-brand { color: var(--brand); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Responsive — collapse sidebar to icons under 1100px (kept simple for prototype) */
@media (max-width: 1100px) {
  :root { --side: 64px; }
  .side-brand-name, .side-brand-tag, .side-item span:not(.ico):not(.badge), .side-section, .side-user-name, .side-user-email { display: none; }
  .side-item { justify-content: center; }
  .side-foot { justify-content: center; }
}
