:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #68737f;
  --line: #dfe4e8;
  --accent: #0b6bcb;
  --good: #087f5b;
  --danger: #c92a2a;
  --warning: #e67700;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
a { color: var(--accent); text-decoration: none; }
.topbar { position: relative; z-index: 10; height: 58px; display: flex; align-items: center; gap: 30px; padding: 0 28px; background: #17202a; color: white; border-bottom: 1px solid #273441; }
.brand { color: white; font-size: 17px; font-weight: 800; white-space: nowrap; }
.brand span { margin-left: 7px; color: #9eabb7; font-size: 11px; font-weight: 600; }
.topbar nav { display: flex; align-self: stretch; }
.topbar nav a { display: flex; align-items: center; padding: 0 15px; color: #b9c3cc; border-bottom: 2px solid transparent; }
.topbar nav a:hover, .topbar nav a.active { color: white; border-bottom-color: #4dabf7; }
.nav-group { position: relative; color: #b9c3cc; }
.nav-group summary { display: flex; height: 100%; align-items: center; gap: 6px; padding: 0 15px; border-bottom: 2px solid transparent; cursor: pointer; list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover, .nav-group summary.active { color: white; border-bottom-color: #4dabf7; }
.nav-group summary span { font-size: 9px; transition: transform .15s ease; }
.nav-group[open] summary span { transform: rotate(180deg); }
.submenu { position: absolute; top: 100%; left: 0; display: none; min-width: 130px; padding: 6px; background: #17202a; border: 1px solid #344351; border-top: 0; border-radius: 0 0 5px 5px; box-shadow: 0 10px 22px rgba(0, 0, 0, .2); }
.nav-group[open] .submenu, .nav-group:hover .submenu { display: grid; }
.topbar nav .submenu a { min-height: 38px; padding: 8px 12px; border: 0; border-radius: 3px; }
.topbar nav .submenu a:hover, .topbar nav .submenu a.active { color: white; background: #273746; }
.topbar form { margin-left: auto; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid #3b4854; background: transparent; color: white; cursor: pointer; }
main { max-width: 1260px; margin: 0 auto; padding: 30px 28px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 16px; letter-spacing: 0; }
.eyebrow { margin-bottom: 3px; color: var(--accent); font-size: 11px; font-weight: 800; }
.muted { color: var(--muted); }
.panel { min-width: 0; margin-bottom: 20px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.section-head { display: flex; justify-content: space-between; align-items: center; min-height: 28px; margin-bottom: 16px; }
.section-head > span { color: var(--muted); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.metrics > div { min-height: 106px; padding: 19px 21px; border-right: 1px solid var(--line); }
.metrics > div:last-child { border-right: 0; }
.metrics span { display: block; color: var(--muted); font-size: 12px; }
.metrics strong { display: block; margin-top: 7px; font-size: 28px; }
.metrics strong.small { font-size: 19px; }
.metrics small { color: var(--muted); }
.balance-total { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.balance-total strong { margin-left: 6px; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.volatility-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 16px; font-size: 12px; color: var(--muted); }
.volatility-chip { display: inline-flex; align-items: center; gap: 4px; }
.split { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; }
.split-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.market-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.market-card { padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; }
.market-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.market-label strong { font-size: 14px; }
.market-label span { font-size: 11px; }
.market-card .price { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.market-card .change { margin-left: 8px; font-size: 13px; font-weight: 700; }
.change.rise { color: var(--danger); }
.change.fall { color: var(--accent); }
.change.even { color: var(--muted); }
.market-card .meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.status, .signal, .mode { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 800; }
.status.good, .signal.buy, .signal.bid { color: #05603f; background: #dff7ec; }
.status.danger, .signal.sell, .signal.ask { color: #a21717; background: #ffeded; }
.status.neutral { color: #5c6670; background: #edf0f2; }
.mode.paper { color: #075c9c; background: #e5f3ff; }
.mode.live { color: #a21717; background: #ffeded; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 10px; color: var(--muted); font-size: 11px; text-align: left; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 35px 10px; color: var(--muted); text-align: center; }
.pnl-positive { color: var(--good); }
.pnl-negative { color: var(--danger); }
.table-wrap.scroll { max-height: 480px; overflow-y: auto; }
.table-wrap.scroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: "↕"; margin-left: 4px; color: var(--line); }
th.sortable.sort-asc::after { content: "↑"; color: var(--accent); }
th.sortable.sort-desc::after { content: "↓"; color: var(--accent); }
.actions { display: flex; justify-content: flex-end; gap: 7px; white-space: nowrap; }
.actions form { margin: 0; }
.error-cell { max-width: 260px; color: var(--danger); overflow-wrap: anywhere; }
label { display: grid; gap: 6px; color: #3e4852; font-size: 12px; font-weight: 700; }
.checkbox-label { display: flex; align-items: center; gap: 8px; }
.checkbox-label[hidden] { display: none; }
.checkbox-label input { width: auto; min-height: auto; }
input, select { width: 100%; min-height: 39px; padding: 8px 10px; color: var(--ink); background: white; border: 1px solid #cbd2d8; border-radius: 4px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px #d9ecff; }
button { min-height: 37px; padding: 8px 14px; border-radius: 4px; border: 0; font-weight: 700; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary { color: white; background: var(--accent); }
.secondary { color: #28323c; background: #edf1f4; border: 1px solid #d4dbe0; }
.danger-button { color: white; background: var(--danger); }
.text-danger { min-height: auto; padding: 5px; color: var(--danger); background: transparent; }
.button-link { display: inline-flex; min-height: 37px; align-items: center; padding: 8px 14px; border-radius: 4px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 16px; }
.strategy-fields { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.strategy-fields[hidden] { display: none; }
.strategy-description { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.common-fields { padding-top: 0; border-top: 0; }
.form-action { display: flex; align-items: end; }
.stack { display: grid; gap: 14px; }
.critical-panel { border-left: 3px solid var(--danger); }
.flash { margin-bottom: 18px; padding: 12px 15px; border: 1px solid; border-radius: 4px; }
.flash.success { color: #075f43; background: #e7f8f0; border-color: #a9e8cd; }
.flash.error { color: #a21717; background: #fff0f0; border-color: #ffc9c9; }
.integration-list { margin: 0 0 18px; }
.integration-list div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.integration-list dt { color: var(--muted); }
.integration-list dd { margin: 0; font-weight: 800; }
.integration-list .ok { color: var(--good); }
.integration-list .off { color: var(--muted); }
.warning-text, .form-error { color: var(--danger); }
.login-main { display: grid; min-height: 100vh; place-items: center; padding: 25px; }
.login-panel { width: min(390px, 100%); padding: 30px; background: white; border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 6px; box-shadow: 0 14px 35px rgba(21, 31, 40, .08); }
.login-panel h1 { font-size: 34px; }
.login-panel > div { margin-bottom: 27px; }
@media (max-width: 850px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px; padding: 13px 16px 0; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav > a, .nav-group summary { min-height: 42px; padding: 10px 12px; }
  main { padding: 22px 15px 48px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics > div:nth-child(2) { border-right: 0; }
  .metrics > div { border-bottom: 1px solid var(--line); }
  .split, .split-3 { grid-template-columns: 1fr; gap: 0; }
  .market-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .strategy-fields { grid-template-columns: repeat(2, 1fr); }
  .table-wrap { overflow-x: auto; }
  .table-wrap table { min-width: 700px; }
}
@media (max-width: 520px) {
  .brand span { display: none; }
  .metrics, .form-grid, .strategy-fields { grid-template-columns: 1fr; }
  .metrics > div { border-right: 0; }
}
.notification-group { margin-bottom: 22px; }
.notification-group h3 { margin: 0 0 8px; font-size: 14px; }
.notification-group td:first-child { width: 48px; text-align: center; }
.notification-group input[type="checkbox"] { width: auto; min-height: auto; }
.notification-group .muted.small { margin-top: 2px; font-size: 11px; }
