/* QuantGO Binance-Grade Trading Terminal Stylesheet (Pure UI v1.0) */
:root,
[data-theme="dark"] {
  --bg-root: #0B0E11;
  --bg-panel: #181A20;
  --bg-elevated: #1E2329;
  --bg-hover: #2B3139;
  --border-line: #2B3139;
  --text-primary: #EAECEF;
  --text-secondary: #848E9C;
  --text-muted: #5E6673;
  --accent: #F0B90B;
  --accent-bg: rgba(240, 185, 11, 0.12);
  --up: #0ECB81;
  --up-bg: rgba(14, 203, 129, 0.14);
  --down: #F6465D;
  --down-bg: rgba(246, 70, 93, 0.14);
  --info: #3B82F6;
  --champ-bar: #F0B90B;
  --champ-row: rgba(240, 185, 11, 0.08);
  --scroll-thumb: #363C45;
  --chart-grid: rgba(43, 49, 57, 0.55);
  --chart-text: #848E9C;
}

[data-theme="light"] {
  --bg-root: #F8FAFC;
  --bg-panel: #FFFFFF;
  --bg-elevated: #F1F5F9;
  --bg-hover: #E2E8F0;
  --border-line: #E2E8F0;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --accent: #4F46E5;
  --accent-bg: rgba(79, 70, 229, 0.10);
  --up: #16A34A;
  --up-bg: rgba(22, 163, 74, 0.12);
  --down: #DC2626;
  --down-bg: rgba(220, 38, 38, 0.12);
  --info: #2563EB;
  --champ-bar: #4F46E5;
  --champ-row: rgba(238, 242, 255, 0.72);
  --scroll-thumb: #CBD5E1;
  --chart-grid: rgba(226, 232, 240, 0.9);
  --chart-text: #64748B;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
  flex-shrink: 0;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 2px;
}

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-root);
}

.login-panel {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: 6px;
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: var(--accent);
  color: #0B0E11;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

[data-theme="light"] .brand-mark {
  color: #FFFFFF;
}

.login-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.login-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.allow-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-line);
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 11px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-line);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--accent);
  color: #0B0E11;
  border-color: var(--accent);
  font-weight: 700;
}

[data-theme="light"] .btn-primary {
  color: #FFFFFF;
}

.btn-primary:hover {
  filter: brightness(1.06);
  background: var(--accent);
}

.btn-danger {
  background: var(--down-bg);
  color: var(--down);
  border-color: rgba(246, 70, 93, 0.35);
}

.btn-block {
  width: 100%;
  padding: 10px 14px;
}

.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.form-group {
  margin-top: 14px;
}

.micro-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  display: block;
}

.input-box {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  background: var(--bg-root);
  border: 1px solid var(--border-line);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}

.input-box:focus {
  border-color: var(--accent);
}

.alert-box {
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 11px;
  margin-bottom: 12px;
  border: 1px solid rgba(246, 70, 93, 0.45);
  background: var(--down-bg);
  color: var(--down);
}

.divider-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
}
.divider-line::before,
.divider-line::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-line);
}

/* Main Terminal Shell */
.term-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg-root);
}

/* Top Ticker Bar */
.topbar {
  height: 48px;
  min-height: 48px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-line);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow-x: auto;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sys-select {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-line);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.pill-gold {
  background: var(--accent-bg);
  color: var(--accent);
}

.pill-up {
  background: var(--up-bg);
  color: var(--up);
}

.pill-down {
  background: var(--down-bg);
  color: var(--down);
}

.pill-muted {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.ticker-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding: 0 4px;
}

.ticker-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 0;
}

.ticker-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

.ticker-val {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.ticker-hero {
  font-size: 16px;
  font-weight: 800;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--up);
  display: inline-block;
}

.dot-off {
  background: var(--down);
}

/* Main Workspace Grid */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 1px;
  background: var(--border-line);
}

.left-col {
  display: grid;
  grid-template-rows: minmax(320px, 58%) minmax(220px, 42%);
  gap: 1px;
  min-height: 0;
  background: var(--border-line);
}

.right-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
}

/* Chart Area */
.chart-card {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-bar {
  height: 34px;
  min-height: 34px;
  border-bottom: 1px solid var(--border-line);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tf-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tf-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  cursor: pointer;
}

.tf-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.charts-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.main-chart-box {
  flex: 1 1 0%;
  min-height: 220px;
  position: relative;
}

.sub-chart-box {
  flex: 0 0 116px;
  height: 116px;
  min-height: 116px;
  border-top: 1px solid var(--border-line);
  position: relative;
}

#sub-chart {
  position: absolute;
  inset: 0;
}

.sub-chart-tag {
  position: absolute;
  top: 4px;
  left: 10px;
  z-index: 5;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  pointer-events: none;
}

/* Bottom Tabs Area */
.blotter-card {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-bar {
  height: 36px;
  min-height: 36px;
  border-bottom: 1px solid var(--border-line);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tabs-left {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-input {
  background: var(--bg-root);
  border: 1px solid var(--border-line);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 3px 7px;
  font-size: 11px;
  outline: none;
}

.mini-input:focus {
  border-color: var(--accent);
}

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 11px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-line);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-line);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr.champ-row {
  background: var(--champ-row);
  box-shadow: inset 3px 0 0 var(--champ-bar);
}

.num-right {
  text-align: right;
}

/* Right Panel */
.kpi-block {
  padding: 12px;
  border-bottom: 1px solid var(--border-line);
}

.sys-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.sys-title {
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-bottom: 10px;
}

.kpi-num {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prog-wrap {
  margin-top: 6px;
}

.prog-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.prog-track {
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.prog-fill {
  height: 100%;
  background: var(--up);
  transition: width 0.25s ease;
}

.bench-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-line);
}

.bench-cell {
  background: var(--bg-elevated);
  padding: 4px 5px;
  border-radius: 3px;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.watchlist-head {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.watchlist-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.watch-item {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 52px 76px 64px;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-line);
  cursor: pointer;
  font-size: 11px;
}

.watch-item:hover {
  background: var(--bg-hover);
}

.watch-item.active {
  background: var(--accent-bg);
}

.watch-item.champ-mark {
  box-shadow: inset 3px 0 0 var(--champ-bar);
}

.watch-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.events-block {
  height: 148px;
  min-height: 148px;
  border-top: 1px solid var(--border-line);
  display: flex;
  flex-direction: column;
}

.events-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 12px;
}

.event-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--border-line);
}

/* Modal Drawer */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-panel {
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: 6px;
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-line);
  margin-bottom: 14px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.svc-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-line);
  border-radius: 4px;
  padding: 8px 10px;
}

.c-up { color: var(--up); }
.c-down { color: var(--down); }
.c-gold { color: var(--accent); }
.c-muted { color: var(--text-secondary); }

@media (max-width: 1024px) {
  .term-root {
    height: auto;
    max-height: none;
    overflow: auto;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .left-col {
    grid-template-rows: 460px 360px;
  }
  .ops-grid {
    grid-template-columns: 1fr;
  }
}
