:root { color-scheme: dark; font-family: "Segoe UI", sans-serif; background: #0b1220; color: #e7edf7; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at top right, #17304d 0, transparent 55%); min-height: 100vh; }
main { max-width: 1000px; margin: auto; padding: 38px 28px; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 48px; gap: 12px; }
.brand { font-size: 24px; font-weight: 750; letter-spacing: -.8px; }
.badge { font-size: 10px; letter-spacing: 1.5px; border: 1px solid #33475e; padding: 8px 12px; border-radius: 20px; color: #a7bfdc; }
.card { background: #111d2ee8; border: 1px solid #2a3c55; border-radius: 22px; padding: 38px; max-width: 720px; margin: auto; box-shadow: 0 20px 70px #0003; }
.eyebrow { color: #71b7ff; font-size: 11px; font-weight: bold; letter-spacing: 2px; margin: 0 0 16px; }
h1 { font-size: clamp(26px, 5vw, 36px); letter-spacing: -1px; line-height: 1.15; margin: 0 0 16px; }
p { line-height: 1.7; }
.intro, .muted { color: #a7b8cc; }
.status-row { display: flex; align-items: center; gap: 10px; margin-top: 30px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #eab768; flex-shrink: 0; }
.dot.connected { background: #58d5aa; box-shadow: 0 0 14px #58d5aa55; }
.muted { font-size: 14px; margin: 9px 0 25px; }
button { font: inherit; font-weight: 650; border: none; border-radius: 9px; padding: 14px 20px; cursor: pointer; background: #70b6ff; color: #071321; width: 100%; }
button:hover { filter: brightness(1.1); }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.secondary { background: transparent; color: #a7bfdc; font-size: 13px; margin-top: 8px; }
.small { font-size: 12px; color: #8d9fb5; border-top: 1px solid #293a50; padding-top: 20px; margin-bottom: 0; }
#notice { border-left: 3px solid #eab768; padding: 12px 16px; background: #1d2c3e; font-size: 14px; margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 36px 0; }
.grid article { padding: 10px; }
.step { color: #6484a9; font-size: 12px; letter-spacing: 2px; }
h2 { font-size: 15px; margin: 12px 0 8px; }
.grid p, footer { font-size: 12px; color: #8d9fb5; margin: 0; }
footer { border-top: 1px solid #223249; padding-top: 20px; text-align: center; line-height: 1.7; }
@media (max-width: 600px) { main { padding: 24px 18px; } header { margin-bottom: 28px; } .card { padding: 26px 22px; } .grid { grid-template-columns: 1fr; gap: 8px; } }
main.wide { max-width: 1200px; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.scanner-config { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 18px 0; }
.scanner-config label { display: grid; gap: 6px; color: #a7bfdc; font-size: 13px; }
.scanner-config .scanner-refresh { display: flex; align-items: center; gap: 8px; }
.scanner-config .scanner-refresh input { width: 16px; height: 16px; }
.scanner-config input, .scanner-config select { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #33475e; border-radius: 8px; background: #0a1422; color: inherit; font: inherit; }
.scanner-note { margin: 14px 2px 20px; }
.scanner-results { overflow-x: auto; margin: 20px 0; }
.scanner-table { width: 100%; border-collapse: collapse; background: #111d2ee8; border: 1px solid #2a3c55; border-radius: 14px; overflow: hidden; }
.scanner-table th, .scanner-table td { padding: 12px 14px; border-bottom: 1px solid #293a50; text-align: left; white-space: nowrap; }
.scanner-table th { color: #a7bfdc; font-size: 12px; letter-spacing: .06em; }
.scanner-table td { font-size: 14px; }
.scanner-activate { width: auto; padding: 8px 12px; font-size: 12px; }
#notice.error { border-left-color: #ff7777; }
.badge-link { text-decoration: none; }
.badge-link:hover { border-color: #70b6ff; color: #e7edf7; }
.link-button { display: block; text-align: center; margin-top: 8px; padding: 12px; border-radius: 9px; border: 1px solid #58d5aa; color: #58d5aa; text-decoration: none; font-weight: 650; }
.paste { margin-top: 18px; font-size: 14px; }
.paste summary { cursor: pointer; color: #a7bfdc; }
.paste input { width: 100%; font: inherit; font-size: 13px; padding: 12px; border-radius: 9px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; margin-bottom: 8px; }
code { color: #9fd0ff; }
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.toolbar .muted { margin-bottom: 0; }
.toolbar-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar-buttons button { width: auto; }
.toolbar-buttons .monitor-all { color: #1f8f4e; border-color: #1f8f4e; }
.toolbar-buttons .monitor-all.running { color: #b33a3a; border-color: #b33a3a; }
button.outline { background: transparent; color: #70b6ff; border: 1px solid #33475e; }
.bt-dialog { width: min(440px, calc(100vw - 32px)); border: 1px solid #33475e; border-radius: 16px; padding: 22px; background: #111d2e; color: #e7edf7; }
.bt-dialog::backdrop { background: #050a12cc; }
.bt-dialog form { display: grid; gap: 12px; }
.bt-dialog h2, .bt-dialog p { margin: 0; }
.bt-dialog label { display: grid; gap: 6px; color: #a7bfdc; font-size: 13px; }
.bt-dialog input { width: 100%; padding: 10px 12px; border: 1px solid #33475e; border-radius: 8px; background: #0a1422; color: inherit; font: inherit; }
.bt-dialog .order-row { display: flex; gap: 10px; }
.bt-dialog .order-row button { width: auto; flex: 1; }
.bt-dialog .error { color: #ff8f8f; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.sym-card { background: #111d2ee8; border: 1px solid #2a3c55; border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.sym-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sym-title-wrap { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 1; min-width: 0; }
.sym-head h3 { margin: 0; font-size: 18px; white-space: nowrap; }
.price {
  font-family: Consolas, "Courier New", monospace, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: pre;
  text-align: right;
  flex-shrink: 0;
  display: inline-block;
}
.sym-head .price { margin-left: auto; flex-shrink: 0; }
.up { color: #58d5aa; } .down { color: #ff7b7b; }
.signal-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.signal { font-weight: 750; font-size: 13px; padding: 5px 10px; border-radius: 6px; background: #22344b; }
.signal.BUY { background: #123d30; color: #58d5aa; }
.signal.SELL { background: #47202a; color: #ff8b8b; }
.signal.HOLD { background: #3b3222; color: #eab768; }
.levels { font-size: 12px; margin: 0; }
.reason { font-size: 13px; margin: 0; line-height: 1.5; }
.reason-summary { cursor: pointer; user-select: none; }
.reason-summary:hover { color: #d6e4f5; }
.indicators { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 10px; margin: 4px 0; font-size: 12px; }
.indicators dt { color: #6f86a3; } .indicators dd { margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.ai-box { border: 1px dashed #33475e; border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.ai-label { margin: 0; font-size: 11px; letter-spacing: 1.5px; color: #71b7ff; }
h4 { margin: 6px 0 0; font-size: 12px; letter-spacing: 1.5px; color: #6f86a3; text-transform: uppercase; }
.news { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.news li { font-size: 13px; line-height: 1.45; }
.news a, .news span.news-title { color: #d6e4f5; text-decoration: none; transition: color 0.15s ease; }
.news a:hover { color: #70b6ff; text-decoration: underline; }
.news small { display: block; color: #6f86a3; font-size: 11px; margin-top: 2px; }

/* Light red / green based on trend of market news */
.news li.news-bullish a,
.news li.news-bullish span.news-title {
  color: #4ade80 !important; /* light green for bullish */
}
.news li.news-bullish a:hover {
  color: #86efac !important;
}

.news li.news-bearish a,
.news li.news-bearish span.news-title {
  color: #f87171 !important; /* light red for bearish */
}
.news li.news-bearish a:hover {
  color: #fca5a5 !important;
}

[data-theme="light"] .news li.news-bullish a,
[data-theme="light"] .news li.news-bullish span.news-title {
  color: #16a34a !important; /* crisp light-mode green */
}
[data-theme="light"] .news li.news-bullish a:hover {
  color: #15803d !important;
}

[data-theme="light"] .news li.news-bearish a,
[data-theme="light"] .news li.news-bearish span.news-title {
  color: #dc2626 !important; /* crisp light-mode red */
}
[data-theme="light"] .news li.news-bearish a:hover {
  color: #b91c1c !important;
}

[data-theme="light"] .news li.news-neutral a,
[data-theme="light"] .news li.news-neutral span.news-title {
  color: #1e293b !important;
}
.news-panel { margin: 30px 0; background: #111d2ee8; border: 1px solid #2a3c55; border-radius: 16px; padding: 22px; }
.news-panel h2 { margin-top: 0; }
.tabs { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.tab { width: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 18px; background: #111d2ee8; color: #a7bfdc; border: 1px solid #2a3c55; }
.tab strong { font-size: 15px; letter-spacing: 1px; }
.tab small { font-size: 11px; font-weight: 500; color: #6f86a3; }
.tab[aria-selected="true"] { background: #70b6ff; color: #071321; border-color: #70b6ff; }
.tab[aria-selected="true"] small { color: #17324f; }
.contract { font-size: 12px; margin: -6px 0 0; }
.watchlist { margin: 0 0 24px; background: #111d2ee8; border: 1px solid #2a3c55; border-radius: 16px; padding: 18px 22px; }
.watch-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.watch-head h2 { margin: 0; font-size: 18px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 14px 0; }
.chips .muted { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border: 1px solid #33475e; border-radius: 999px; font-size: 13px; font-weight: 600; }
.chip button { width: auto; padding: 2px 9px; border-radius: 999px; background: transparent; color: #ff8f8f; font-size: 16px; line-height: 1; }
.chip button:hover { background: #ff8f8f22; }
.trade-settings button.clone { width: auto; margin-left: auto; padding: 4px 10px; border-radius: 8px; font-size: 12px; background: transparent; border: 1px solid #70b6ff; color: #70b6ff; }
.trade-settings button.clone:hover:not(:disabled) { background: #70b6ff22; }
.trade-settings button.remove { width: auto; padding: 4px 10px; border-radius: 8px; font-size: 12px; background: transparent; border: 1px solid #ff8f8f; color: #ff8f8f; }
.trade-settings button.remove:hover:not(:disabled) { background: #ff8f8f22; }
#watch-chips .chip { cursor: pointer; padding: 6px 12px; }
#watch-chips .chip:hover { border-color: #70b6ff; }
.watch-search { position: relative; }
.watch-search input { box-sizing: border-box; width: 100%; padding: 11px 14px; border-radius: 9px; border: 1px solid #33475e; background: #0a1422; color: inherit; font: inherit; }
.results { list-style: none; margin: 6px 0 0; padding: 6px; max-height: 320px; overflow-y: auto; border: 1px solid #33475e; border-radius: 9px; background: #0a1422; }
.results .muted { margin: 6px 8px; }
.results button { display: flex; align-items: baseline; gap: 10px; text-align: left; padding: 9px 12px; background: transparent; color: inherit; font-weight: 500; }
.results button:hover:not(:disabled) { background: #70b6ff22; }
.results button small { color: #8aa3c2; }
.news .news-range { margin: 14px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: #8aa3c2; }
.news .more { border: none; list-style: none; }
.news .more button { width: auto; margin-top: 10px; padding: 8px 14px; font-size: 13px; }

.chip.live { border-color: #ffb454; }
.trade-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; padding: 8px; border: 1px solid #33475e; border-radius: 10px; }
.trade-settings.live { border-color: #ffb454; }
.trade-settings input.amount { width: 92px; padding: 3px 6px; border-radius: 8px; font-size: 12px; }
.trade-settings label.auto, .trade-settings label.market-data-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: #9fb1c8; cursor: pointer; }
.trade-settings label.auto input, .trade-settings label.market-data-toggle input { width: auto; margin: 0; }
.trade-settings select.broker { width: auto; max-width: 150px; padding: 3px 4px; border-radius: 8px; font: inherit; font-size: 12px; font-weight: 500; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; }
.trade-settings.live select.broker:not(.strategy) { border-color: #ffb454; color: #ffcf8a; }
.trade-settings select.option-by { width: auto; max-width: 110px; padding: 3px 4px; border-radius: 8px; font: inherit; font-size: 12px; font-weight: 500; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; }
.trade-settings select.option-by.missing { border-color: #ff7b7b; color: #ffb0b0; }
.trade-settings .missing { border-color: #ff7b7b; }
.sym-head .price { margin-left: auto; }
.expiry-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(225, 29, 72, 0.16);
  color: #fb7185;
  border: 1px solid rgba(225, 29, 72, 0.35);
  white-space: nowrap;
  line-height: 1.4;
}
.expiry-badge[hidden] { display: none !important; }
.chip.expiry-today { border-color: #d44080; color: #ffb5d5; }
.monitor-toggle { width: auto; flex: none; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 650; background: #1f8f4e; color: #fff; }
.monitor-toggle.running { background: #b33a3a; }
.signal-state { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; color: #fff; background: #6b7280; }
.signal-state.ready { background: #1f8f4e; }
.signal-state.triggered { background: #c2410c; }
.signal-state.checking { background: #2563eb; }
.sym-card.stopped { border-color: #3a4048; background: #1a1d22e8; }
.sym-card.stopped > :not(.sym-head):not(.trade-settings), .sym-card.stopped .sym-head > :not(.monitor-toggle) { filter: grayscale(1); opacity: 0.55; }
.sym-card.stopped .price { color: #8a919b; }
.chip.stopped { color: #8a919b; border-style: dashed; filter: grayscale(1); }
.trade-settings input.premium { width: 84px; padding: 3px 6px; border-radius: 8px; font-size: 12px; }
.order-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.order-row .place-order { width: auto; background: #1f7a5a; }
.order-row .place-order:disabled { opacity: .5; cursor: not-allowed; }
.orders-panel { margin: 30px 0 0; background: #111d2ee8; border: 1px solid #2a3c55; border-radius: 16px; padding: 22px; }
.orders-panel h2 { margin-top: 0; }
.record-editor, .bt-dialog { margin: auto; width: min(640px, calc(100vw - 48px)); max-height: 90vh; color: #e7edf7; box-sizing: border-box; background: #0c1624; border: 1px solid #2a3c55; border-radius: 16px; padding: 22px; overflow-y: auto; }
.record-editor::backdrop, .bt-dialog::backdrop { background: #000a; }
.record-editor label { display: grid; gap: 5px; margin: 14px 0; color: #a7bfdc; }
.record-editor input, .record-editor select { width: 100%; padding: 9px; box-sizing: border-box; border: 1px solid #33475e; border-radius: 8px; background: #0b1220; color: #e7edf7; color-scheme: dark; }
.record-editor [role="alert"] { color: #ff7b7b; }
.orders { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.orders .order { display: grid; gap: 2px; padding: 8px 12px; border-left: 3px solid #58d5aa; background: #0c1624; border-radius: 8px; }
.orders .order.FAILED { border-left-color: #ff8b8b; }
.orders .order.PAPER { border-left-color: #e0b85a; }
.orders .order small { color: #9fb1c8; }

.watch-head .link-button { margin: 0; padding: 6px 12px; font-size: 13px; }
.toolbar-buttons .link-button { margin: 0; }
.status-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: -8px 0 18px; }
.status-filter { width: auto; padding: 6px 14px; font-size: 13px; border-radius: 999px; background: transparent; color: #a7bfdc; border: 1px solid #33475e; }
.status-filter[aria-pressed="true"] { background: #22344b; color: #e7edf7; border-color: #70b6ff; }
.order-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.order-summary div { background: #111d2ee8; border: 1px solid #2a3c55; border-radius: 12px; padding: 12px 16px; display: grid; gap: 4px; }
.order-summary small { color: #8aa3c2; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.order-summary .summary-sub { color: #8aa3c2; font-size: 11px; letter-spacing: 0; text-transform: none; font-weight: normal; margin-top: 2px; }
.order-summary strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.order-summary strong.up { color: #58d5aa; }
.order-summary strong.down { color: #ff7b7b; }
.card-pnl-box { background: #0c1624; border: 1px solid #22344b; border-radius: 9px; padding: 8px 12px; margin: 8px 0 10px; display: flex; flex-direction: column; gap: 4px; }
.card-pnl-box[hidden] { display: none; }
.card-pnl-head { display: flex; justify-content: space-between; align-items: center; }
.card-pnl-head small { color: #8aa3c2; font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; font-weight: 600; }
.card-pnl-live-row { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.card-pnl-live-label { color: #9fb1c8; }
.card-pnl-total { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-pnl-live { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.card-pnl-total.up, .card-pnl-live.up { color: #58d5aa; }
.card-pnl-total.down, .card-pnl-live.down { color: #ff7b7b; }
.card-pnl-total.flat, .card-pnl-live.flat { color: #8aa3c2; }
.table-wrap { overflow-x: auto; margin-top: 0; padding: 8px 12px; }
.order-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.order-table th { text-align: left; color: #6f86a3; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; padding: 10px 8px; border-bottom: 1px solid #2a3c55; white-space: nowrap; }
.order-table td { padding: 10px 8px; border-bottom: 1px solid #1c2b3f; vertical-align: top; }
.order-table td > span { display: block; font-weight: 600; white-space: nowrap; }
.order-table td small { display: block; color: #8aa3c2; font-size: 11px; margin-top: 2px; }
.order-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.order-table td.empty { text-align: center; padding: 30px; }
.order-table tr.state-FAILED td { opacity: .75; }
.order-table td.pnl.up, .order-table small.tick.up { color: #58d5aa; }
.order-table td.pnl.down, .order-table small.tick.down { color: #ff7b7b; }
.order-table td.live .ltp { font-weight: 700; }
.order-table button.exit { width: auto; padding: 6px 14px; font-size: 12px; color: #ff9b9b; border-color: #5a2f3a; }
.state-badge { display: inline-block !important; font-size: 11px; font-weight: 750; letter-spacing: 1px; padding: 3px 8px; border-radius: 6px; background: #22344b; }
.state-badge.OPEN { background: #123d30; color: #58d5aa; }
.state-badge.CLOSED { background: #1d2f4a; color: #70b6ff; }
.state-badge.EXPIRED { background: #3b3222; color: #eab768; }
.state-badge.FAILED { background: #47202a; color: #ff8b8b; }
.flash-up, .flash-down { transition: color 0.2s ease; }
.market-status { font-size: 13px; font-weight: 600; margin: 4px 0 0; }
.market-status.open { color: #58d5aa; }
.market-status.closed { color: #eab768; }
.live-status { font-size: 12px; margin: 2px 0 0; color: #9aa4b2; }
.live-status.open { color: #58d5aa; }
.live-status.closed { color: #eab768; }
.order-table td.actions { white-space: nowrap; }
.order-table td.actions button { width: auto; padding: 6px 12px; font-size: 12px; }
.order-table td.actions button + button { margin-left: 6px; }
.order-table button.leg-expand { width: auto; padding: 3px 8px; margin-top: 4px; font-size: 10px; color: #9fc7f2; }
.order-table tr.leg-child-row > td { padding: 0 8px 10px; background: #101b2a; }
.leg-child-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.leg-child-table th { color: #8aa3c2; text-align: left; font-size: 10px; padding: 8px; border-bottom: 1px solid #2a3c55; }
.leg-child-table td { padding: 7px 8px; border-bottom: 1px solid #1c2b3f; font-variant-numeric: tabular-nums; white-space: nowrap; }
.leg-child-table td.up { color: #58d5aa; }
.leg-child-table td.down { color: #ff7b7b; }
.order-table button.close { width: auto; padding: 6px 14px; font-size: 12px; color: #a7bfdc; }

/* Sign-in and broker pages */
.card.narrow { max-width: 460px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; margin: 12px 0 0; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #a7bfdc; flex: 1; min-width: 0; }
.stack-form input { width: 100%; font: inherit; font-size: 14px; padding: 11px 12px; border-radius: 9px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; }
.stack-form input:focus-visible { outline: 2px solid #70b6ff; outline-offset: 1px; }
.form-row { display: flex; gap: 10px; }
.warning { border-left: 3px solid #ff7b7b; padding: 12px 16px; background: #2a1c25; font-size: 14px; margin-bottom: 20px; }
.warning a { color: #9fd0ff; }
.inline-form { display: inline; margin: 0; }
button.badge-button { width: auto; background: transparent; font-weight: 400; cursor: pointer; }
button.badge-button:hover { border-color: #ff7b7b; color: #e7edf7; filter: none; }
.broker-cards { margin-bottom: 18px; }
.broker-card .status-row { margin-top: 0; }
.broker-card .muted { margin: 0; }
.broker-tags { display: flex; gap: 6px; }
.tag { font-size: 10px; letter-spacing: 1px; padding: 4px 8px; border-radius: 6px; background: #1d3550; color: #9fd0ff; }
.account-card { margin-top: 32px; max-width: 520px; }
@media (max-width: 600px) { .form-row { flex-direction: column; } }
.settings .stack-form label { display: block; font-size: 13px; color: #a7bfdc; }
.section-title { font-size: 16px; color: #a7bfdc; margin: 18px 0 8px; }
.connect-card { margin-top: 22px; }
.pick-label { display: block; max-width: 420px; font-size: 13px; color: #a7bfdc; }
.pick-label select { display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 9px; font: inherit; font-size: 14px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; }
.chip.pick { padding: 4px 12px 4px 4px; gap: 6px; }
.chip.pick button { color: #e7edf7; font-size: 13px; font-weight: 600; padding: 4px 10px; }
.chip.pick.selected { border-color: #70b6ff; background: #70b6ff22; }
#picked:empty { display: none; }
.settings input[readonly] { opacity: .65; cursor: not-allowed; }

/* Password field wrapper with eye toggle */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.pw-wrap input {
  width: 100%;
  padding-right: 42px !important;
}
.pw-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  border: none !important;
  padding: 4px 8px !important;
  width: auto !important;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #8aa3c2;
  opacity: 0.85;
  user-select: none;
  transition: opacity 0.15s;
}
.pw-toggle-btn:hover {
  opacity: 1;
  color: #70b6ff;
  filter: none !important;
}

/* ATM Options Monitoring Box */
.atm-options-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: #0d1828;
  border: 1px solid #23364d;
  border-radius: 10px;
  padding: 6px 10px;
  margin: 6px 0;
}
.atm-opt-item {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  background: #111f33;
  border: 1px solid #233b59;
  font-size: 12px;
}
.atm-opt-item.atm-ce { border-color: #1b4b3b; }
.atm-opt-item.atm-pe { border-color: #552731; }
.atm-opt-badge {
  font-weight: 800;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.atm-opt-badge.ce-badge { background: #123d30; color: #58d5aa; }
.atm-opt-badge.pe-badge { background: #47202a; color: #ff8b8b; }
.atm-opt-strike {
  font-weight: 600;
  color: #cfddec;
  font-size: 12px;
  white-space: nowrap;
}
.atm-opt-price {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}
.atm-opt-item.atm-ce .atm-opt-price { color: #58d5aa; }
.atm-opt-item.atm-pe .atm-opt-price { color: #ff8b8b; }
.btn-quick-buy {
  width: auto;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-quick-buy.ce-buy {
  background: #195e47;
  color: #d1fae5;
}
.btn-quick-buy.ce-buy:hover {
  background: #237a5d;
}
.btn-quick-buy.pe-buy {
  background: #732a39;
  color: #fee2e2;
}
.btn-quick-buy.pe-buy:hover {
  background: #923447;
}

/* Strategy Formula Bar & Dialog */
.strategy-formula-bar { margin: 4px 0 2px; }
.btn-formula-popup {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: #152438;
  border: 1px solid #2e4768;
  color: #70b6ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-formula-popup:hover { background: #1c314d; border-color: #70b6ff; }
.indicators.strategy-interactive { cursor: pointer; border-radius: 8px; padding: 4px; transition: background 0.15s; }
.indicators.strategy-interactive:hover { background: #152438; }

.formula-dialog {
  position: relative;
  background: #0d1726;
  border: 1px solid #253952;
  border-radius: 16px;
  padding: 20px;
  color: #e7edf7;
  box-shadow: 0 16px 48px #0008;
}
.formula-dialog-close-icon {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  color: #94a3b8 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  padding: 0 !important;
  margin: 0 !important;
  transition: all 0.15s ease !important;
  z-index: 10 !important;
}
.formula-dialog-close-icon:hover {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="light"] .formula-dialog-close-icon {
  color: #64748b !important;
}
[data-theme="light"] .formula-dialog-close-icon:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
.formula-toggle-btn.active {
  background: #254668 !important;
  color: #fff !important;
  font-weight: 700;
}
.formula-group-card {
  background: #111d2e;
  border: 1px solid #23364d;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.formula-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1c2b3e;
  padding-bottom: 6px;
}
.formula-group-title {
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.5px;
}
.formula-group-title.BUY { color: #58d5aa; }
.formula-group-title.SELL { color: #ff8b8b; }
.formula-cond-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: Consolas, "Courier New", monospace;
  transition: all 0.15s ease;
}
.formula-cond-card.is-true {
  background: #0d281f;
  border: 1px solid #1f6b4e;
  color: #a7f3d0;
}
.formula-cond-card.is-false {
  background: #2b1419;
  border: 1px solid #6e2531;
  color: #fecdd3;
}
.formula-cond-badge {
  font-family: inherit;
  font-weight: 800;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.formula-cond-badge.TRUE {
  background: #123d30;
  color: #58d5aa;
  border: 1px solid #227b5e;
}
.formula-cond-badge.FALSE {
  background: #47202a;
  color: #ff8b8b;
  border: 1px solid #8e2b3c;
}
.formula-cond-text {
  flex: 1;
  word-break: break-word;
}
.formula-cond-text .op {
  font-weight: 750;
  color: #eab768;
}
.secret-field { margin-bottom: 4px; }
.inline-check { display: inline-flex !important; align-items: center; gap: 6px; margin: -4px 0 8px; }
.settings .inline-check input { width: auto; margin: 0; }

/* Backtest pages */
.bt-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.bt-form label { display: grid; gap: 4px; font-size: 11px; letter-spacing: .5px; color: #8aa3c2; }
.bt-form .wide { grid-column: 1 / -1; }
.bt-form input, .bt-form select, .bt-filters select { width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; font: inherit; font-size: 13px; color-scheme: dark; }
.bt-form input:invalid:not(:placeholder-shown), .bt-form .missing { border-color: #ff7b7b; }
.bt-form .order-row { margin-top: 2px; }
.bt-form .order-row button { width: auto; padding: 10px 16px; }
.bt-form .order-row .run { background: #1f7a5a; color: #e7edf7; }
.bt-note { margin: 0; font-size: 12px; }
.bt-note.error { color: #ff8b8b; }
.bt-status, .run-status { font-size: 11px; font-weight: 700; letter-spacing: 1px; padding: 4px 9px; border-radius: 6px; background: #22344b; color: #a7bfdc; }
.bt-status.COMPLETED, .run-status.COMPLETED { background: #123d30; color: #58d5aa; }
.bt-status.RUNNING, .run-status.RUNNING, .bt-status.QUEUED, .run-status.QUEUED { background: #3b3222; color: #eab768; }
.bt-status.FAILED, .run-status.FAILED { background: #47202a; color: #ff8b8b; }
.bt-result { border-top: 1px solid #2a3c55; padding-top: 10px; display: grid; gap: 6px; }
.bt-summary { grid-template-columns: repeat(3, 1fr); }
.bt-link { color: #70b6ff; font-size: 13px; text-decoration: none; }
.bt-filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.bt-filters label { display: grid; gap: 4px; font-size: 11px; color: #8aa3c2; min-width: 170px; }
.bt-detail { margin-top: 22px; }
.bt-detail h2 { font-size: 18px; margin: 0 0 6px; }
.order-table tr.selected td { background: #70b6ff14; }
.order-table button.view { width: auto; padding: 6px 14px; font-size: 12px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; font-size: 13px; color: #9fb1c8; }
.pager[hidden] { display: none; }
.pager-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-button { width: auto; min-width: 34px; padding: 5px 9px; font-size: 13px; font-weight: 600; border-radius: 8px; background: transparent; color: #a7bfdc; border: 1px solid #33475e; }
.pager-button[aria-current="page"] { background: #22344b; color: #e7edf7; border-color: #70b6ff; opacity: 1; cursor: default; }
.pager-gap { padding: 0 4px; }
.pager-size select { margin-left: 6px; padding: 4px 8px; border-radius: 8px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; font: inherit; color-scheme: dark; }
.st-editor { margin-bottom: 22px; }
.st-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 12px; }
.st-group { min-width: 0; border: 1px solid #2a3c55; border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 8px; }
.st-group legend { padding: 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .4px; color: #c9d6e8; }
.st-group.BUY legend { color: #58d5aa; }
.st-group.SELL legend { color: #ff8f8f; }
.st-indicators-panel { margin: 12px 0 16px 0; padding: 12px 14px; background: #0f1a2a; border: 1px solid #2a3c55; border-radius: 12px; }
.st-indicator-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: #142236; padding: 6px 10px; border: 1px solid #2a3c55; border-radius: 8px; color: #e7edf7; }
.st-indicator-row select, .st-indicator-row input { width: auto; padding: 5px 6px; border-radius: 8px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; font: inherit; font-size: 12px; color-scheme: dark; }
.ind-remove-btn { margin-left: auto; width: auto; padding: 4px 10px; background: transparent; color: #ff6b6b; border: 1px solid #7f2323; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; line-height: 1; }
.ind-remove-btn:hover { background: #ff4d4d25; border-color: #ff6b6b; color: #ff8b8b; }
.st-group-head, .st-cond { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.st-cond { background: #142236; padding: 6px 10px; border: 1px solid #2a3c55; border-radius: 8px; color: #e7edf7; }
.st-cond .muted, .st-indicator-row .muted { color: #8aa3c2; }
.st-group select, .st-group input { width: auto; padding: 5px 6px; border-radius: 8px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; font: inherit; font-size: 12px; color-scheme: dark; }
.st-group .g-n, .st-cond .c-times, .st-cond .c-bars { width: 52px; }
.st-cond .c-value { width: 90px; }
.st-cond .c-time { width: 110px; }
.st-group button { width: auto; padding: 5px 10px; font-size: 12px; }
.st-group .g-empty { margin: 0; font-size: 12px; }
.st-group-child { background: #101c2e; padding: 8px 10px; margin: 6px 0 6px 12px; border-radius: 8px; border: 1px solid #2a3c55; border-left: 3px solid #70b6ff; }
.st-formula-preview { margin-top: 10px; padding: 8px 12px; background: #08111e; border: 1px solid #1f3148; border-left: 3px solid #58d5aa; font-family: Consolas, "Courier New", monospace; font-size: 12px; color: #a5f3fc; border-radius: 6px; line-height: 1.5; word-break: break-word; }
.g-conditions { display: grid; gap: 6px; }
.st-help { font-size: 12px; color: #9fb1c8; }
.st-help summary { cursor: pointer; color: #70b6ff; }
.st-card .st-rule { margin: 0; font-size: 13px; line-height: 1.5; }
.st-card .order-row button, .st-card .order-row .badge-link { width: auto; }
.st-list > .st-card { max-height: 70vh; overflow-y: auto; align-self: start; }
.sb-form { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .sb-form { grid-template-columns: 1fr 1fr; } .st-rules { grid-template-columns: 1fr; } }
.tu-indicators { border: 1px solid #33475e; border-radius: 10px; padding: 8px 12px; margin: 0; }
.tu-indicators legend { font-size: 13px; padding: 0 4px; }
#r-indicators { display: grid; gap: 8px; }
.tu-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.tu-group > small { flex-basis: 100%; }
.tu-check { display: inline-flex; flex-direction: row; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.tu-check input { width: auto; margin: 0; }
.tu-count { margin: 0; font-size: 13px; color: #8fd19e; }
.tu-count.over { color: #ff8f8f; }
.tu-formula { font-size: 12px; line-height: 1.5; min-width: 320px; }
.tu-save-name { display: block; max-width: 420px; margin: 8px 0; font-size: 13px; }
#results .row-actions, #rows .row-actions { white-space: nowrap; }
#results .row-actions button, #rows .row-actions button { width: auto; padding: 5px 10px; font-size: 12px; margin: 2px; }

.st-cond select { max-width: 140px; }
.st-cond .c-kind { max-width: 100px; }
.st-group-head > *, .st-cond > * { margin: 0; align-self: center; }

.st-rule-card {
  background: #0f1c2e;
  border: 1px solid #23364d;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}
.st-rule-card.BUY { border-left: 4px solid #58d5aa; }
.st-rule-card.SELL { border-left: 4px solid #ff8f8f; }
.st-rule-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid #1c2b3e;
  padding-bottom: 10px;
}
.st-rule-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: 12px;
}
html[data-theme="light"] .st-rule-card {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04) !important;
}
html[data-theme="light"] .st-rule-header {
  border-bottom-color: #e2e8f0 !important;
}

button.text-button { width: auto; display: inline; padding: 0; background: none; color: #70b6ff; text-decoration: underline; font-weight: 650; }
.admin-only[hidden], [hidden] { display: none !important; }

.icon-button { width: auto; padding: 2px 8px; margin: 0; font-size: 14px; background: transparent; border: 1px solid #2c3a52; color: #70b6ff; border-radius: 6px; cursor: pointer; }

.icon-button:hover { border-color: #70b6ff; }

.menus-cell { min-width: 220px; }
.users-table { table-layout: fixed; }
.users-table td { overflow-wrap: anywhere; }
.users-table .menus-cell { min-width: 0; }
.users-table td > span { white-space: normal; }
.users-table #rows .row-actions { white-space: normal; }
.users-table .account-status button { display: block; width: auto; padding: 5px 8px; font-size: 12px; margin-top: 6px; }
.run-status.STOPPING { color: #f5c76b; }
.run-status.STOPPED { color: #a7bfdc; }
@media (max-width: 1000px) {
  .users-table, .users-table tbody, .users-table tr, .users-table td { display: block; width: 100%; }
  .users-table thead { display: none; }
  .users-table tr { padding: 12px 0; border-bottom: 1px solid #2a3c55; }
  .users-table td { box-sizing: border-box; border-bottom: 0; padding: 6px 8px; }
  .users-table td::before { content: attr(data-label); display: block; color: #8aa3c2; font-size: 11px; margin-bottom: 4px; }
}

.menu-editor { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }

.menu-editor label { display: inline-flex; gap: 4px; align-items: center; margin: 0; font-size: 13px; white-space: nowrap; }

.historic-meta-section { background: #112034; border-left: 3px solid #70b6ff; border-radius: 6px; padding: 6px 12px; font-size: 12px; margin: 6px 0 10px; color: #c5daf2; }
.historic-meta-section.missing { border-left-color: #ff7b7b; background: #25161c; color: #ffb5b5; }
.historic-meta-section a { color: #70b6ff; text-decoration: underline; }

.menu-editor input[type=checkbox] { width: auto; margin: 0; }

.menu-editor button { width: auto; padding: 4px 10px; margin: 0; }


/* Profile page and header profile icon */
.profile-link { display: inline-flex; align-items: center; gap: 6px; }
.profile-link[aria-current="page"] { border-color: #70b6ff; color: #e7edf7; }
.profile-icon { font-size: 13px; line-height: 1; }
.settings-groups { display: flex; flex-direction: column; gap: 18px; }
.settings-card { max-width: none; margin: 0; padding: 26px 30px; min-width: 0; }
.settings-card legend { float: left; width: 100%; padding: 0; }
.settings-grid { clear: both; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 22px; }
.setting { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #a7bfdc; min-width: 0; }
.setting-label { font-weight: bold; color: #e7edf7; }
.setting-env { font-size: 10px; color: #6f86a3; letter-spacing: .5px; }
.setting-help { font-size: 11px; color: #8d9fb5; }
.market-data-toggle { display: flex; align-items: center; gap: 6px; margin: 10px 0; font-size: 13px; cursor: pointer; }
.market-data-toggle input { width: 16px; height: 16px; }
.setting-usage { font-size: 11px; color: #f2c46d; }
.setting input:disabled { opacity: .6; cursor: not-allowed; }
.setting input, .setting select, .setting textarea { width: 100%; font: inherit; font-size: 14px; padding: 9px 11px; border-radius: 9px; border: 1px solid #33475e; background: #0b1220; color: #e7edf7; box-sizing: border-box; }
.setting textarea { resize: vertical; min-height: 44px; }
.setting input:focus-visible, .setting select:focus-visible, .setting textarea:focus-visible { outline: 2px solid #70b6ff; outline-offset: 1px; }
.settings-actions { display: flex; gap: 10px; margin: 18px 0 30px; }
.settings-actions button { width: auto; }
#rows .row-actions .link-button { display: inline-block; margin: 2px; padding: 5px 10px; font-size: 12px; font-weight: normal; border-color: #33475e; color: #70b6ff; }

/* Subscriptions */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 12px 0 24px; }
.plan-card { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.plan-card h3 { margin: 0; font-size: 18px; }
.plan-card button { margin-top: auto; }
.plan-price { font-size: 20px; font-weight: 700; color: #70b6ff; margin: 0; }
.benefit-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.plan-form { margin: 0 0 20px; }
.plan-fieldset { border: 1px solid #223249; border-radius: 8px; padding: 12px 14px; margin: 16px 0 0; }
.plan-menus { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 18px; }
.plan-menu { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.plan-menu label { flex: 1; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.plan-menu input[type=checkbox] { width: 16px; height: 16px; }
.plan-menu input[type=number] { width: 100px; margin: 0; }
button.danger { color: #ff8b8b; border-color: #b33a3a; }

/* Market AI Chatbot Widget (Agentic RAG) */
.chatbot-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: auto;
  height: 48px;
  border-radius: 24px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #ffffff;
  border: 1px solid #38bdf8;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chatbot-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.5);
  filter: brightness(1.1);
}
.chatbot-launcher.active {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.chatbot-window {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  z-index: 9999;
  overflow: hidden;
}

.chatbot-header {
  padding: 12px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.chatbot-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bot-icon { font-size: 20px; }
.bot-name { font-size: 14px; font-weight: 700; color: #f8fafc; }
.bot-status { font-size: 11px; color: #94a3b8; display: flex; align-items: center; gap: 4px; }
.bot-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }

.chatbot-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-instrument-select {
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  max-width: 150px;
}
.chatbot-close-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 14px;
  padding: 4px 8px;
  width: auto;
  cursor: pointer;
  border-radius: 4px;
}
.chatbot-close-btn:hover { background: #334155; color: #f8fafc; }

.chatbot-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
}
.user-msg {
  align-self: flex-end;
}
.user-msg .chat-bubble {
  background: #2563eb;
  color: #ffffff;
  border-radius: 14px 14px 2px 14px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
}
.bot-msg {
  align-self: flex-start;
  width: 100%;
}
.bot-msg .chat-bubble {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 14px 14px 14px 2px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}
.bot-msg .card-bubble {
  background: #162032;
  border-color: #3b82f644;
}

.chat-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.quick-prompt {
  background: #0f172a;
  border: 1px solid #334155;
  color: #38bdf8;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  width: auto;
  transition: background 0.15s, border-color 0.15s;
}
.quick-prompt:hover {
  background: #1e293b;
  border-color: #38bdf8;
}

.prediction-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.prediction-tag {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.action-buy { background: #16a34a; color: #ffffff; }
.action-sell { background: #dc2626; color: #ffffff; }
.action-hold { background: #d97706; color: #ffffff; }

.prediction-stat {
  font-size: 11px;
  color: #94a3b8;
  background: #0f172a;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #334155;
}
.prediction-stat strong { color: #f8fafc; }
.sr-stat { border-color: #f59e0b55; }
.sr-stat strong { color: #f59e0b; }

.sr-banner {
  background: #0f172a;
  border-left: 3px solid #f59e0b;
  padding: 5px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
  color: #cbd5e1;
  font-size: 11px;
}

.chat-levels-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 10px;
  background: #0f172a;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #334155;
}
.level-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.level-box .lbl { font-size: 9px; text-transform: uppercase; color: #64748b; font-weight: 700; margin-bottom: 2px; }
.level-box .val { font-size: 11px; font-weight: 700; color: #f1f5f9; }
.level-box .val.sl { color: #f87171; }
.level-box .val.tgt { color: #4ade80; }

.chat-answer-text {
  font-size: 12.5px;
  line-height: 1.6;
  color: #e2e8f0;
  margin-bottom: 8px;
}
.chat-meta-bar {
  border-top: 1px solid #334155;
  padding-top: 6px;
  margin-top: 6px;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chatbot-form {
  padding: 10px 14px;
  background: #1e293b;
  border-top: 1px solid #334155;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chatbot-form input[type="file"] {
  display: none !important;
}
.chatbot-form input:not([type="file"]) {
  flex: 1;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 8px;
  color: #f8fafc;
  padding: 8px 12px;
  font-size: 13px;
}
.chatbot-form input:not([type="file"]):focus {
  outline: 2px solid #38bdf8;
  border-color: #38bdf8;
}
.chatbot-form .chatbot-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}
.chatbot-form textarea {
  flex: 1;
  min-width: 0;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 8px;
  color: #f8fafc;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  resize: none;
  transition: border-color 0.15s ease;
}
.chatbot-form textarea:focus {
  border-color: #38bdf8;
  outline: none;
}
.chatbot-form button#chatbot-send,
.chatbot-form .chatbot-send-btn {
  width: auto !important;
  min-width: 84px !important;
  max-width: fit-content !important;
  height: 38px !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9) !important;
  color: #ffffff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 0 14px !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35) !important;
  flex: 0 0 auto !important;
}
.chatbot-form button#chatbot-send:hover,
.chatbot-form .chatbot-send-btn:hover {
  background: linear-gradient(135deg, #1e40af, #0284c7) !important;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.5) !important;
}
.widget-attach-btn {
  width: 38px !important;
  min-width: 38px !important;
  max-width: 38px !important;
  height: 38px !important;
  border-radius: 8px !important;
  background: #0f172a !important;
  border: 1px solid #475569 !important;
  color: #38bdf8 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  flex: 0 0 38px !important;
  transition: all 0.15s ease !important;
  box-sizing: border-box !important;
}
.widget-attach-btn:hover {
  background: #1e293b !important;
  border-color: #38bdf8 !important;
}

/* Full-Width Market AI Panel (Monitoring Page) */
.market-ai-panel {
  background: #111d2ee8;
  border: 1px solid #2a3c55;
  border-radius: 20px;
  padding: 24px 28px;
  margin: 28px 0;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
  width: 100%;
}
.ai-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ai-chip {
  background: #0f172a;
  border: 1px solid #33475e;
  color: #38bdf8;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  width: auto;
  transition: all 0.15s;
}
.ai-chip:hover {
  background: #1e293b;
  border-color: #38bdf8;
  transform: translateY(-1px);
}
.ai-attach-btn:hover {
  background: #1e293b !important;
  border-color: #38bdf8 !important;
}
.ai-submit-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Ensure Market AI Page & Chatbox buttons NEVER stretch to fullscreen width */
.chat-page-container button,
.chat-page-prompts button,
.chat-input-row button,
.ai-quick-chips button,
.ai-panel-controls button,
.toolbar-buttons button,
button#clear-chat-btn,
button#monitoring-ai-clear,
button#monitoring-ai-submit,
button#chat-page-send,
button#file-remove-btn,
button#monitoring-ai-file-remove,
button.ai-submit-btn,
.ai-submit-btn,
.chatbox-send-btn,
.quick-prompt,
.ai-chip {
  width: auto !important;
  max-width: fit-content !important;
  flex: 0 0 auto !important;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Specific styling for Ask AI submit buttons */
#monitoring-ai-submit,
#chat-page-send,
button#monitoring-ai-submit,
button#chat-page-send {
  min-width: 110px !important;
  height: 48px !important;
  padding: 0 20px !important;
}

/* Fixed small size button for clearing attached file */
button#file-remove-btn,
button#monitoring-ai-file-remove,
button#widget-file-remove,
.file-remove-btn,
.file-remove {
  width: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  height: 20px !important;
  min-height: 20px !important;
  max-height: 20px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  margin: 0 0 0 6px !important;
  background: rgba(239, 68, 68, 0.2) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.15s ease-in-out !important;
}

button#file-remove-btn:hover,
button#monitoring-ai-file-remove:hover,
button#widget-file-remove:hover,
.file-remove-btn:hover,
.file-remove:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #ef4444 !important;
  transform: scale(1.1) !important;
}

/* Fixed left attachment button */
.ai-attach-btn,
#monitoring-ai-file-label,
#chat-file-label,
.chatbox-attach-btn {
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  flex: 0 0 48px !important;
  box-sizing: border-box !important;
}

/* Full width responsive textarea across the container */
#monitoring-ai-text,
#chat-page-input {
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* ==========================================================================
   THEME TOGGLE BUTTON & LIGHT MODE OVERRIDES
   ========================================================================== */

button.theme-toggle-btn {
  width: auto !important;
  min-width: 38px !important;
  height: 34px !important;
  padding: 0 10px !important;
  border-radius: 20px !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid #33475e !important;
  color: #f1f5f9 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
  box-shadow: none !important;
  margin: 0 !important;
}

button.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.16) !important;
  border-color: #70b6ff !important;
  color: #70b6ff !important;
  transform: scale(1.04);
}

/* Light Theme Overrides */
html[data-theme="light"],
body[data-theme="light"] {
  color-scheme: light !important;
  background-color: #f1f5f9 !important;
  color: #020617 !important;
}

html[data-theme="light"] body {
  background: radial-gradient(ellipse at top right, #e2e8f0 0, #f8fafc 60%) !important;
  background-color: #f8fafc !important;
  color: #020617 !important;
}

html[data-theme="light"] p,
html[data-theme="light"] span,
html[data-theme="light"] label,
html[data-theme="light"] li,
html[data-theme="light"] td,
html[data-theme="light"] div {
  color: inherit;
}

html[data-theme="light"] .brand {
  color: #020617 !important;
}

html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4 {
  color: #020617 !important;
}

html[data-theme="light"] .intro,
html[data-theme="light"] .muted,
html[data-theme="light"] p.muted,
html[data-theme="light"] small.muted {
  color: #334155 !important;
}

html[data-theme="light"] .eyebrow {
  color: #0284c7 !important;
}

html[data-theme="light"] .badge {
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
  background: #ffffff !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .badge:hover,
html[data-theme="light"] .badge-link:hover {
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] .card,
html[data-theme="light"] .sym-card,
html[data-theme="light"] .news-panel,
html[data-theme="light"] .orders-panel,
html[data-theme="light"] .st-panel,
html[data-theme="light"] .watchlist,
html[data-theme="light"] fieldset.settings-card {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
  color: #020617 !important;
}

html[data-theme="light"] button.theme-toggle-btn {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] button.theme-toggle-btn:hover {
  background: #f1f5f9 !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="light"] .stack-form input,
html[data-theme="light"] .bt-dialog input,
html[data-theme="light"] .record-editor input,
html[data-theme="light"] .record-editor select,
html[data-theme="light"] .watch-search input {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  color-scheme: light !important;
}

html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus {
  border-color: #0284c7 !important;
  outline-color: #0284c7 !important;
}

html[data-theme="light"] .setting {
  color: #1e293b !important;
}

html[data-theme="light"] .setting-label {
  color: #0f172a !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .setting-env {
  color: #64748b !important;
  background: #f1f5f9 !important;
}

html[data-theme="light"] .setting-help,
html[data-theme="light"] .setting-usage {
  color: #334155 !important;
}

html[data-theme="light"] .order-table th {
  color: #334155 !important;
  border-bottom-color: #cbd5e1 !important;
  font-weight: 700 !important;
}

html[data-theme="light"] .order-table td {
  border-bottom-color: #e2e8f0 !important;
  color: #020617 !important;
}

/* Profit and loss colors must never be overridden to black in light theme */
html[data-theme="light"] .up,
html[data-theme="light"] .order-table td.up,
html[data-theme="light"] .order-table td.pnl.up,
html[data-theme="light"] .order-table td > span.up,
html[data-theme="light"] .order-table small.tick.up,
html[data-theme="light"] .order-summary strong.up,
html[data-theme="light"] .card-pnl-total.up,
html[data-theme="light"] .card-pnl-live.up,
html[data-theme="light"] .pnl-cell.positive,
html[data-theme="light"] .stat-val.up,
html[data-theme="light"] .profit-val {
  color: #16a34a !important; /* vivid green */
}

html[data-theme="light"] .down,
html[data-theme="light"] .order-table td.down,
html[data-theme="light"] .order-table td.pnl.down,
html[data-theme="light"] .order-table td > span.down,
html[data-theme="light"] .order-table small.tick.down,
html[data-theme="light"] .order-summary strong.down,
html[data-theme="light"] .card-pnl-total.down,
html[data-theme="light"] .card-pnl-live.down,
html[data-theme="light"] .pnl-cell.negative,
html[data-theme="light"] .stat-val.down,
html[data-theme="light"] .loss-val {
  color: #dc2626 !important; /* vivid red */
}

html[data-theme="light"] .order-table td small {
  color: #475569 !important;
}

html[data-theme="light"] .order-summary div {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] .order-summary small,
html[data-theme="light"] .order-summary .summary-sub {
  color: #475569 !important;
}

html[data-theme="light"] .tab {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

html[data-theme="light"] .tab strong {
  color: #020617 !important;
}

html[data-theme="light"] .tab small {
  color: #475569 !important;
}

html[data-theme="light"] .tab[aria-selected="true"] {
  background: #0284c7 !important;
  color: #ffffff !important;
  border-color: #0284c7 !important;
}

html[data-theme="light"] .tab[aria-selected="true"] strong {
  color: #ffffff !important;
}

html[data-theme="light"] .tab[aria-selected="true"] small {
  color: #e0f2fe !important;
}

html[data-theme="light"] .chip {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .chip:hover {
  border-color: #0284c7 !important;
}

html[data-theme="light"] .trade-settings {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] .trade-settings select.broker,
html[data-theme="light"] .trade-settings select.option-by {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .card-pnl-box {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="light"] .atm-options-box {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="light"] .orders .order {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="light"] .orders .order small {
  color: #64748b !important;
}

html[data-theme="light"] .status-filter {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

html[data-theme="light"] .status-filter[aria-pressed="true"] {
  background: #0284c7 !important;
  color: #ffffff !important;
  border-color: #0284c7 !important;
}

html[data-theme="light"] button.outline {
  background: transparent !important;
  color: #0284c7 !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] button.outline:hover {
  background: #f1f5f9 !important;
  border-color: #0284c7 !important;
}

html[data-theme="light"] button:not(.outline):not(.badge-button):not(.close):not(.monitor-toggle):not(.quick-prompt):not(.theme-toggle-btn) {
  background: #0284c7 !important;
  color: #ffffff !important;
}

html[data-theme="light"] button:not(.outline):not(.badge-button):not(.close):not(.monitor-toggle):not(.quick-prompt):not(.theme-toggle-btn):hover {
  filter: brightness(0.95) !important;
}

html[data-theme="light"] #notice {
  background: #fef9c3 !important;
  border-left-color: #ca8a04 !important;
  color: #713f12 !important;
}

html[data-theme="light"] footer {
  border-top-color: #e2e8f0 !important;
  color: #64748b !important;
}

html[data-theme="light"] .bt-dialog,
html[data-theme="light"] .record-editor {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .bt-dialog label,
html[data-theme="light"] .record-editor label {
  color: #334155 !important;
}

html[data-theme="light"] .results {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] .results button {
  color: #0f172a !important;
}

html[data-theme="light"] .results button:hover {
  background: #f1f5f9 !important;
}

html[data-theme="light"] .st-formula-preview {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .st-group-top {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] .st-indicator-row {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="light"] .st-indicators-panel {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

/* Chat & AI Widget light mode */
html[data-theme="light"] .chatbot-window {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15) !important;
}

html[data-theme="light"] .chatbot-header {
  background: #f8fafc !important;
  border-bottom-color: #e2e8f0 !important;
}

html[data-theme="light"] .bot-name {
  color: #0f172a !important;
}

html[data-theme="light"] .chatbot-messages {
  background: #f8fafc !important;
}

html[data-theme="light"] .bot-msg .chat-bubble {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="light"] .chat-instrument-select {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] #chatbot-form {
  background: #ffffff !important;
  border-top-color: #e2e8f0 !important;
}

html[data-theme="light"] .quick-prompt {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0369a1 !important;
}

html[data-theme="light"] .quick-prompt:hover {
  background: #e0f2fe !important;
  border-color: #38bdf8 !important;
}

html[data-theme="light"] .chat-input-container {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] .chat-textarea {
  color: #0f172a !important;
}

html[data-theme="light"] .ai-attach-btn,
html[data-theme="light"] #monitoring-ai-file-label,
html[data-theme="light"] #chat-file-label,
html[data-theme="light"] .chatbox-attach-btn {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] .ai-box {
  border-color: #cbd5e1 !important;
  background: #f8fafc !important;
}

html[data-theme="light"] .signal {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .signal.BUY {
  background: #dcfce7 !important;
  color: #15803d !important;
}

html[data-theme="light"] .signal.SELL {
  background: #fee2e2 !important;
  color: #b91c1c !important;
}

/* Scanner results use a dark palette by default; restyle the table for light mode. */
html[data-theme="light"] .scanner-table {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .scanner-table th {
  background: #f1f5f9 !important;
  border-bottom-color: #cbd5e1 !important;
  color: #334155 !important;
}

html[data-theme="light"] .scanner-table td {
  background: #ffffff !important;
  border-bottom-color: #e2e8f0 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .scanner-table tbody tr:hover td {
  background: #f8fafc !important;
}

.scanner-saved-section { margin: 20px 0 26px; }
.scanner-saved-section > h2 { font-size: 19px; margin: 0 0 14px; }
.scanner-item-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
.scanner-item-card { min-width: 0; }
.scanner-item-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.scanner-item-fields label { display: grid; gap: 6px; color: #a7bfdc; font-size: 13px; }
.scanner-item-fields input, .scanner-item-fields select { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #33475e; border-radius: 8px; background: #0a1422; color: inherit; font: inherit; }
.scanner-item-fields .scanner-refresh-card { display: flex; align-items: center; gap: 9px; }
.scanner-item-fields .scanner-refresh-card input { width: 16px; height: 16px; }
.scanner-item-card.selected { border-color: #70b6ff; box-shadow: 0 0 0 1px #70b6ff55; }
.scanner-item-badges { display: flex; gap: 6px; align-items: center; }
.scanner-run-state { display: inline-block; border-radius: 14px; padding: 4px 8px; font-size: 10px; font-weight: 750; color: #a7bfdc; background: #22344b; }
.scanner-run-state.running { color: #58d5aa; background: #123d30; }
.scanner-item-exchange { border: 1px solid #33475e; border-radius: 14px; padding: 4px 9px; color: #a7bfdc; font-size: 11px; font-weight: 700; }
.scanner-item-summary, .scanner-item-strategy { margin: 0; color: #a7b8cc; font-size: 13px; }
.scanner-item-strategy { color: #71b7ff; }
.scanner-item-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.scanner-item-actions button { width: auto; flex: 1; padding: 9px 10px; font-size: 12px; }
@media (max-width: 600px) { .scanner-item-fields { grid-template-columns: 1fr; } }

html[data-theme="light"] .scanner-item-card.selected { border-color: #0284c7 !important; box-shadow: 0 0 0 1px #0284c733 !important; }
html[data-theme="light"] .scanner-item-exchange { border-color: #cbd5e1 !important; background: #f8fafc !important; color: #334155 !important; }
html[data-theme="light"] .scanner-item-summary { color: #475569 !important; }
html[data-theme="light"] .scanner-item-strategy { color: #0369a1 !important; }
html[data-theme="light"] .scanner-item-fields label { color: #334155 !important; }
html[data-theme="light"] .scanner-item-fields input,
html[data-theme="light"] .scanner-item-fields select { background: #ffffff !important; border-color: #cbd5e1 !important; color: #0f172a !important; }
html[data-theme="light"] .scanner-run-state { color: #475569; background: #e2e8f0; }
html[data-theme="light"] .scanner-run-state.running { color: #15803d; background: #dcfce7; }

.scanner-dialog { width: min(980px, calc(100vw - 32px)); max-height: min(82vh, 900px); overflow: auto; border: 1px solid #33475e; border-radius: 16px; padding: 22px; background: #111d2e; color: #e7edf7; }
.scanner-dialog::backdrop { background: #050a12bb; }
.scanner-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.scanner-dialog-head h2, .scanner-dialog-head p { margin: 0; }
.scanner-dialog-head button { width: auto; }
.scanner-stocks-list { display: grid; gap: 8px; }
.scanner-stock-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto; align-items: center; gap: 14px; padding: 12px; border: 1px solid #293a50; border-radius: 10px; background: #0b1220; }
.scanner-stock-main, .scanner-stock-order { display: grid; gap: 4px; }
.scanner-stock-main span, .scanner-stock-order small { color: #a7b8cc; font-size: 12px; }
.scanner-order-status { justify-self: start; border-radius: 12px; padding: 4px 9px; color: #fde68a; background: #423517; font-size: 11px; font-weight: 750; }
.scanner-stock-actions button { width: auto; padding: 8px 12px; }
.scanner-formula-dialog { width: min(900px, calc(100vw - 32px)); }
.scanner-formula-content { display: grid; gap: 10px; white-space: normal; overflow-wrap: anywhere; font: inherit; font-size: 13px; line-height: 1.55; padding: 4px 0; }
.scanner-formula-rule { border: 1px solid #33475e; border-left: 4px solid #64748b; border-radius: 10px; padding: 12px; background: #101b2b; }
.scanner-formula-rule.is-true { border-left-color: #22c55e; }
.scanner-formula-rule.is-false { border-left-color: #ef4444; }
.scanner-formula-rule-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; }
.scanner-formula-state { border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 800; background: #475569; color: #fff; white-space: nowrap; }
.scanner-formula-state.is-true { background: #15803d; }
.scanner-formula-state.is-false { background: #b91c1c; }
.scanner-formula-expression { margin: 10px 0; padding: 9px 11px; border-radius: 7px; background: #1e293b; border: 1px solid #475569; font: 12px/1.5 Consolas, monospace; }
.scanner-formula-expression.is-true { color: #22c55e; border-color: #22c55e66; background: #052e1a; }
.scanner-formula-expression.is-false { color: #f87171; border-color: #ef444466; background: #3b1010; }
.scanner-formula-conditions { display: grid; gap: 6px; }
.scanner-formula-condition { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid #33475e; border-radius: 7px; }
.scanner-formula-condition.is-true { border-color: #22c55e66; }
.scanner-formula-condition.is-false { border-color: #ef444466; }
.scanner-formula-indicators { margin-top: 12px; }
.scanner-formula-indicators summary { cursor: pointer; color: #0284c7; font-weight: 700; }
.scanner-formula-indicator { padding: 8px 10px; border-bottom: 1px solid #33475e; }
html[data-theme="light"] .scanner-dialog { background: #ffffff !important; color: #0f172a !important; border-color: #cbd5e1 !important; }
html[data-theme="light"] .scanner-stock-row { background: #ffffff !important; border-color: #e2e8f0 !important; }
html[data-theme="light"] .scanner-stock-main span, html[data-theme="light"] .scanner-stock-order small { color: #475569 !important; }
html[data-theme="light"] .scanner-formula-rule { background: #f8fafc !important; border-color: #cbd5e1 !important; }
html[data-theme="light"] .scanner-formula-expression { background: #f1f5f9; border-color: #cbd5e1; }
html[data-theme="light"] .scanner-formula-expression.is-true { background: #f0fdf4; color: #15803d; }
html[data-theme="light"] .scanner-formula-expression.is-false { background: #fef2f2; color: #b91c1c; }
html[data-theme="light"] .scanner-formula-condition { border-color: #cbd5e1; }
html[data-theme="light"] .scanner-formula-indicator { border-color: #e2e8f0; }
@media (max-width: 700px) { .scanner-stock-row { grid-template-columns: 1fr; } .scanner-dialog-head { align-items: flex-start; } }

html[data-theme="light"] .signal.HOLD {
  background: #fef3c7 !important;
  color: #b45309 !important;
}

html[data-theme="light"] .state-badge.OPEN {
  background: #dcfce7 !important;
  color: #15803d !important;
}

html[data-theme="light"] .state-badge.CLOSED {
  background: #e0f2fe !important;
  color: #0369a1 !important;
}

html[data-theme="light"] .state-badge.EXPIRED {
  background: #fef3c7 !important;
  color: #b45309 !important;
}

html[data-theme="light"] .state-badge.FAILED {
  background: #fee2e2 !important;
  color: #b91c1c !important;
}

html[data-theme="light"] code {
  color: #0369a1 !important;
}

html[data-theme="light"] .warning {
  background: #fff1f2 !important;
  border-left-color: #f43f5e !important;
  color: #881337 !important;
}

/* Monitoring cards & items specific light mode styling */
html[data-theme="light"] .sym-card {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .sym-card .sym-head h3 {
  color: #020617 !important;
}

html[data-theme="light"] .sym-card .price {
  color: #020617 !important;
}

html[data-theme="light"] .sym-card .price.up {
  color: #16a34a !important;
}

html[data-theme="light"] .sym-card .price.down {
  color: #dc2626 !important;
}

html[data-theme="light"] .sym-card.stopped {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] .indicators dt {
  color: #475569 !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .indicators dd {
  color: #020617 !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .levels {
  color: #1e293b !important;
  font-weight: 500 !important;
}

html[data-theme="light"] .reason {
  color: #1e293b !important;
}

html[data-theme="light"] .contract {
  color: #475569 !important;
}

html[data-theme="light"] .trade-settings label.auto,
html[data-theme="light"] .trade-settings label.market-data-toggle {
  color: #1e293b !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .trade-settings input.amount,
html[data-theme="light"] .trade-settings input.premium {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #020617 !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .trade-settings select.broker,
html[data-theme="light"] .trade-settings select.option-by,
html[data-theme="light"] .trade-settings select.interval,
html[data-theme="light"] .trade-settings select.strategy {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #020617 !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .trade-settings select.broker.missing,
html[data-theme="light"] .trade-settings select.option-by.missing {
  border-color: #ef4444 !important;
  color: #b91c1c !important;
}

html[data-theme="light"] .atm-opt-title {
  color: #0369a1 !important;
  font-weight: 700 !important;
}

html[data-theme="light"] .atm-row {
  color: #1e293b !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .trade-settings button.clone {
  background: #ffffff !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] .trade-settings button.clone:hover:not(:disabled) {
  background: #e0f2fe !important;
}

html[data-theme="light"] .trade-settings button.remove {
  background: #ffffff !important;
  border-color: #ef4444 !important;
  color: #dc2626 !important;
}

html[data-theme="light"] .trade-settings button.remove:hover:not(:disabled) {
  background: #fee2e2 !important;
}

html[data-theme="light"] .order-row .place-order {
  background: #059669 !important;
  color: #ffffff !important;
}

html[data-theme="light"] .order-row .place-order:hover:not(:disabled) {
  background: #047857 !important;
}

html[data-theme="light"] .news a {
  color: #0369a1 !important;
}

html[data-theme="light"] .news a:hover {
  color: #0284c7 !important;
}

html[data-theme="light"] .news small {
  color: #64748b !important;
}

/* Dedicated Market AI Chat Page Light Mode */
html[data-theme="light"] .chat-page-container {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06) !important;
}

html[data-theme="light"] .chat-page-prompts {
  background: #f8fafc !important;
  border-bottom-color: #e2e8f0 !important;
}

html[data-theme="light"] #page-instrument-select {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] #chat-thread {
  background: #ffffff !important;
}

html[data-theme="light"] .chat-bubble {
  color: #020617 !important;
}

html[data-theme="light"] .bot-msg .chat-bubble {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] .bot-msg .chat-bubble p,
html[data-theme="light"] .bot-msg .chat-bubble ul,
html[data-theme="light"] .bot-msg .chat-bubble li {
  color: #1e293b !important;
}

html[data-theme="light"] #chat-page-form {
  background: #f8fafc !important;
  border-top-color: #e2e8f0 !important;
}

html[data-theme="light"] #chat-file-label {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] #chat-file-label:hover {
  background: #f1f5f9 !important;
  border-color: #0284c7 !important;
}

html[data-theme="light"] #chat-page-input {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] .card-bubble {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] .prediction-stat {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

html[data-theme="light"] .prediction-stat strong {
  color: #020617 !important;
}

html[data-theme="light"] .sr-banner {
  background: #fffbeb !important;
  border-left-color: #f59e0b !important;
  color: #92400e !important;
}

html[data-theme="light"] .chat-levels-grid {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="light"] .chat-levels-grid .level-box .lbl {
  color: #475569 !important;
  font-weight: 600 !important;
}

html[data-theme="light"] .chat-levels-grid .level-box .val {
  color: #020617 !important;
  font-weight: 700 !important;
}

html[data-theme="light"] .chat-answer-text {
  color: #020617 !important;
}

html[data-theme="light"] .chat-meta-bar {
  border-top-color: #e2e8f0 !important;
  color: #475569 !important;
}

html[data-theme="light"] .chat-meta-bar strong {
  color: #020617 !important;
}

html[data-theme="light"] #file-preview-bar > div {
  background: #f1f5f9 !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] #file-size-label {
  color: #64748b !important;
}

html[data-theme="light"] .toolbar-buttons label {
  color: #334155 !important;
}

/* Monitoring in-page Chat Panel Light Mode */
html[data-theme="light"] .monitoring-ai-panel {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] .monitoring-ai-panel h2 {
  color: #020617 !important;
}

html[data-theme="light"] #monitoring-ai-feed {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="light"] #monitoring-ai-feed .chat-bubble {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] #monitoring-ai-symbol {
  background: #ffffff !important;
  color: #020617 !important;
  border-color: #cbd5e1 !important;
}

/* ==========================================================================
   Broker History Page - Clean Horizontal Filter & Button Sizing
   ========================================================================== */
.filter-bar-horizontal {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  padding: 12px 18px !important;
  background: #0f172a !important;
  border: 1px solid #1e293b !important;
  border-radius: 14px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
}

.filter-bar-horizontal .filter-group {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

.filter-bar-horizontal .filter-group label {
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.7px !important;
  color: #94a3b8 !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  margin: 0 !important;
}

.filter-bar-horizontal .filter-group input,
.filter-bar-horizontal .filter-group select {
  background: #1e293b !important;
  border: 1px solid #334155 !important;
  color: #f8fafc !important;
  padding: 5px 8px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  outline: none !important;
  height: 32px !important;
  box-sizing: border-box !important;
}

.filter-bar-horizontal .filter-group input[type="date"] {
  width: 115px !important;
  text-align: center !important;
}

.filter-bar-horizontal .btn-group-horizontal {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 6px !important;
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

.filter-bar-horizontal .actions-group-horizontal {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  margin-left: auto !important;
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

/* Override default full-width blue button */
.filter-bar-horizontal button,
.filter-bar-horizontal button.chip-btn,
.broker-history-page button.chip-btn {
  width: 100px !important;
  min-width: 100px !important;
  max-width: 100px !important;
  flex: 0 0 100px !important;
  height: 32px !important;
  padding: 0 4px !important;
  margin: 0 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 30px !important;
  border-radius: 8px !important;
  border: 1px solid #334155 !important;
  background: #1e293b !important;
  color: #94a3b8 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
  transition: all 0.15s ease !important;
}

.filter-bar-horizontal button.chip-btn:hover,
.broker-history-page button.chip-btn:hover {
  background: #334155 !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

.filter-bar-horizontal button.chip-btn.active,
.broker-history-page button.chip-btn.active {
  background: rgba(56, 189, 248, 0.15) !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
  font-weight: 700 !important;
}

/* Action buttons: Export CSV & Refresh */
.filter-bar-horizontal button.action-btn,
.broker-history-page button.action-btn {
  width: 110px !important;
  min-width: 110px !important;
  max-width: 110px !important;
  flex: 0 0 110px !important;
  height: 32px !important;
  padding: 0 8px !important;
  margin: 0 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
}

.filter-bar-horizontal button#btn-export-csv {
  background: transparent !important;
  border: 1px solid #334155 !important;
  color: #94a3b8 !important;
}

.filter-bar-horizontal button#btn-export-csv:hover {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

.filter-bar-horizontal button#btn-refresh {
  background: #0284c7 !important;
  border: 1px solid #0284c7 !important;
  color: #ffffff !important;
}

.filter-bar-horizontal button#btn-refresh:hover {
  background: #0369a1 !important;
  border-color: #0369a1 !important;
}

/* Light Theme Overrides */
[data-theme="light"] .filter-bar-horizontal {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .filter-bar-horizontal .filter-group label {
  color: #475569 !important;
}

[data-theme="light"] .filter-bar-horizontal .filter-group input,
[data-theme="light"] .filter-bar-horizontal .filter-group select {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

[data-theme="light"] .filter-bar-horizontal button.chip-btn,
[data-theme="light"] .broker-history-page button.chip-btn {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #475569 !important;
}

[data-theme="light"] .filter-bar-horizontal button.chip-btn:hover,
[data-theme="light"] .broker-history-page button.chip-btn:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

[data-theme="light"] .filter-bar-horizontal button.chip-btn.active,
[data-theme="light"] .broker-history-page button.chip-btn.active {
  background: #e0f2fe !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

[data-theme="light"] .filter-bar-horizontal button#btn-export-csv {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #475569 !important;
}

[data-theme="light"] .filter-bar-horizontal button#btn-export-csv:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
}


html[data-theme="light"] .ai-quick-chips .ai-chip {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0369a1 !important;
}

html[data-theme="light"] .ai-quick-chips .ai-chip:hover {
  background: #e0f2fe !important;
  border-color: #38bdf8 !important;
}

html[data-theme="light"] #monitoring-ai-text {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] #monitoring-ai-file-preview > div {
  background: #f1f5f9 !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

/* Strategy Publication & Access Requests */
#publish-dialog {
  max-width: 520px;
}

#publish-dialog textarea {
  background: #0b1220;
  border: 1px solid #33475e;
  color: #e7edf7;
  resize: vertical;
}

html[data-theme="light"] #publish-dialog textarea {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] #pub-notification-banner {
  background: #f0f9ff !important;
  border-color: #38bdf8 !important;
}

html[data-theme="light"] #pub-notification-text {
  color: #0369a1 !important;
}

html[data-theme="light"] #incoming-requests-list .ai-box,
html[data-theme="light"] #outgoing-requests-list .ai-box {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="light"] #incoming-requests-list strong,
html[data-theme="light"] #outgoing-requests-list strong {
  color: #020617 !important;
}

/* Static IP Panel */
.static-ip-panel {
  background: #111d2ee8;
  border: 1px solid #2a3c55;
  border-radius: 16px;
}

html[data-theme="light"] .static-ip-panel {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
}

html[data-theme="light"] #global-static-ip {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #020617 !important;
}

html[data-theme="light"] .expiry-badge,
body[data-theme="light"] .expiry-badge {
  background: #fef2f2 !important;
  color: #dc2626 !important;
  border: 1px solid #fecaca !important;
  font-weight: 750 !important;
  box-shadow: 0 1px 2px rgba(220, 38, 38, 0.06) !important;
}

html[data-theme="light"] .chip.expiry-today,
body[data-theme="light"] .chip.expiry-today {
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
  background: #fef2f2 !important;
}

/* ==========================================================================
   STRATEGY EDIT PAGE LIGHT THEME OVERRIDES
   ========================================================================== */

html[data-theme="light"] .st-editor,
body[data-theme="light"] .st-editor {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
}

html[data-theme="light"] .st-rule-card,
body[data-theme="light"] .st-rule-card {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .st-rule-card.BUY {
  border-left: 4px solid #16a34a !important;
}

html[data-theme="light"] .st-rule-card.SELL {
  border-left: 4px solid #dc2626 !important;
}

html[data-theme="light"] .st-rule-header,
body[data-theme="light"] .st-rule-header {
  border-bottom: 1px solid #e2e8f0 !important;
}

html[data-theme="light"] .st-section-title {
  color: #0f172a !important;
}

html[data-theme="light"] .st-group,
body[data-theme="light"] .st-group {
  border-color: #cbd5e1 !important;
  background: #ffffff !important;
}

html[data-theme="light"] .st-group legend,
body[data-theme="light"] .st-group legend {
  color: #0f172a !important;
}

html[data-theme="light"] .st-group.BUY legend {
  color: #16a34a !important;
}

html[data-theme="light"] .st-group.SELL legend {
  color: #dc2626 !important;
}

html[data-theme="light"] .st-cond,
body[data-theme="light"] .st-cond {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .st-cond .muted,
html[data-theme="light"] .st-indicator-row .muted,
html[data-theme="light"] .st-group-head .muted {
  color: #475569 !important;
}

html[data-theme="light"] .st-group select,
html[data-theme="light"] .st-group input,
html[data-theme="light"] .st-cond select,
html[data-theme="light"] .st-cond input,
html[data-theme="light"] .st-indicator-row select,
html[data-theme="light"] .st-indicator-row input,
html[data-theme="light"] .rule-name-input,
html[data-theme="light"] .rule-side-select,
html[data-theme="light"] .rule-sl-input,
html[data-theme="light"] .rule-tp-input,
html[data-theme="light"] #s-name,
html[data-theme="light"] #s-description,
html[data-theme="light"] #s-sl,
html[data-theme="light"] #s-target {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  color-scheme: light !important;
}

html[data-theme="light"] .st-group select:focus,
html[data-theme="light"] .st-group input:focus,
html[data-theme="light"] .st-cond select:focus,
html[data-theme="light"] .st-cond input:focus,
html[data-theme="light"] .st-indicator-row select:focus,
html[data-theme="light"] .st-indicator-row input:focus {
  border-color: #0284c7 !important;
  outline-color: #0284c7 !important;
}

html[data-theme="light"] .st-group-child,
body[data-theme="light"] .st-group-child {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  border-left: 3px solid #0284c7 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .st-formula-preview,
body[data-theme="light"] .st-formula-preview {
  background: #f0fdf4 !important;
  border-color: #bbf7d0 !important;
  border-left: 3px solid #16a34a !important;
  color: #166534 !important;
}

html[data-theme="light"] .st-indicators-panel,
body[data-theme="light"] .st-indicators-panel {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .st-indicator-row,
body[data-theme="light"] .st-indicator-row {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .st-help,
body[data-theme="light"] .st-help {
  color: #475569 !important;
}

html[data-theme="light"] .st-help summary {
  color: #0284c7 !important;
}

html[data-theme="light"] .st-card,
body[data-theme="light"] .st-card {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .st-cond button.close,
html[data-theme="light"] .st-group button.close,
html[data-theme="light"] button.ind-remove-btn {
  color: #dc2626 !important;
  border-color: #fca5a5 !important;
  background: transparent !important;
}

html[data-theme="light"] .st-cond button.close:hover,
html[data-theme="light"] .st-group button.close:hover,
html[data-theme="light"] button.ind-remove-btn:hover {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
}

/* ==========================================================================
   HISTORIC MARKET DATA PAGE LIGHT THEME OVERRIDES
   ========================================================================== */

html[data-theme="light"] .overview-card,
body[data-theme="light"] .overview-card {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .overview-card h3 {
  color: #0284c7 !important;
}

html[data-theme="light"] .overview-stat strong {
  color: #0f172a !important;
}

html[data-theme="light"] .overview-stat small {
  color: #64748b !important;
}

html[data-theme="light"] .sync-banner,
body[data-theme="light"] .sync-banner {
  background: #f0f9ff !important;
  border-color: #bae6fd !important;
  color: #0369a1 !important;
}

html[data-theme="light"] .progress-bar-wrap {
  background: #e2e8f0 !important;
}

html[data-theme="light"] .progress-details {
  color: #475569 !important;
}

html[data-theme="light"] .search-input {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  color-scheme: light !important;
}

html[data-theme="light"] .status-badge.AVAILABLE,
body[data-theme="light"] .status-badge.AVAILABLE {
  background: #dcfce7 !important;
  color: #15803d !important;
  border: 1px solid #bbf7d0 !important;
  font-weight: 700 !important;
}

html[data-theme="light"] .status-badge.PARTIAL,
body[data-theme="light"] .status-badge.PARTIAL {
  background: #fef9c3 !important;
  color: #a16207 !important;
  border: 1px solid #fef08a !important;
  font-weight: 700 !important;
}

html[data-theme="light"] .status-badge.MISSING,
body[data-theme="light"] .status-badge.MISSING {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border: 1px solid #fecaca !important;
  font-weight: 700 !important;
}

html[data-theme="light"] .data-pill {
  color: #475569 !important;
}

html[data-theme="light"] .data-pill strong {
  color: #0f172a !important;
}

html[data-theme="light"] .data-pill-missing {
  color: #94a3b8 !important;
}

html[data-theme="light"] .quick-chip,
body[data-theme="light"] .quick-chip {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

html[data-theme="light"] .quick-chip:hover,
body[data-theme="light"] .quick-chip:hover {
  background: #e2e8f0 !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] #coverage-table th {
  background: #f8fafc !important;
  color: #334155 !important;
  border-bottom: 2px solid #cbd5e1 !important;
}

html[data-theme="light"] #coverage-table td {
  border-bottom: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

html[data-theme="light"] #coverage-table tr:hover td {
  background: #f8fafc !important;
}

html[data-theme="light"] .action-btn-sync {
  background: #ffffff !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

html[data-theme="light"] .action-btn-sync:hover {
  background: #f0f9ff !important;
}

/* Child-leg details follow the active page theme. */
html[data-theme="light"] .order-table tr.leg-child-row > td,
body[data-theme="light"] .order-table tr.leg-child-row > td {
  background: #f8fafc !important;
  color: #0f172a !important;
}

html[data-theme="light"] .leg-child-table,
body[data-theme="light"] .leg-child-table {
  background: #ffffff !important;
  color: #0f172a !important;
}

html[data-theme="light"] .leg-child-table th,
body[data-theme="light"] .leg-child-table th {
  color: #475569 !important;
  border-bottom-color: #cbd5e1 !important;
}

html[data-theme="light"] .leg-child-table td,
body[data-theme="light"] .leg-child-table td {
  color: #0f172a !important;
  border-bottom-color: #e2e8f0 !important;
}

html[data-theme="light"] .leg-child-table td.up,
body[data-theme="light"] .leg-child-table td.up {
  color: #15803d !important;
}

html[data-theme="light"] .leg-child-table td.down,
body[data-theme="light"] .leg-child-table td.down {
  color: #dc2626 !important;
}

/* Strategy formula popup follows the active page theme, including inline rule colors. */
html[data-theme="light"] dialog.formula-dialog,
body[data-theme="light"] dialog.formula-dialog {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2) !important;
}

html[data-theme="light"] .formula-dialog .formula-toolbar,
body[data-theme="light"] .formula-dialog .formula-toolbar {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .formula-dialog .formula-group-card,
body[data-theme="light"] .formula-dialog .formula-group-card {
  background: #ffffff !important;
  border-top-color: #cbd5e1 !important;
  border-right-color: #cbd5e1 !important;
  border-bottom-color: #cbd5e1 !important;
  color: #0f172a !important;
}

html[data-theme="light"] .formula-dialog .formula-group-head,
body[data-theme="light"] .formula-dialog .formula-group-head {
  border-bottom-color: #e2e8f0 !important;
}

html[data-theme="light"] .formula-dialog .formula-framed-banner,
body[data-theme="light"] .formula-dialog .formula-framed-banner {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

html[data-theme="light"] .formula-dialog .formula-framed-banner.is-true,
body[data-theme="light"] .formula-dialog .formula-framed-banner.is-true,
html[data-theme="light"] .formula-dialog .formula-sub-expression.is-true,
body[data-theme="light"] .formula-dialog .formula-sub-expression.is-true {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}

html[data-theme="light"] .formula-dialog .formula-framed-banner.is-false,
body[data-theme="light"] .formula-dialog .formula-framed-banner.is-false,
html[data-theme="light"] .formula-dialog .formula-sub-expression.is-false,
body[data-theme="light"] .formula-dialog .formula-sub-expression.is-false {
  background: #fef2f2 !important;
  border-color: #fca5a5 !important;
  color: #b91c1c !important;
}

html[data-theme="light"] .formula-dialog .formula-sub-expression,
body[data-theme="light"] .formula-dialog .formula-sub-expression {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

html[data-theme="light"] .formula-dialog .formula-framed-banner span,
body[data-theme="light"] .formula-dialog .formula-framed-banner span,
html[data-theme="light"] .formula-dialog .formula-sub-expression span,
body[data-theme="light"] .formula-dialog .formula-sub-expression span {
  color: #475569 !important;
}

html[data-theme="light"] .formula-dialog .formula-cond-card.is-true,
body[data-theme="light"] .formula-dialog .formula-cond-card.is-true {
  background: #ecfdf5 !important;
  border-color: #86efac !important;
  color: #166534 !important;
}

html[data-theme="light"] .formula-dialog .formula-cond-card.is-false,
body[data-theme="light"] .formula-dialog .formula-cond-card.is-false {
  background: #fef2f2 !important;
  border-color: #fca5a5 !important;
  color: #991b1b !important;
}

html[data-theme="light"] .formula-dialog .formula-cond-badge.TRUE,
body[data-theme="light"] .formula-dialog .formula-cond-badge.TRUE {
  background: #dcfce7 !important;
  border-color: #86efac !important;
  color: #166534 !important;
}

html[data-theme="light"] .formula-dialog .formula-cond-badge.FALSE,
body[data-theme="light"] .formula-dialog .formula-cond-badge.FALSE {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
  color: #991b1b !important;
}

html[data-theme="light"] .formula-dialog .formula-connector,
body[data-theme="light"] .formula-dialog .formula-connector {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #7dd3fc;
  padding: 1px 8px;
  border-radius: 10px;
  letter-spacing: 1px;
}

html[data-theme="light"] .formula-dialog .formula-conds-details summary,
body[data-theme="light"] .formula-dialog .formula-conds-details summary {
  color: #0369a1 !important;
}

html[data-theme="light"] .formula-dialog .btn-rule-live-val,
body[data-theme="light"] .formula-dialog .btn-rule-live-val {
  background: #ffffff !important;
  color: #0369a1 !important;
  border-color: #7dd3fc !important;
}











