/* System 2 · soft light design (from SYSTEM2_MOCKUP). Loaded last; light only.
   Warm paper background, white cards, soft sage / coral / periwinkle accents, bold type, mono numbers. */
:root, :root[data-theme="light"] {
    color-scheme: light;
    --bg: #FFFFFF;
    --bg-subtle: #FAF9F6;
    --bg-hover: #F3F1EC;
    --border: #ECE8DF;
    --border-strong: #E0DACD;
    --text: #1B2130;
    --text-muted: #636B7D;
    --blue: #5B6BEE;
    --blue-hover: #4757DC;
    --blue-soft: #ECEEFE;
    --green: #1C8560;
    --green-soft: #E3F4EB;
    --red: #BE4339;
    --red-soft: #FCEAE6;
    --orange: #C98A1B;
    --orange-soft: #FDF2DA;
    --paper: #F5F3EE;
    --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --radius: 8px;
    --radius-lg: 14px;
    --toolbar-h: 60px;
    --shadow: 0 12px 40px -12px rgba(27, 33, 48, .22), 0 2px 8px rgba(27, 33, 48, .06);
}
body, body:not(.theme-dark) {
    background: var(--paper);
    --bg-dashboard: #F5F3EE;
    --dash-card-bg: #FFFFFF;
    --dash-card-border: #ECE8DF;
    --dash-card-subtle: #FAF9F6;
    --dash-text-head: #1B2130;
    --dash-text-body: #3F4859;
    --dash-text-muted: #636B7D;
    --dash-accent-blue: #5B6BEE;
    --dash-accent-bg: #ECEEFE;
    --dash-green: #1C8560;
    --dash-green-bg: #E3F4EB;
    --dash-red: #BE4339;
    --dash-red-bg: #FCEAE6;
    --dash-amber: #9A620A;
    --dash-amber-bg: #FDF2DA;
}

/* ---------- top bar ---------- */
.toolbar { background: var(--bg); border-bottom: 1px solid var(--border); gap: 8px; padding: 0 14px; }
.toolbar .tool-btn { border-radius: 10px; font-weight: 700; }
.toolbar .tool-btn[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); }
#strategy-btn {
    height: 42px; padding: 0 12px; border: 1px solid var(--border); background: var(--bg-subtle); border-radius: 14px;
}
#strategy-btn .btn-text { font-weight: 800; letter-spacing: -.01em; }
.candle-timer-chip { border-radius: 999px; background: var(--paper); border: 0; font-weight: 700; }

