/* Shared presentation tokens. No trading, accounting or execution rules live here.
 * shadcn-inspired controls, layered porcelain-blue surfaces and visual-only feedback.
 */
:root {
  color-scheme: light;
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  --background: #eaf0fb;
  --foreground: #172237;
  --card: #fff;
  --card-foreground: #172237;
  --primary: #3665f9;
  --primary-hover: #2851d8;
  --primary-foreground: #fff;
  --secondary: #e5edff;
  --secondary-foreground: #2b50bc;
  --muted-surface: #f0f4fc;
  --muted-foreground: #4b5e7b;
  --destructive: #b42338;
  --destructive-surface: #fff1f3;
  --border: #c4d3ec;
  --input: #aabfe0;
  --ring: #3665f9;
  --radius: 14px;
  --radius-sm: 7px;
  --shadow-sm: 0 2px 4px rgba(31, 65, 122, .08), inset 0 1px 0 rgba(255, 255, 255, .9);
  --shadow-md: 0 16px 40px rgba(31, 65, 122, .14), 0 3px 10px rgba(31, 65, 122, .07);
  --card-shadow: 0 9px 24px rgba(31, 65, 122, .10), 0 2px 5px rgba(31, 65, 122, .05), inset 0 1px 0 #fff;
  --card-shadow-raised: 0 18px 34px rgba(31, 65, 122, .17), 0 5px 10px rgba(31, 65, 122, .08), inset 0 1px 0 #fff;
  --surface-inset: rgba(255, 255, 255, .62);
  /* Existing renderers use these aliases. Preserve red gains / green losses. */
  --bg: var(--background); --bg-2: var(--muted-surface);
  --panel: var(--card); --panel-2: var(--muted-surface); --panel-hover: #edf2fa;
  --text: var(--foreground); --text-2: #33445e;
  --muted: var(--muted-foreground); --muted-2: var(--muted-foreground);
  --border-light: var(--input); --accent: var(--primary); --accent-2: #6b8bff;
  --purple: var(--primary); --info: var(--primary);
  --up: #b3233c; --up-glow: #fff0f2;
  --down: #07694f; --down-glow: #eaf8f2; --green: var(--down);
  --warn: #945600; --warn-surface: #fff8e8;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 108px; }
body {
  margin: 0; color: var(--foreground); font: 14px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased;
  background: radial-gradient(ellipse at 2% 22%, #b7d1fa66, transparent 50%), radial-gradient(ellipse at 100% 5%, #c4cafa66, transparent 50%), linear-gradient(150deg, #eaf0fc, #f1f5fb 58%, #e2eff5);
  background-attachment: fixed;
}
::selection { background: #dce6ff; color: #173b9b; }
button, input, select, textarea { font: inherit; }
button, a, select, summary { -webkit-tap-highlight-color: transparent; }
button, select, input, a, summary { touch-action: manipulation; }
a { color: var(--primary); text-underline-offset: 4px; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { opacity: .5; cursor: not-allowed; }
:is(button, a, select, input, summary, [tabindex]):focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { display: inline-block; width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.mono, .mono-cell, .mono-col, .stat-big, .trade-summary-value, .mini-stats b { font-family: var(--font-sans); font-variant-numeric: tabular-nums lining-nums; }
.skip-link { position: fixed; top: -70px; left: 16px; z-index: 500; padding: 10px 16px; background: var(--card); border-radius: var(--radius-sm); }
.skip-link:focus { top: 10px; }
.app-header { position: sticky; top: 0; z-index: 50; background: linear-gradient(115deg, #10284e, #193f82 70%, #2455aa); border-bottom: 1px solid #7093d4; box-shadow: 0 4px 18px #17366526, inset 0 -1px 0 #ffffff12; color: #fff; }
.header-inner { max-width: 1664px; min-height: 72px; margin: auto; padding: 12px 32px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; border: 1px solid #89a9d8; box-shadow: 0 3px 10px #071c3c40; }
.brand-title { display: flex; align-items: center; gap: 10px; }
.brand-text h1 { font-size: 18px; font-weight: 650; line-height: 1.4; margin: 0; letter-spacing: -.3px; }
.ver { font-size: 11px; border: 1px solid #526789; border-radius: 5px; padding: 0 6px; color: #dfebff; line-height: 20px; }
.deployment-badge { display: inline-flex; align-items: center; max-width: 100%; min-height: 30px; padding: 4px 10px; border: 1px solid #779bd3; border-radius: 6px; background: #e8f0ff; color: #153c85; font-size: 14px; font-weight: 650; line-height: 1.5; }
.app-header .deployment-badge { background: #eff5ff; color: #123674; border-color: #9bb8e7; }
.login-card .environment-line { margin: 10px 0 16px; }
.brand-text .meta { font-size: 12px; color: #c7d4e9; margin-top: 3px; max-width: 580px; }
.brand-text .meta [style*="var(--warn)"] { color: #ffcc78 !important; }
.app-nav { display: flex; gap: 4px; margin-right: auto; }
.app-nav a { text-decoration: none; color: #dce7fb; border-radius: var(--radius-sm); padding: 8px 12px; white-space: nowrap; font-size: 13px; transition: background-color .16s, box-shadow .16s; }
.app-nav a:hover, .app-nav a:focus-visible { color: #fff; background: #223c64; }
.header-right { display: flex; align-items: center; gap: 20px; flex: none; font-size: 12px; color: #c7d4e9; }
.refresh-meta { text-align: right; }
.upd { color: #e1e9f8; }
#last-update-abs { font-variant-numeric: tabular-nums; margin-left: 5px; }
.refresh-next { display: flex; justify-content: flex-end; align-items: center; gap: 5px; color: #bccae0; margin-top: 3px; }
.refresh-bar { width: 48px; height: 3px; border-radius: 9px; background: #3a4e71; overflow: hidden; margin-left: 3px; }
.refresh-bar-fill { display: block; height: 100%; width: 0; background: #9bb5ff; transition: width .5s linear; }
.btn, .btn-logout, .btn-close-pos, .rng-btn, .alt-tab, .history-toggle, .trade-filter-select {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 12px; line-height: 20px; font-size: 13px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius-sm); white-space: nowrap;
  transition: background-color .16s, color .16s, border-color .16s, box-shadow .16s, transform .16s;
}
.btn-primary { background: linear-gradient(180deg, #3665f9, #2d59e5); color: var(--primary-foreground); border-color: #2d56dd; box-shadow: 0 3px 7px #3665f92b, inset 0 1px 0 #ffffff38; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #3864ec, #244dc7); border-color: var(--primary-hover); }
.btn-outline, .trade-filter-select { background: linear-gradient(180deg, #fff, #f1f5ff); border-color: var(--input); color: #274a81; box-shadow: var(--shadow-sm); }
.btn-outline:hover:not(:disabled), .trade-filter-select:hover { background: #e7efff; border-color: #7699d3; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--muted-surface); color: var(--text); }
.btn-icon { width: 36px; padding: 0; flex: none; }
.btn-destructive { background: linear-gradient(180deg, #c12d42, #a31d32); border-color: var(--destructive); color: #fff; box-shadow: 0 3px 7px #a31d3221, inset 0 1px 0 #ffffff26; }
.btn-destructive:hover:not(:disabled) { background: #99182c; }
.btn-logout { background: #ffffff0f; border-color: #809fd0; color: #fff; box-shadow: inset 0 1px 0 #ffffff1a; }
.btn-logout:hover { background: #2b4873; border-color: #829bc0; }
.btn-close-pos { color: var(--destructive); background: var(--destructive-surface); border-color: #e7b8c1; min-height: 32px; padding: 5px 10px; }
.btn-close-pos:hover:not(:disabled) { background: #ffe2e8; border-color: var(--destructive); }
.buy-control { margin-top: 28px; padding: 16px; border: 1px solid #bfccdf; border-radius: 10px; background: linear-gradient(145deg, #fff, #e8effb); box-shadow: var(--shadow-sm); }
.buy-control-heading { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; color: #284978; }
.buy-control-state { display: block; margin: 12px 0 6px; font-size: 14px; font-weight: 600; }
.buy-control p { margin: 8px 0; font-size: 12px; line-height: 1.65; color: var(--muted-foreground); overflow-wrap: anywhere; }
.buy-control .btn { width: 100%; margin-top: 10px; min-height: 40px; white-space: normal; }
.btn-pause-buy { color: #813d12; border-color: #c79353; background: linear-gradient(180deg, #fff8ea, #f6e4c5); box-shadow: var(--shadow-sm); }
.btn-pause-buy:hover:not(:disabled) { color: #6c3009; background: #f1dbb2; border-color: #a86722; }
.buy-control[data-state="paused"] { background: linear-gradient(145deg, #fffaf0, #f9ecd5); border-color: #c79353; }
.buy-control[data-state="paused"] .buy-control-state { color: #813d12; }
.buy-control[data-state="enabled"] .buy-control-state { color: #07694f; }
.buy-control[data-state="pending"] .buy-control-state, .buy-control[data-state="unconfirmed"] .buy-control-state { color: #945600; }
.buy-control .buy-control-error { color: var(--destructive); }
.segmented { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid #b7c9e8; border-radius: 9px; background: #e2eaf8; box-shadow: inset 0 1px 3px #284d8a10, 0 1px 0 #ffffffcc; flex: none; }
.rng-btn, .alt-tab { min-height: 30px; padding: 4px 11px; color: var(--muted); background: transparent; border-radius: 6px; }
.rng-btn:hover, .alt-tab:hover { color: #204bb7; background: #f6f9ff; }
.rng-btn.active, .alt-tab.active { color: #fff; background: linear-gradient(180deg, #3665f9, #2d59e5); border-color: #2e59e4; box-shadow: 0 3px 7px #3665f938, inset 0 1px 0 #ffffff40; }
.alt-count { font-size: 11px; min-width: 18px; padding: 0 5px; border-radius: 4px; background: #e3e8f0; color: var(--muted); line-height: 18px; }
.alt-tab.active .alt-count { background: #ffffff30; color: #fff; }
.container { max-width: 1664px; margin: auto; padding: 30px 32px 24px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: #5a6e8c; font-size: 10px; font-weight: 650; letter-spacing: .14em; margin: 0 0 5px; }
.page-heading h2 { margin: 0; font-size: 26px; line-height: 1.35; letter-spacing: -.7px; font-weight: 650; }
.page-description { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.page-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge, .chip, .incident-badge { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 2px 8px; min-height: 24px; border-radius: 6px; border: 1px solid transparent; font-size: 12px; font-weight: 500; line-height: 18px; vertical-align: middle; }
.badge-up { color: var(--up); background: var(--up-glow); border-color: #f5ccd3; }
.badge-down { color: var(--down); background: var(--down-glow); border-color: #bce5d7; }
.badge-info, .chip { color: var(--secondary-foreground); background: var(--secondary); border-color: #d3defb; }
.badge-neutral, .incident-badge { color: #52627a; background: var(--muted-surface); border-color: var(--border); }
.badge-warn { color: var(--warn); background: var(--warn-surface); border-color: #ead7ad; }
.badge-crit { color: var(--destructive); background: var(--destructive-surface); border-color: #e9bac3; }
.incident-badge { margin-left: 7px; min-height: 20px; line-height: 16px; font-size: 11px; }
.pos { color: var(--up); } .neg { color: var(--down); }
.risk-bar { display: flex; align-items: center; flex-wrap: wrap; column-gap: 20px; row-gap: 6px; padding: 12px 16px; margin-bottom: 20px; border: 1px solid #b8cae7; border-radius: 9px; background: linear-gradient(110deg, #f8fbffed, #e5edfbcc); box-shadow: inset 0 1px 0 #fff, 0 3px 9px #294c7e08; color: #43516a; font-size: 12px; }
.risk-title { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: #263c5f; }
.risk-title .icon { width: 16px; height: 16px; }
#risk-flag { margin-left: auto; }
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.overview-grid { margin-bottom: 20px; }
.card {
  position: relative; isolation: isolate; min-width: 0; padding: 22px;
  border: 1px solid #b8cdeb; border-radius: var(--radius);
  background: radial-gradient(ellipse at 100% 0, #b4d7fa45, transparent 60%), linear-gradient(140deg, #ffffff, #eef4ff 70%, #e4eefb);
  box-shadow: var(--card-shadow);
  transition: transform .22s cubic-bezier(.2,.7,.3,1), box-shadow .22s ease, border-color .22s ease;
}
.card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px #ffffff99; pointer-events: none; }
.card:focus-within { border-color: #789bd6; box-shadow: 0 0 0 2px #3665f91a, var(--card-shadow-raised); }
.card h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.5; color: var(--foreground); display: flex; align-items: center; gap: 9px; }
.card h3 > .icon { color: #3965a5; width: 27px; height: 27px; padding: 5px; border-radius: 7px; background: #ffffffa6; box-shadow: inset 0 0 0 1px #bdd1f0, 0 2px 4px #254c7f0a; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-description { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 4px 0 0; }
.card-header > .section-description { text-align: right; }
.card.kpi { padding: 20px; }
.kpi h3 { color: #344f78; font-size: 13px; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.kpi-equity { border-color: #9cb9ed; background: radial-gradient(ellipse at 100% 0, #91b8ff52, transparent 68%), linear-gradient(145deg, #f8fbff, #dfeaff 54%, #cbdffd); }
.overview-grid > .kpi:nth-child(2) { background: radial-gradient(ellipse at 100% 0, #b1d9f466, transparent 65%), linear-gradient(145deg, #fbfdff, #e1edfa 54%, #d3e7f3); }
.overview-grid > .kpi:nth-child(3) { background: radial-gradient(ellipse at 100% 0, #b4bdf852, transparent 65%), linear-gradient(145deg, #fdfcff, #e9e9fa 54%, #dbe4fb); }
.overview-grid > .kpi:nth-child(4) { background: radial-gradient(ellipse at 100% 0, #a7d8e34d, transparent 65%), linear-gradient(145deg, #fcfeff, #e0eff4 54%, #d7e7f7); }
.kpi > .stat-big { padding: 10px 12px; min-height: 62px; border: 1px solid #ffffffd9; border-radius: 9px; background: var(--surface-inset); box-shadow: inset 0 1px 0 #fff, 0 2px 7px #2d509610; color: #193b73; }
.stat-big { font-size: 30px; font-weight: 650; line-height: 1.25; letter-spacing: -.8px; min-height: 38px; margin-bottom: 10px; }
.stat-big .badge { font-size: 13px; padding: 4px 10px; letter-spacing: 0; }
.stat-sub, .stat-sub-2, .kpi-detail { font-size: 12px; line-height: 1.8; color: var(--muted); overflow-wrap: anywhere; }
.stat-sub-2 { margin-top: 10px; }
.kpi-detail { margin-top: 10px; padding: 9px 11px; border: 1px solid #ffffffb3; border-radius: 8px; background: #ffffff66; box-shadow: inset 0 1px 0 #ffffffb3; }
.kpi-detail div { gap: 6px 14px !important; }
.kpi-link { display: inline-flex; gap: 8px; margin-top: 22px; }
.text-link { font-size: 12px; font-weight: 500; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.metric-pair { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.metric-pair b { color: var(--foreground); font-weight: 600; }
.stage-rules { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.stage-rules .rule-values { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.strategy-details { color: var(--muted); font-size: 12px; margin-top: 10px; }
.strategy-details summary { cursor: pointer; color: #2753c8; padding: 3px 0; border-radius: 5px; }
.strategy-details summary:hover { color: #183f9a; text-decoration: underline; text-underline-offset: 3px; }
.strategy-details .stat-sub-2 { margin-top: 6px; }
.universe-card { padding: 16px 20px; margin-bottom: 20px; }
.universe-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.universe-heading h3 { font-size: 13px; }
.universe-grid { display: grid; grid-template-columns: repeat(10,minmax(0,1fr)); gap: 8px; }
.market-item { min-width: 0; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; column-gap: 6px; padding: 8px 10px; border: 1px solid #bdcfee; border-radius: var(--radius-sm); background: linear-gradient(145deg, #ffffffed, #e4edfc); box-shadow: inset 0 1px 0 #fff, 0 2px 4px #294c7e08; font-size: 12px; transition: background-color .18s, border-color .18s, box-shadow .18s, transform .18s; }
.market-item strong { font-weight: 600; color: #344963; }
.market-item span { font-variant-numeric: tabular-nums; }
.market-item.is-unavailable { background: var(--warn-surface); color: var(--warn); }
.analytics-grid { grid-template-columns: minmax(0, 1.65fr) minmax(340px, 1fr); align-items: start; margin-bottom: 20px; }
.chart-wrap { position: relative; height: 342px; padding: 12px 10px 6px; border: 1px solid #ffffffd9; border-radius: 10px; background: #ffffffb8; box-shadow: inset 0 1px 0 #fff; }
.mini-stats { display: flex; flex-wrap: wrap; column-gap: 20px; row-gap: 6px; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; color: var(--muted); font-size: 12px; }
#curve-range-label { flex-basis: 100%; font-size: 11px; }
.mini-stats b { font-weight: 600; color: var(--text-2); margin-left: 4px; }
#curve-initial { color: var(--primary); }
.earnings-card { background: radial-gradient(ellipse at 100% 0, #bccbf752, transparent 60%), linear-gradient(145deg, #fefeff, #e7edf9); }
.earnings-card .card-header { margin-bottom: 16px; }
.pnl-hero { padding: 14px 16px; background: linear-gradient(120deg, #f3f7ff, #d6e4ff); border: 1px solid #adc5ee; border-radius: 10px; margin-bottom: 14px; box-shadow: inset 0 1px 0 #fff, 0 3px 8px #284d8a0a; }
.pnl-label { font-size: 12px; color: #455d82; margin-bottom: 5px; }
.pnl-total { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; font-variant-numeric: tabular-nums; }
.pnl-total > strong { font-size: 25px; font-weight: 650; letter-spacing: -.5px; }
.pnl-total > span { font-size: 13px; }
.pnl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font-size: 12px; line-height: 1.7; padding: 3px 0; }
.pnl-row > span:first-child { color: var(--muted); }
.pnl-row > span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pnl-divider { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--border); }
.pnl-cutoff { margin-top: 12px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.pnl-note { margin-top: 10px; padding: 8px 10px; background: var(--warn-surface); border: 1px solid #efdfbc; border-radius: 6px; color: var(--warn); font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.positions-card, #trade-history-card, .system-card { margin-bottom: 20px; scroll-margin-top: 104px; }
.table-wrap { max-width: 100%; overflow: auto; scrollbar-width: thin; scrollbar-color: #a8bbd9 #edf3fc; border: 1px solid #afc4e6; border-radius: 9px; background: #ffffffdb; box-shadow: 0 2px 6px #294c7e08; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 13px 14px; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; color: #37557f; background: linear-gradient(180deg, #edf3ff, #dfe9fb); }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
#trade-history-table > :is(thead,tbody) > tr > :is(th,td):nth-child(3), #trade-history-table > :is(thead,tbody) > tr > :is(th,td):nth-child(8) { text-align: left; }
td { transition: background-color .12s; }
tbody tr:last-child > td { border-bottom: none; }
tbody tr:nth-child(even) > td { background: #f5f8fe; }
tbody tr:hover > td { background: #e8f0ff; }
td b { font-weight: 600; }
.symbol-link { color: var(--foreground); font-weight: 600; text-decoration: none; }
.symbol-link:hover { color: var(--primary); text-decoration: underline; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; white-space: normal; }
.liq-bar { display: inline-block; width: 28px; height: 4px; border-radius: 4px; background: #e4eaf3; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.liq-bar-fill { display: block; height: 100%; }
.trade-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.trade-actions { display: flex; gap: 8px; }
.trade-filter-select { min-width: 148px; cursor: pointer; padding-right: 30px; }
.trade-summary-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.trade-summary-item { padding: 14px; border: 1px solid #c0cfee; border-radius: 10px; background: linear-gradient(145deg, #ffffffed, #e5edf9); box-shadow: 0 4px 12px #25477f0c, inset 0 1px 0 #fff; min-width: 0; transition: transform .2s, box-shadow .2s, border-color .2s; }
.trade-summary-item:first-child { background: linear-gradient(135deg, #f7faff, #d8e5ff); border-color: #a9c0ec; }
.trade-summary-item:nth-child(3) { background: linear-gradient(135deg, #fdfcff, #e5e7fa); }
.trade-summary-item:nth-child(4), .trade-summary-item:nth-child(5) { background: linear-gradient(135deg, #fbffff, #dceff4); border-color: #bad7e4; }
.trade-summary-label { color: var(--muted); font-size: 11px; }
.trade-summary-value { font-weight: 600; font-size: 20px; line-height: 1.4; margin-top: 6px; letter-spacing: -.35px; }
.history-quality { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.history-quality summary { cursor: pointer; padding: 4px 0; }
.history-quality summary:hover { color: var(--primary); }
.history-quality ul { padding-left: 20px; margin: 8px 0; font-size: 12px; }
.quality-warning { color: var(--warn); padding: 6px 10px; background: var(--warn-surface); border-radius: 6px; margin-top: 6px; }
.history-toggle { width: 30px; min-height: 30px; padding: 0; font-size: 21px; line-height: 1; color: #345f9d; background: linear-gradient(180deg, #fff, #eaf1ff); border-color: #c2d2ef; box-shadow: 0 2px 4px #274c850d; }
.history-toggle:hover { background: var(--secondary); color: var(--primary); border-color: #d1dcf6; }
.history-toggle .chevron { display: block; transition: transform .15s; }
.history-cycle-row.is-open .history-toggle .chevron { transform: rotate(90deg); }
.history-cycle-row.is-open > td { background: #eff4ff; }
.history-detail-row { display: none; }
.history-detail-row.is-open { display: table-row; }
.history-detail-row > td { padding: 0; background: #f8faff; white-space: normal; }
.history-detail { padding: 16px 20px 20px; border-left: 3px solid var(--primary); }
.history-detail table { font-size: 12px; }
.history-detail th, .history-detail td { padding: 10px 12px; }
.history-detail-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; color: var(--muted); margin-bottom: 12px; }
.history-estimate { color: var(--warn); font-size: 11px; margin-left: 5px; }
.system-card { display: grid; grid-template-columns: 310px minmax(0,1fr); grid-template-areas: "heading filters" "summary events"; gap: 16px 24px; }
.system-heading { grid-area: heading; min-width: 0; }
.system-summary { grid-area: summary; min-width: 0; }
.system-summary > .refresh-status { margin-top: 0; }
.system-filters.card-header { grid-area: filters; align-self: center; min-width: 0; margin: 0; flex-wrap: wrap; gap: 8px; }
/* The left column sizes the body row; long event history scrolls inside it. */
.system-events { grid-area: events; position: relative; min-width: 0; min-height: 0; }
.refresh-status { padding: 12px 14px; margin: 14px 0 8px; border: 1px solid #acd8c7; border-left: 3px solid var(--down); border-radius: 8px; background: linear-gradient(135deg, #f2fcf7, #dbf2e7); box-shadow: inset 0 1px 0 #ffffffcc; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.refresh-status strong { font-weight: 600; color: #21644f; }
.refresh-status[data-level="warn"] { border-color: #e9d6ad; border-left-color: var(--warn); background: var(--warn-surface); }
.refresh-status[data-level="warn"] strong { color: var(--warn); }
.refresh-status[data-level="error"] { border-color: #ebc3ca; border-left-color: var(--destructive); background: var(--destructive-surface); }
.refresh-status[data-level="error"] strong { color: var(--destructive); }
.alerts-list { position: absolute; inset: 0; overflow: auto; padding-right: 6px; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #b5c1d4 transparent; }
.alerts-list:focus-visible { outline-offset: -2px; }
.alert-item { padding: 13px 14px; border: 1px solid var(--border); border-left: 3px solid #87a5d5; background: linear-gradient(130deg, #ffffffed, #e8effc); box-shadow: inset 0 1px 0 #fff; border-radius: 8px; margin-bottom: 10px; }
.alert-item:last-child { margin-bottom: 0; }
.alert-item.warn { border-left-color: var(--warn); background: #fffaf0; }
.alert-item.crit { border-left-color: var(--destructive); background: #fff7f8; }
.alert-title { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; line-height: 1.7; margin-bottom: 5px; }
.alert-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.8; color: var(--muted); }
.alert-ts { font-size: 11px; white-space: nowrap; color: var(--muted); font-weight: 400; }
.incident-detail { margin-top: 8px; font-size: 11px; color: var(--muted); line-height: 1.7; overflow-wrap: anywhere; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot-ok { background: #37c898; } .dot-bad { background: #fb7185; } .dot-warn, .dot-warn-amber { background: #ffcc78; }
.footer-note { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; padding-top: 8px; }
.sep { margin: 0 7px; color: #9aa9bd; }
.ui-dialog { border: 1px solid #aec3e8; border-radius: 14px; padding: 24px; color: var(--foreground); background: linear-gradient(145deg, #fff, #edf3ff); width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto; box-shadow: 0 24px 80px #0f234a40, 0 4px 16px #0f234a1a, inset 0 1px 0 #fff; }
.ui-dialog::backdrop { background: rgba(12, 25, 48, .5); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.dialog-symbol { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--secondary); color: var(--primary); box-shadow: inset 0 0 0 1px #3665f926, inset 0 1px 0 #fff; }
.ui-dialog[data-destructive="true"] .dialog-symbol { background: var(--destructive-surface); color: var(--destructive); }
.ui-dialog h2 { margin: 0 0 10px; font-size: 19px; line-height: 1.4; font-weight: 650; }
.ui-dialog p { font-size: 14px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; line-height: 1.8; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; border-top: 4px solid var(--primary); }
.login-card { width: 100%; max-width: 400px; padding: 32px; box-shadow: var(--shadow-md); }
.login-card .logo { width: 48px; height: 48px; border-radius: 12px; display: block; margin-bottom: 22px; }
.login-card h1 { font-size: 24px; font-weight: 650; margin: 0 0 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.field { margin-bottom: 20px; }
.field label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; }
.field input { width: 100%; height: 42px; padding: 8px 12px; border: 1px solid var(--input); border-radius: var(--radius-sm); background: #fff; color: var(--foreground); font-size: 16px; }
.login-card .btn-primary { width: 100%; min-height: 42px; }
.login-card .err { display: none; color: var(--destructive); background: var(--destructive-surface); border: 1px solid #ecc9d0; border-radius: 7px; padding: 10px 12px; margin-top: 16px; font-size: 13px; }
.login-card .err.show { display: block; }
.login-card .footer { margin-top: 24px; font-size: 11px; color: var(--muted); line-height: 1.7; }
/* Surface feedback does not make a card clickable or submit a trading action. */
@media (hover: hover) and (pointer: fine) and (min-width: 641px) {
  .card:not(.login-card):hover { transform: translateY(-2px); border-color: #84a7df; box-shadow: var(--card-shadow-raised); }
  .card.kpi:hover { transform: translateY(-4px); }
  .trade-summary-item:hover { transform: translateY(-2px); border-color: #8baadd; box-shadow: 0 8px 18px #25477f1c, inset 0 1px 0 #fff; }
  .market-item:not(.is-unavailable):hover { transform: translateY(-1px); background: #dce9ff; border-color: #8baade; box-shadow: 0 3px 9px #25477f17, inset 0 1px 0 #fff; }
  :is(.btn, .btn-logout, .btn-close-pos, .rng-btn, .alt-tab, .history-toggle):hover:not(:disabled) { box-shadow: 0 4px 10px #20458026, inset 0 1px 0 #ffffff40; }
}
:is(.btn, .btn-logout, .btn-close-pos, .rng-btn, .alt-tab, .history-toggle):active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 2px 4px #1739662b; }
@media (min-width: 1600px) { .chart-wrap { height: 340px; } }
@media (max-width: 1280px) {
  .app-nav { display: none; }
  .container { padding: 24px; }
  .header-inner { padding: 12px 24px; }
  .grid { gap: 16px; }
  .grid-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .universe-grid { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .analytics-grid { grid-template-columns: minmax(0,1.3fr) minmax(330px,1fr); }
  .trade-summary-value { font-size: 18px; }
  .system-card { grid-template-columns: 280px minmax(0,1fr); column-gap: 20px; }
}
@media (max-width: 900px) {
  .analytics-grid { grid-template-columns: minmax(0,1fr); }
  .system-card { grid-template-columns: minmax(0,1fr); grid-template-areas: "heading" "summary" "filters" "events"; }
  .system-filters.card-header { margin-top: 8px; }
  .alerts-list { position: static; max-height: min(480px, 60vh); }
  .trade-summary-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .risk-bar { column-gap: 16px; }
  #risk-flag { flex-basis: 100%; margin-left: 0; }
}
@media (max-width: 600px) {
  body { background-attachment: scroll; }
  html { scroll-padding-top: 124px; }
  .header-inner { padding: 12px 16px; min-height: 72px; gap: 12px; }
  .brand-text h1 { font-size: 16px; } .brand-title { gap: 7px; } .brand { gap: 9px; }
  .brand-logo { width: 32px; height: 32px; }
  .brand-text .meta { font-size: 11px; }
  .refresh-meta { display: none; } .header-right { gap: 0; }
  .btn-logout { min-height: 36px; padding: 7px; } .btn-logout > span { display: none; }
  .container { padding: 20px 14px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .page-heading h2 { font-size: 23px; }
  .page-badges { gap: 6px; }
  .risk-bar { padding: 12px; row-gap: 7px; column-gap: 14px; }
  .risk-title { flex-basis: 100%; }
  .grid-4 { grid-template-columns: minmax(0,1fr); }
  .card, .card.kpi { padding: 18px; }
  .kpi h3 { margin-bottom: 12px; }
  .stat-big { font-size: 29px; }
  .kpi-link { margin-top: 14px; }
  .universe-heading { flex-direction: column; align-items: flex-start; gap: 4px; }
  .universe-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .market-item { padding: 8px 10px; }
  .card-header { gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
  .card-header > .section-description { text-align: left; }
  .card h3 { font-size: 14px; }
  .chart-card .card-header { align-items: flex-start; }
  .chart-wrap { height: 270px; }
  .mini-stats { gap: 6px 14px; }
  .trade-actions { width: 100%; }
  .trade-filter-select { min-width: 0; flex: 1; }
  .trade-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .trade-summary-item { padding: 12px; }
  .trade-summary-value { font-size: 19px; }
  th, td { padding: 12px; }
  .alert-tabs { width: 100%; justify-content: space-between; gap: 0; }
  .alt-tab { padding: 4px 6px; gap: 4px; font-size: 12px; }
  .alert-title { flex-wrap: wrap; gap: 4px; }
  .alert-ts { font-size: 11px; }
  .footer-note { font-size: 10px; }
  .ui-dialog { padding: 22px; }
  .dialog-actions .btn { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .card:not(.login-card):hover, .card.kpi:hover, .trade-summary-item:hover, .market-item:hover, :is(.btn, .btn-logout, .btn-close-pos, .rng-btn, .alt-tab, .history-toggle):active:not(:disabled) { transform: none; }
}
