:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --line: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --pos: #15803d;
    --neg: #dc2626;
    --warn: #b45309;
    --info: #2563eb;
    --accent: #16a34a;
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--line);
}

html, body { background: var(--bg); color: var(--text); }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 14px; }
.num, td.num, .mono { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos) !important; }
.neg { color: var(--neg) !important; }
.muted { color: var(--muted); }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 216px; flex: 0 0 216px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: .2px; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; }
.sidebar nav a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.sidebar nav a:hover { background: #f1f5f9; color: var(--text); }
.sidebar nav a.active { background: rgba(22,163,74,.10); color: #166534; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar .ico { width: 18px; text-align: center; opacity: .85; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 4px; }
.sidebar-foot { margin-top: auto; padding: 14px 18px 18px; border-top: 1px solid var(--line); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 20px 24px 40px; }

/* status bar */
.statusbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: 10px 24px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.sb-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sb-k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.sb-spacer { flex: 1; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .6px; border: 1px solid transparent; }
.state-disarmed { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.state-armed, .state-trading { background: #dcfce7; color: #166534; border-color: #86efac; }
.state-trading { animation: pulse 2s infinite; }
.state-halted { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.state-flattening, .state-recovering { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.state-closed { background: #f1f5f9; color: var(--muted); border-color: var(--line); }
.mode-paper { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.mode-live { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(34,197,94,.18); } }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,.6); }
.dot.off { background: var(--neg); }

/* panels */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 650; margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 0 0 12px; font-weight: 650; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); }
@media (max-width: 1100px) { .g-3, .g-4, .g-main { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .g-2, .g-3, .g-4, .g-main { grid-template-columns: 1fr; } .sidebar { display: none; } .content { padding: 14px; } }

/* KPI tiles */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.panel-inset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.kpi .v { font-size: 24px; font-weight: 650; margin-top: 4px; }
.kpi .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* health cards */
.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 10px; }
.hc { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; border-left-width: 4px; }
.hc .t { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.hc .d { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.35; }
.hc.ok { border-left-color: #22c55e; } .hc.warn { border-left-color: #f59e0b; } .hc.fail { border-left-color: #ef4444; } .hc.info { border-left-color: #3b82f6; }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; padding: 1px 7px; border-radius: 6px; background: #f1f5f9; color: var(--muted); }
.tag.ok { color: var(--pos); } .tag.warn { color: var(--warn); } .tag.fail { color: var(--neg); } .tag.info { color: var(--info); }

/* banner */
.banner { border-radius: 12px; padding: 16px 20px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border: 1px solid; }
.banner .big { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.banner.armed { background: linear-gradient(90deg, #dcfce7, #f0fdf4); border-color: #86efac; }
.banner.disarmed { background: linear-gradient(90deg, #fef3c7, #fffbeb); border-color: #fcd34d; }
.banner.halted { background: linear-gradient(90deg, #fee2e2, #fef2f2); border-color: #fca5a5; }

/* tables */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--line); margin: 0; }
.table thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; border-bottom-color: var(--line); white-space: nowrap; }
.table td { vertical-align: middle; border-color: #edf1f5; }
.table-hover tbody tr:hover > * { --bs-table-bg-state: #f1f5f9; }
.stage { display: inline-block; min-width: 26px; text-align: center; padding: 1px 7px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.stage-0 { background: #f1f5f9; color: #64748b; } .stage-1 { background: #dbeafe; color: #1d4ed8; } .stage-2 { background: #dcfce7; color: #166534; } .stage-3 { background: #fef3c7; color: #92400e; }
.rbar { height: 6px; background: #e2e8f0; border-radius: 4px; overflow: hidden; min-width: 90px; }
.rbar > span { display: block; height: 100%; background: #22c55e; }
.rbar.neg > span { background: #ef4444; }
.cat { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; letter-spacing: .3px; white-space: nowrap; }
.cat-Results { background: #dbeafe; color: #1d4ed8; } .cat-OrderWin { background: #dcfce7; color: #166534; } .cat-Pledge, .cat-Regulatory { background: #fee2e2; color: #b91c1c; }
.cat-BoardMeeting { background: #ede9fe; color: #6d28d9; } .cat-CorporateAction { background: #fef9c3; color: #854d0e; } .cat-BanList { background: #fee2e2; color: #b91c1c; }
.cat-Insider, .cat-Other, .cat-BulkBlockDeal, .cat-Circular, .cat-AsmGsm { background: #f1f5f9; color: #475569; }

/* forms */
.form-control, .form-select { background-color: #fff; border-color: #cbd5e1; color: var(--text); }
.form-control:focus, .form-select:focus { background-color: #fff; color: var(--text); border-color: #4ade80; box-shadow: 0 0 0 .2rem rgba(22,163,74,.18); }
.form-label { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.form-text { color: var(--muted); }
.btn-success { background: var(--accent); border-color: var(--accent); }
.log { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; color: #334155; max-height: 360px; overflow: auto; white-space: pre-wrap; }
.log div { padding: 2px 0; border-bottom: 1px dashed var(--line); }

/* auth */
body.bare { background: radial-gradient(1200px 600px at 20% -10%, #dcfce7 0%, transparent 60%), radial-gradient(1000px 500px at 110% 110%, #dbeafe 0%, transparent 55%), var(--bg); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 16px; padding: 28px 28px 24px; box-shadow: 0 20px 60px rgba(15,23,42,.10); }
.auth-card .brand { padding: 0 0 18px; justify-content: center; font-size: 20px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

/* strategy library, scanner, symbol */
.diagram { width: 100%; height: auto; display: block; border-radius: 10px; }
.dg-ref { stroke: #94a3b8; stroke-dasharray: 5 4; stroke-width: 1.2; }
.dg-ref2 { fill: none; stroke: #2563eb; stroke-width: 1.6; stroke-dasharray: 6 4; opacity: .8; }
.dg-px { fill: none; stroke: #1e293b; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.dg-in { fill: #16a34a; stroke: #fff; stroke-width: 2; }
.dg-sl { stroke: #dc2626; stroke-width: 1.6; stroke-dasharray: 5 3; }
.dg-t { fill: #64748b; font-size: 10.5px; font-family: "Segoe UI", system-ui, sans-serif; }
.dg-t.ok { fill: #15803d; } .dg-t.bad { fill: #b91c1c; }
.explain h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 8px; font-weight: 650; }
.explain h3.pos { color: var(--pos); } .explain h3.neg { color: var(--neg); }
.explain p, .explain li { line-height: 1.55; }
.explain ol, .explain ul { padding-left: 20px; margin-bottom: 4px; }
.explain ul.checks { list-style: none; padding-left: 0; }
.explain ul.checks li::before { content: "✓ "; color: var(--pos); font-weight: 700; }
.lead-sm { font-size: 15.5px; color: var(--text); }
.pulse { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.pulse-item { display: flex; flex-direction: column; } .pulse-item .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; } .pulse-item .v { font-size: 17px; font-weight: 650; }
.sectors { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; }
.sector { font-size: 11.5px; padding: 3px 8px; border-radius: 6px; color: var(--text); white-space: nowrap; }
.strategy-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.stab { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.stab:hover { border-color: #86efac; color: var(--text); } .stab.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #f0fdf4; }
.stab .name { font-weight: 650; } .stab .meta { font-size: 11.5px; color: var(--muted); } .stab .counts { margin-top: 2px; }
.strategy-link { color: var(--text); text-decoration: none; } .strategy-link:hover { color: var(--pos); }
.info-dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font-size: 11px; font-style: italic; font-family: Georgia, serif; vertical-align: middle; margin-left: 4px; }
.scan-row.ready > td { background: rgba(34,197,94,.07); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; cursor: help; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: #f1f5f9; color: var(--muted); white-space: nowrap; }
.chip.ok { color: #166534; background: #dcfce7; } .chip.fail { color: #b91c1c; background: #fee2e2; } .chip.opt { color: #92400e; background: #fef3c7; }
.strategy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.scard { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
a.scard:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--text); }
.scard.static { background: var(--panel-2); }
.scard-name { font-size: 16px; font-weight: 650; }
.mini-sug { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; color: var(--text); text-decoration: none; background: var(--panel-2); }
.mini-sug:hover { border-color: #86efac; color: var(--text); }
.checklist { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.checklist li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.checklist .mark { width: 16px; font-weight: 700; } .checklist li.ok .mark { color: var(--pos); } .checklist li.fail .mark { color: var(--neg); } .checklist li.opt .mark { color: var(--warn); }
.offcanvas { background: var(--panel); color: var(--text); border-left: 1px solid var(--line); }
.explain .diagram { max-width: 560px; }
.scard .diagram { max-height: 150px; }
.checklist .mark { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; background: var(--muted); }
.checklist li.ok .mark { background: #22c55e; } .checklist li.fail .mark { background: #ef4444; } .checklist li.opt .mark { background: #f59e0b; }
.mode-cards { display: grid; gap: 8px; }
.mode-card { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer; }
.mode-card.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #f0fdf4; }
.split-bar { display: flex; height: 30px; border-radius: 8px; overflow: hidden; font-size: 12px; font-weight: 650; }
.split-bar span { display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; }
.split-bar .intra { background: #dbeafe; color: #1d4ed8; } .split-bar .swing { background: #dcfce7; color: #166534; }

/* ---- Sections: LIVE (real money) / PAPER (simulated) / BACKTEST (history only) ---- */
.sidebar nav { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.sidebar nav a { padding: 6px 10px; }
.nav-group { font-size: 10.5px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); margin: 12px 4px 3px; padding: 3px 6px; border-left: 3px solid var(--line); }
.nav-group:first-child { margin-top: 2px; }
.nav-group.paper { color: #0369a1; border-left-color: #38bdf8; }
.nav-group.live { color: #b91c1c; border-left-color: #ef4444; }
.nav-group.bt { color: #6d28d9; border-left-color: #a78bfa; }
.chip { display: inline-block; padding: 4px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; letter-spacing: .5px; border: 1px solid var(--line); text-decoration: none; white-space: nowrap; }
.chip.off { background: #f1f5f9; color: var(--muted); }
.chip-live.on { background: #dc2626; color: #fff; border-color: #b91c1c; animation: pulse 2s infinite; }
.chip-paper.on { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.sec-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .7px; vertical-align: middle; margin-right: 6px; }
.sec-tag.paper { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.sec-tag.live { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.sec-tag.bt { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }
.panel.sec.live, .panel.live-panel { border-left: 4px solid #ef4444; }
.panel.sec.paper { border-left: 4px solid #38bdf8; }
.panel.sec.bt { border-left: 4px solid #a78bfa; }
.banner.live-banner.halted { background: linear-gradient(90deg, #fee2e2, #fef2f2); border-color: #fca5a5; }
.banner.paper-banner.armed { background: linear-gradient(90deg, #dbeafe, #eff6ff); border-color: #93c5fd; }
.sec-card { display: block; text-decoration: none; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.sec-card:hover { background: var(--panel-2); color: var(--text); }
.sec-card.live { border-left: 4px solid #ef4444; }
.sec-card.paper { border-left: 4px solid #38bdf8; }
.sec-card .v { font-size: 20px; font-weight: 650; margin-top: 8px; }
.sec-card .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
ul.plain { margin: 0; padding-left: 18px; color: var(--muted); }
ul.plain li { margin-bottom: 8px; }
tr.dim td { opacity: .62; }
