/* QuantSetu — trading-desk UI. Dark by default, light via [data-theme="light"]. */
:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18202b;
  --line: #243041;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #f5a524;          /* saffron */
  --accent-ink: #1a1203;
  --up: #22c58b;
  --down: #f2555a;
  --info: #5aa9ff;
  --warn: #f5a524;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #f0f3f7; --line: #dbe2ea; --text: #111827; --muted: #5b6878;
  --accent: #c97d00; --accent-ink: #ffffff; --up: #0f9d6b; --down: #d63a40; --info: #1f6feb;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
a { color: var(--info); }
.num, td.n, .kpi .v, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- shell */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.top .grow { flex: 1; }
.page { padding: 20px 24px 60px; max-width: 1500px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.badge.demo { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.badge.live { color: var(--up); border-color: color-mix(in srgb, var(--up) 40%, transparent); }
.badge.err { color: var(--down); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- building blocks */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hr { height: 1px; background: var(--line); margin: 12px 0; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
textarea { font-family: var(--mono); font-size: 13px; min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; border-color: transparent; }
input[type=checkbox] { width: auto; }
.field { min-width: 0; }
.field.err textarea, .field.err input { border-color: var(--down); }
.field .msg { color: var(--down); font-size: 12px; margin-top: 4px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.buy { background: var(--up); color: #04150e; border-color: transparent; }
.btn.sell { background: var(--down); color: #1d0405; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); white-space: nowrap; }
td.n, th.n { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
.tablewrap { overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.note { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.note.err { background: color-mix(in srgb, var(--down) 10%, var(--panel)); border-color: color-mix(in srgb, var(--down) 35%, transparent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { background: none; border: none; color: var(--muted); padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; }
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.chips input { border: none; background: transparent; padding: 3px; width: 140px; flex: 1; }
.chips input:focus { outline: none; }
.varrow { display: grid; grid-template-columns: 160px 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.varrow input { font-family: var(--mono); }
.ref { max-height: 420px; overflow: auto; font-size: 12px; }
.ref .item { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ref code { font-family: var(--mono); color: var(--accent); cursor: copy; }
.chart { height: 420px; width: 100%; border-radius: 8px; overflow: hidden; }
.chart.sm { height: 240px; }
.log { font-family: var(--mono); font-size: 12px; max-height: 220px; overflow: auto; }
.log div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; max-width: 720px; width: 100%; max-height: 85vh; overflow: auto; padding: 20px; }
.toast { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast div { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toast div.err { border-left-color: var(--down); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { max-width: 420px; width: 100%; padding: 28px; }
.hero { font-size: 13px; color: var(--muted); margin: 6px 0 18px; }
.ticket { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); }
.legs .leg { display: grid; grid-template-columns: 90px 90px 90px 80px auto; gap: 6px; margin-bottom: 6px; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 0.8s linear infinite; display: inline-block; }
@keyframes s { to { transform: rotate(360deg); } }
.hide { display: none !important; }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px; z-index: 20; border-right: none; border-top: 1px solid var(--line); }
  .side .brand, .side .foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px; }
  .top, .page { padding-left: 16px; padding-right: 16px; }
  .page { padding-bottom: 90px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .varrow { grid-template-columns: 1fr; }
  .chart { height: 320px; }
  .legs .leg { grid-template-columns: 1fr 1fr; }
}
