:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #0b0f17;
  --panel: #111827;
  --panel-2: #172033;
  --line: rgba(255,255,255,.09);
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #7dd3fc;
  --positive: #86efac;
  --negative: #fca5a5;
  --warning: #fcd34d;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }

body {
  min-width: 320px;
  background:
    radial-gradient(circle at 20% 0%, rgba(56,189,248,.08), transparent 28rem),
    var(--bg);
}

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, .8fr) minmax(360px, 1.4fr) minmax(180px, .7fr);
  gap: 16px;
  align-items: center;
  min-height: 72px;
  padding: 10px 18px;
  background: rgba(11,15,23,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand-block, .connection-block, .topbar-center, .summary-chip, .toolbar, .row { display: flex; align-items: center; }
.brand-block { gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(145deg, #164e63, #1e3a8a);
  font-weight: 800;
  letter-spacing: .04em;
}
.brand-title { font-weight: 800; letter-spacing: .06em; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.topbar-center { justify-content: center; gap: 10px; flex-wrap: wrap; }
.summary-chip {
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.03);
}
.summary-chip span { color: var(--muted); font-size: 12px; }
.summary-chip strong { font-size: 13px; }
.connection-block { justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 13px; }
.connection-dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(255,255,255,.03); }
.connection-dot.is-online { background: var(--positive); }
.connection-dot.is-offline { background: var(--negative); }

.workspace { display: grid; grid-template-columns: 184px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: rgba(10,14,22,.8);
}
.sidebar-spacer { flex: 1; }
.nav-button {
  border: 1px solid transparent;
  background: transparent;
  padding: 11px 12px;
  text-align: left;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
}
.nav-button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-button.is-active { color: var(--text); background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.18); }

.main-stage { min-width: 0; padding: 16px; }
.backend-banner {
  display: none;
  gap: 8px;
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid rgba(252,211,77,.25);
  border-radius: 12px;
  background: rgba(252,211,77,.06);
  color: #fde68a;
  font-size: 13px;
}
.backend-banner.is-visible { display: flex; flex-wrap: wrap; }
.view-root { min-width: 0; }

.page-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.page-title { margin: 0; font-size: 22px; }
.page-subtitle { margin-top: 5px; color: var(--muted); font-size: 13px; }
.toolbar { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.panel {
  background: linear-gradient(180deg, rgba(23,32,51,.88), rgba(17,24,39,.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  overflow: hidden;
}
.panel-header { padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.panel-body { padding: 14px; }

.trading-grid { display: grid; grid-template-columns: 250px minmax(360px, 1fr) 300px; gap: 12px; align-items: stretch; }
.watchlist { display: flex; flex-direction: column; gap: 7px; }
.watch-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255,255,255,.025);
  cursor: pointer;
}
.watch-item:hover { border-color: var(--line); }
.watch-item.is-selected { border-color: rgba(125,211,252,.35); background: rgba(125,211,252,.07); }
.watch-symbol { font-weight: 750; }
.watch-name, .muted { color: var(--muted); font-size: 12px; }
.price-up { color: var(--positive); }
.price-down { color: var(--negative); }

.chart-box {
  min-height: 420px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 36px 36px;
  color: var(--muted);
}
.chart-empty { text-align: center; max-width: 420px; line-height: 1.6; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.metric-card { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); }
.metric-card span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.metric-card strong { font-size: 15px; }

.field { display: grid; gap: 6px; margin-bottom: 10px; }
.field label { color: var(--muted); font-size: 12px; }
.input, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0c1422;
  color: var(--text);
  border-radius: 9px;
  padding: 10px 11px;
  outline: none;
}
.input:focus, .select:focus { border-color: rgba(125,211,252,.5); }

.button {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.05);
  padding: 9px 12px;
  cursor: pointer;
}
.button:hover { background: rgba(255,255,255,.09); }
.button.primary { border-color: rgba(125,211,252,.25); background: rgba(14,116,144,.34); }
.button.danger { border-color: rgba(248,113,113,.25); background: rgba(127,29,29,.28); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.full { width: 100%; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.feature-card { min-height: 160px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.025); }
.feature-card h3 { margin: 0 0 7px; }
.feature-card p { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }

.empty-state { padding: 42px 22px; text-align: center; color: var(--muted); }
.toast-root { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast { padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: #111827; box-shadow: 0 18px 45px rgba(0,0,0,.35); }
.toast.error { border-color: rgba(248,113,113,.35); }
.toast.success { border-color: rgba(134,239,172,.35); }

@media (max-width: 1180px) {
  .trading-grid { grid-template-columns: 220px minmax(320px,1fr); }
  .order-panel { grid-column: 1 / -1; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-center { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 72px;
    z-index: 15;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px;
  }
  .sidebar-spacer { display: none; }
  .nav-button { white-space: nowrap; }
  .main-stage { padding: 12px; }
  .trading-grid { grid-template-columns: 1fr; }
  .order-panel { grid-column: auto; }
  .cards-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .toolbar { justify-content: flex-start; }
}
