/* ===== Design tokens: clean light dashboard (dark is optional) ============== */
:root {
  --bg: #eef0f8;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --surface-3: #eaecf5;
  --border: #d4d8e8;
  --border-strong: #b8bed4;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --grad: linear-gradient(135deg, #2563eb, #6d28d9);
  --glow: rgba(109, 40, 217, 0.10);
  --green: #15803d;
  --green-soft: rgba(22, 163, 74, 0.09);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.08);
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.1);
  --ema-fast: #d97706;
  --ema-slow: #7c3aed;
  --sidebar-bg:
    radial-gradient(420px 320px at 100% 0%, rgba(139, 92, 246, .45), transparent 65%),
    radial-gradient(380px 360px at 0% 100%, rgba(14, 165, 233, .28), transparent 65%),
    linear-gradient(170deg, #0b1437 0%, #1e2a78 58%, #3b1c7a 100%);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 232px;
  --topbar-h: 56px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1017;
  --surface: #121821;
  --surface-2: #161d28;
  --surface-3: #1c2532;
  --border: #232d3b;
  --border-strong: #2f3b4d;
  --text: #e6edf5;
  --text-2: #aab6c5;
  --muted: #7d8a9c;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.13);
  --red: #f05252;
  --red-soft: rgba(240, 82, 82, 0.13);
  --amber: #f5a524;
  --amber-soft: rgba(245, 165, 36, 0.14);
  --ema-fast: #f5a524;
  --ema-slow: #a78bfa;
  --glow: rgba(139, 92, 246, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ===== Base =========================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.01em; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== App shell: sidebar + main column ================================ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 40;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: var(--sidebar-bg); border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 4px 8px 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 4px 10px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px; color: var(--text-2); font-weight: 550; white-space: nowrap;
}
.nav a svg { flex: none; opacity: .8; }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--border); }
.sidebar-foot .who { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who b { display: block; color: var(--text); font-weight: 600; }
.sidebar-foot form { margin: 0; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand { display: none; }
.topbar .spacer { flex: 1; }
.topbar .clock { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface); white-space: nowrap;
}
.pill.demo { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); background: var(--amber-soft); }
.pill.real, .pill.zerodha { color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); background: var(--green-soft); }
.pill.live { color: #fff; background: var(--red); border-color: var(--red); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }

main.page { padding: 24px 28px 48px; width: 100%; max-width: 1480px; margin: 0 auto; }
.page-intro { margin: -4px 0 18px; color: var(--muted); font-size: 13.5px; }

/* ===== Cards ============================================================= */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-h {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.card-h h2, .card-h h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-b { padding: 18px 20px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; margin: 0 0 8px; }

/* ===== Buttons & inputs ===================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 10px; font: 600 13px var(--sans);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .12s, border-color .12s, filter .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .25); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--surface); border-color: color-mix(in srgb, var(--red) 45%, transparent); color: var(--red); }
.btn.danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
dialog .btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
input, select {
  height: 36px; padding: 0 11px; border-radius: 10px; font: 500 13px var(--sans);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { padding-right: 28px; }
label.field { display: grid; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.field-err { color: var(--red); font-size: 12px; min-height: 16px; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); }
.seg button {
  height: 28px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text-2); font: 600 12.5px var(--sans); cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.seg button.win[aria-pressed="true"] { color: var(--green); }
.seg button.loss[aria-pressed="true"] { color: var(--red); }

/* ===== Filter bar ============================================================== */
.filterbar {
  position: sticky; top: var(--topbar-h); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px;
  padding: 14px 18px; margin-bottom: 16px;
}
.filter { display: grid; gap: 5px; }
.filter > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.filterbar .grow { flex: 1; }

/* ===== KPI row ===================================================================== */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.accent::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }

.metrics-strip { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 12px 18px; margin-bottom: 14px; font-size: 12.5px; color: var(--text-2); }
.metrics-strip b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* mode comparison */
.compare { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.cmp { padding: 14px 16px; cursor: pointer; text-align: left; font: inherit; color: inherit; transition: border-color .15s; }
.cmp:hover { border-color: var(--border-strong); }
.cmp.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow); }
.cmp .t { display: flex; justify-content: space-between; align-items: baseline; font-weight: 650; }
.cmp .row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.cmp .row div { font-size: 11px; color: var(--muted); }
.cmp .row b { display: block; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ===== Workspace ======================================================================== */
.workspace { display: grid; grid-template-columns: 450px minmax(0, 1fr); gap: 16px; align-items: start; }
.trade-list { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 520px; position: sticky; top: 140px; }
.trade-list .card-h small { color: var(--muted); font-weight: 500; }
.tl-scroll { overflow: auto; flex: 1; outline: none; }
table.tl { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.tl th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  text-align: left; font-size: 11px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  padding: 9px 8px; border-bottom: 1px solid var(--border);
}
table.tl td { padding: 9px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tl th.r, table.tl td.r { text-align: right; }
table.tl tbody tr { cursor: pointer; }
table.tl tbody tr:hover { background: var(--surface-2); }
table.tl tbody tr.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.dir { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 6px; font-size: 12px; font-weight: 800; }
.dir.up { background: var(--green-soft); color: var(--green); }
.dir.down { background: var(--red-soft); color: var(--red); }
.kbd-hint { font-size: 11.5px; color: var(--muted); padding: 8px 12px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
kbd { font: 600 11px var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); }

.detail { display: grid; gap: 16px; min-width: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 0; }
.meta .m { padding: 12px 18px; border-right: 1px solid var(--border); min-width: 0; }
.meta .m:last-child { border-right: 0; }
.meta .m .k { font-size: 11px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.meta .m .v { font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.badge.whip { background: var(--amber-soft); color: var(--amber); }
.badge.bull { background: var(--green-soft); color: var(--green); }
.badge.bear { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }

.chart-wrap { position: relative; }
.chart { height: 430px; }
.chart.small { height: 230px; }
.legend {
  position: absolute; left: 12px; top: 10px; z-index: 3; pointer-events: none;
  display: flex; flex-wrap: wrap; gap: 4px 14px; font: 600 12px var(--sans); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.legend .sw { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }

.costs { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.costs td { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.costs td:last-child { text-align: right; font-weight: 600; }
.costs tr.total td { border-bottom: 0; border-top: 1px solid var(--border-strong); font-weight: 750; font-size: 15px; padding-top: 10px; }
.costs tr.sub td { font-weight: 650; color: var(--text); }
.costs tr.ind td:first-child { padding-left: 14px; color: var(--text-2); }

.notes { font-size: 12.5px; color: var(--text-2); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.facts .k { font-size: 11px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.facts .v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== States ======================================================================== */
.state { display: grid; place-items: center; text-align: center; padding: 52px 20px; color: var(--text-2); }
.state h3 { margin: 12px 0 4px; color: var(--text); font-size: 16px; }
.state p { margin: 0 0 16px; max-width: 460px; }
.state .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 20px; }
.state.error .ico { background: var(--red-soft); color: var(--red); }
.skel { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 6px; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skel.line { height: 12px; margin: 10px 0; }
.skel.big { height: 26px; width: 60%; margin-top: 8px; }
.loading-bar { position: fixed; top: 0; left: 0; height: 2px; background: var(--accent); z-index: 100; transition: width .3s, opacity .3s; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 200; max-width: 420px;
  padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--surface);
  box-shadow: var(--shadow-lg); font-weight: 550;
}
.toast.err { background: var(--red); color: #fff; }
.banner { padding: 11px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 550; }
.banner::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 10px; vertical-align: 1px; }
.banner.warn { background: var(--amber-soft); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); }
.banner.err { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }
.banner.ok { background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 25%, transparent); }
.banner a { font-weight: 650; text-decoration: underline; }

/* progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }

/* generic grids */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
dl.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; margin: 0; }
dl.kv dt { color: var(--muted); white-space: nowrap; }
dl.kv dd { margin: 0; min-width: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
.scroll-y { max-height: 380px; overflow: auto; }
details.disclosure summary { cursor: pointer; padding: 14px 20px; font-weight: 650; list-style: none; display: flex; justify-content: space-between; }
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure[open] summary { border-bottom: 1px solid var(--border); }

dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; max-width: 460px; width: calc(100% - 32px); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px); }
dialog .card-b { display: grid; gap: 14px; }

/* ===== Live page: Entry / Exit signal boxes, stronger in the light theme ================= */
:root:not([data-theme="dark"]) .sig-box.entry {
  background: #dcf5e4; border-color: #6cc48b;
}
:root:not([data-theme="dark"]) .sig-box.exit {
  background: #fde2e2; border-color: #ec8a8a;
}
:root:not([data-theme="dark"]) .sig-box.entry .sig-t { color: #116b33; }
:root:not([data-theme="dark"]) .sig-box.exit .sig-t { color: #b91c1c; }

/* ===== Login page ======================================================================= */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card .card-b { padding: 26px 26px 28px; }
.login-card h1 { margin: 18px 0 2px; font-size: 20px; }
.login-card p { margin: 0 0 6px; color: var(--muted); }
.login-card .btn { height: 40px; }

/* ===== Brand theme: same blue-violet look as the login page ================================ */
body { background: radial-gradient(1100px 340px at 75% -120px, var(--glow), transparent 70%) fixed, var(--bg); }

/* gradient sidebar */
.sidebar { color: #fff; border-right: 0; overflow: hidden; box-shadow: 4px 0 24px rgba(11, 20, 55, .12); }
.sidebar::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, transparent, #000 20%, #000 80%, transparent);
}
.sidebar > * { position: relative; }
.sidebar .brand { color: #fff; }
.sidebar .brand small { color: rgba(255,255,255,.6); }
.sidebar .brand-mark { background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.sidebar .nav-label { color: rgba(255,255,255,.5); }
.sidebar .nav a { color: rgba(255,255,255,.74); }
.sidebar .nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav a.active { background: rgba(255,255,255,.15); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.sidebar .nav a.active svg { color: #a5b4fc; }
.sidebar-foot { border-top-color: rgba(255,255,255,.14); }
.sidebar-foot .who { color: rgba(255,255,255,.6); }
.sidebar-foot .who b { color: #fff; }
.sidebar .icon-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: rgba(255,255,255,.85); }
.sidebar .icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3); }

/* gradient primary buttons, like the login button */
.btn.primary { background: var(--grad); border-color: transparent; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn.primary:hover { background: var(--grad); filter: brightness(1.08); }
.loading-bar { background: var(--grad); }

/* small (i) button next to a title; its text opens in a floating pop-up next to it (placed by common.js) */
.info-btn {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: 4px; padding: 0; vertical-align: -6px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
.info-pop {
  position: fixed; z-index: 80; top: 0; left: 0; margin: 0 !important; width: min(380px, calc(100vw - 24px));
  max-height: min(60vh, 420px); overflow: auto;
  padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.55; color: var(--text-2);
  text-transform: none; letter-spacing: normal; font-weight: 400; text-align: left;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .08);
  animation: info-pop-in .12s ease-out;
}
@keyframes info-pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Order mode: Paper | Live switch, the highlighted side is the current mode */
.mode-switch {
  display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.mode-switch button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 104px; height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--text-2); font: 650 13.5px var(--sans); cursor: pointer;
}
.mode-switch button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .35; }
.mode-switch button:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.mode-switch .ms-paper[aria-pressed="true"] {
  background: var(--surface); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.mode-switch .ms-live[aria-pressed="true"] {
  background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 4px 12px rgba(220, 38, 38, .3);
}
.mode-switch button[aria-pressed="true"]::before { opacity: 1; }
.mode-switch .ms-live[aria-pressed="false"]:hover:not(:disabled) { color: var(--red); }
.mode-switch button:disabled { opacity: .45; cursor: not-allowed; }
.mode-hint { margin: 0; font-size: 12.5px; color: var(--muted); }

/* day label in the Activity log */
.log-day {
  margin: 10px 0 2px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
}
.log-day:first-child { margin-top: 0; }

/* accent bar before each card title */
.card-h h2::before {
  content: ""; display: inline-block; width: 4px; height: 14px; margin-right: 10px; border-radius: 2px;
  background: linear-gradient(180deg, #3b82f6, #7c3aed); vertical-align: -2px;
}

/* ===== Responsive ======================================================================= */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 420px minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 76px; }
  .sidebar { padding: 18px 10px; align-items: center; }
  .sidebar .brand { padding: 4px 0 18px; }
  .sidebar .brand .full, .nav a span, .nav-label, .sidebar-foot .who { display: none; }
  .nav a { justify-content: center; padding: 10px; }
  .sidebar-foot { flex-direction: column; padding: 12px 0 0; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .trade-list { position: static; height: 360px; min-height: 0; }
  .compare, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .filterbar { position: static; }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar {
    position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 4px;
    padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0 6px 0 0; }
  .nav { flex-direction: row; flex: 1; overflow-x: auto; scrollbar-width: none; }
  .nav a { padding: 8px 10px; }
  .nav a span { display: inline; }
  @media (max-width: 420px) { .nav { gap: 0; } .nav a { padding: 8px 7px; font-size: 13.5px; } }
  .nav a svg { display: none; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; flex-direction: row; gap: 6px; }
  .topbar { position: static; padding: 14px 16px 0; height: auto; border: 0; background: transparent; backdrop-filter: none; flex-wrap: wrap; }
  .topbar h1 { font-size: 20px; }
}
@media (max-width: 640px) {
  main.page { padding: 14px 16px 32px; }
  .trade-list, .filterbar { top: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 19px; }
  .chart { height: 320px; }
  .meta .m { flex: 1 1 45%; border-right: 0; border-bottom: 1px solid var(--border); }
  .cmp .row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg { overflow-x: auto; max-width: 100%; }
  .filter { max-width: 100%; }
  .card-h, .card-b { padding-left: 16px; padding-right: 16px; }
  select { padding-left: 10px; padding-right: 22px; }
}