/* running trade / status strip (bot_toolbar.js) */
.tb-live-trade {
    display: inline-flex !important; align-items: center !important; gap: 8px !important; height: 30px !important; padding: 0 10px 0 6px !important; min-width: 0 !important; max-width: 480px !important; flex: 0 1 auto !important;
    border: 1px solid var(--border) !important; border-radius: 6px !important; background: var(--bg-subtle) !important; color: var(--text) !important; box-shadow: 0 1px 2px rgba(0,0,0,0.03) !important;
}
.tb-live-trade[hidden] { display: none !important; }
.tb-live-trade.is-live { background: var(--blue-soft); border-color: rgba(91, 107, 238, .35); }
.tb-live-trade .ls-badge {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 10px; flex: none;
    font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: var(--bg); color: var(--text-muted);
    box-shadow: 0 1px 2px rgba(27, 33, 48, .06);
}
.tb-live-trade .ls-badge i { width: 7px; height: 7px; border-radius: 50%; background: #A2A8B4; }
.tb-live-trade.is-scan .ls-badge i { background: var(--green); animation: s2pulse 1.6s infinite; }
.tb-live-trade.is-live .ls-badge { background: var(--blue); color: #fff; }
.tb-live-trade.is-live .ls-badge i { background: #fff; animation: s2pulse 1.2s infinite; }
.tb-live-trade .ls-main { display: inline-flex !important; flex-direction: row !important; align-items: center !important; gap: 5px !important; min-width: 0 !important; flex: 0 1 auto !important; line-height: 1 !important; white-space: nowrap !important; }
.tb-live-trade .ls-main b { font-size: 12px !important; font-weight: 750 !important; white-space: nowrap !important; }
.tb-live-trade .ls-main small { font-size: 10.5px !important; color: var(--text-muted) !important; font-weight: 600 !important; white-space: nowrap !important; display: inline !important; }
.tb-live-trade .ls-pnl { display: inline-flex !important; flex-direction: row !important; align-items: center !important; gap: 5px !important; line-height: 1 !important; flex: none !important; font-family: var(--font-mono) !important; white-space: nowrap !important; }
.tb-live-trade .ls-pnl b { font-size: 14px; font-weight: 700; }
.tb-live-trade .ls-pnl small { font-size: 10.5px; color: var(--text-muted); font-family: var(--font-sans); font-weight: 600; }
.tb-live-trade .ls-pnl.up b, .tb-live-trade .ls-pnl.up small { color: var(--green); }
.tb-live-trade .ls-pnl.down b, .tb-live-trade .ls-pnl.down small { color: var(--red); }
@keyframes s2pulse { 50% { opacity: .35; } }

.tb-others { display: flex; gap: 6px; flex: none; }
.tb-other {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg); font: 800 12px var(--font-sans); color: var(--blue);
}
.tb-other i { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: s2pulse 1.2s infinite; }
.tb-other b { font-family: var(--font-mono); font-size: 11.5px; }
.tb-other b.up { color: var(--green); } .tb-other b.down { color: var(--red); }

/* Upstox login badge */
.upstox-badge {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; flex: none;
    font: 700 11.5px var(--font-sans); text-decoration: none; white-space: nowrap; background: var(--paper); color: var(--text-muted);
}
.upstox-badge i { width: 8px; height: 8px; border-radius: 50%; background: #A2A8B4; }
.upstox-badge.is-ok { background: var(--green-soft); color: var(--green); cursor: default; }
.upstox-badge.is-ok i { background: var(--green); }
.upstox-badge.is-warn { background: var(--orange-soft); color: #9A620A; }
.upstox-badge.is-warn i { background: var(--orange); }
.upstox-badge.is-bad { background: var(--red-soft); color: var(--red); }
.upstox-badge.is-bad i { background: var(--red); animation: s2pulse 1.2s infinite; }
.upstox-badge.is-bad:hover { background: var(--red); color: #fff; }
.upstox-badge.is-bad:hover i { background: #fff; }

/* Terminal | Dashboard switch */
.view-tabs { display: flex; padding: 3px; border-radius: 12px; background: var(--paper); flex: none; margin-left: 6px; }
.view-tabs button {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border: 0; border-radius: 9px;
    background: none; font: 700 13px var(--font-sans); color: var(--text-muted); cursor: pointer;
}
.view-tabs button[aria-selected="true"] { background: var(--text); color: #fff; }
.view-tabs kbd { font: 600 10px var(--font-mono); padding: 1px 5px; border-radius: 5px; border: 1px solid currentColor; opacity: .55; }

.badge { border-radius: 999px; font-weight: 700; }

/* ---------- workspace: cards on paper ---------- */
.workspace { background: var(--paper); }
.sidebar { background: var(--paper); border-left: 0; padding: 10px 10px 10px 0; }
.sidebar .panel {
    background: var(--bg); border: 1px solid var(--border); border-radius: 18px; margin-bottom: 10px; padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(27, 33, 48, .04);
}
.panel-head h2 { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }

/* read-only strategy values from .env (bot_panel.js) */
.bp-env h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; margin: 12px 0 8px; }
.env-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--paper); color: var(--text-muted); font-size: 10.5px; font-weight: 800; }
.env-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.env-row { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 10px; background: var(--bg-subtle); }
.env-row span { font-size: 10.5px; font-weight: 700; color: var(--text-muted); }
.env-row b { font: 600 12.5px var(--font-mono); }

/* alerts sit over the chart's lower-left corner, never on the panel */
.alert-stack { top: auto; bottom: 22px; left: 22px; right: auto; width: min(340px, calc(100vw - 32px)); }
.alert-stack > * { border-radius: 14px; box-shadow: var(--shadow); }

/* dashboard drawer */
.bots-drawer { background: var(--paper); }

@media (max-width: 1500px) { .tb-live-trade .ls-main small, .view-tabs kbd { display: none; } .tb-live-trade { flex-basis: 420px; } }
@media (max-width: 1200px) { .tb-others, #side-btn .btn-text { display: none; } }
@media (max-width: 900px) {
    .view-tabs { display: none; }
    .tb-live-trade { flex-basis: 260px; }
    .upstox-badge .ub-text { display: none; }
    .alert-stack { bottom: 84px; left: 16px; right: 16px; width: auto; }
}

/* keep the top bar readable: fixed-size items never squash, the trade strip takes what is left */
.tb-strategy, .candle-timer-chip, .upstox-badge, .toolbar .badge, .view-tabs, .toolbar .tool-btn, .toolbar .menu-anchor { flex: none; }
#connect-btn { display: none !important; }      /* the Upstox badge is the login button now */
#strategy-btn .btn-text { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1700px) { .toolbar .tool-btn:not(#strategy-btn) .btn-text { display: none; } }
@media (max-width: 1350px) { #data-badge { display: none; } #strategy-btn .btn-text { max-width: 150px; } }
