:root {
  --ink: #e8f0e4;
  --muted: #8a9a86;
  --line: #243026;
  --panel: #121812;
  --panel-2: #171f18;
  --bg: #0b100c;
  --lime: #c6f04d;
  --amber: #f0b429;
  --rose: #ff6b6b;
  --sky: #7ec8e3;
  --ok: #3dd68c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.45 "IBM Plex Sans", "Avenir Next", "PingFang SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 10% -10%, #1c2a14 0%, transparent 55%),
    linear-gradient(180deg, #101610 0%, var(--bg) 40%);
}

code, .num, td, input { font-variant-numeric: tabular-nums; }
code { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

.shell { max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 52px; height: 52px; display: grid; place-items: center;
  border: 1px solid var(--lime); color: var(--lime);
  font: 700 13px/1 "IBM Plex Mono", monospace; letter-spacing: 0.08em;
}
h1 { margin: 0; font-size: 22px; letter-spacing: 0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); }
.engine-cluster { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.engine-switch, #engine-switch {
  margin: 0;
  height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  font: inherit;
  line-height: 32px;
}
.vip-badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 34px; padding: 0 8px; box-sizing: border-box;
  color: var(--amber); background: #1c160c; border: 1px solid #5c4a1f;
  line-height: 1;
}
.vip-badge svg { width: 14px; height: 14px; display: block; flex: 0 0 auto; }
.vip-badge strong { font-size: 12px; font-weight: 600; color: var(--amber); }
.engine-list { display: grid; gap: 8px; }
.engine-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}
.engine-row .engine-current,
.engine-row .engine-account {
  grid-column: 1 / -1;
  font-size: 12px;
}
.engine-row .engine-current { color: var(--lime); letter-spacing: 0.04em; }
.engine-row .engine-account { color: var(--muted); }
.cfg-refresh { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 12px 0; }
.cfg-refresh input { width: 120px; }
#cfg-table tbody tr[data-id] { cursor: pointer; }
#cfg-body td.cfg-url, #cfg-body td.cfg-hook { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-chip {
  color: var(--muted);
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 7px 12px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 32px 28px;
  text-align: center;
}
.login-card .mark { margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; }
.login-card .sub { margin: 8px 0 0; }
.login-card .form-msg { margin-top: 14px; }
.login-form { margin-top: 22px; display: grid; gap: 12px; text-align: left; }
.login-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.login-form input {
  text-align: center;
  letter-spacing: 0.28em;
  font-size: 20px;
  padding: 10px 12px;
}
.login-form button { width: 100%; }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 auto; box-sizing: border-box;
  border: 1px solid var(--line); background: var(--panel);
  padding: 0;
}
#btn-panel-settings {
  height: 34px; min-height: 34px; box-sizing: border-box;
  display: inline-flex; align-items: center; padding: 0 12px;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.up i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.down i { background: var(--rose); }

.tabs {
  display: flex; gap: 0; margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 1px solid transparent; border-bottom: none;
  background: transparent; color: var(--muted);
  padding: 8px 16px; margin-bottom: -1px; cursor: pointer;
}
.tab.active {
  color: var(--ink); background: var(--panel-2);
  border-color: var(--line); border-bottom-color: var(--panel-2);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel);
  padding: 3px 8px; font-size: 12px;
}
.chip button {
  padding: 0 4px; border: none; color: var(--muted); line-height: 1;
}
.hedge-add { display: flex; align-items: flex-end; gap: 8px; margin-top: 10px; }
.hedge-add label { flex: 1; display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.block-label { display: grid; gap: 4px; margin-top: 10px; color: var(--muted); font-size: 12px; }
#hedge-form .block-label { margin-top: 0; }
#hedge-blacklist,
#hedge-grid-blacklist {
  width: 100%;
  font: inherit; color: var(--ink);
  background: #0d130e; border: 1px solid #2c3a2e; padding: 8px 9px;
}
#hedge-grid-blacklist {
  resize: vertical;
  min-height: 2.6em;
  cursor: default;
}
.hedge-grid-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 12px;
}
.hedge-grid-toggle input { accent-color: var(--lime); }
.hedge-grid-toggle:has(input:disabled) { cursor: not-allowed; opacity: 0.75; }
.algo-field select {
  width: 100%;
  font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); padding: 6px 8px;
}
.hedge-rules-card > header {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 14px;
}
.hedge-rules-card > header .hint {
  margin: 0;
  line-height: 1.5;
}
.hedge-form-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.hedge-form-block > h3,
.hedge-form-block-head h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.hedge-form-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.hedge-form-block-head h3 { margin: 0; }
.hedge-rule-list { display: grid; gap: 10px; }
.hedge-rule-empty {
  margin: 0;
  padding: 18px 12px;
  text-align: center;
  border: 1px dashed var(--line);
  background: rgba(13, 19, 14, 0.45);
}
.hedge-rule-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
}
.hedge-rule-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.hedge-rule-head strong { font-size: 13px; margin-right: auto; }
.hedge-rule-head label {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px;
}
#hedge-form .hedge-rule-head input { width: 72px; }
.hedge-filters { display: grid; gap: 8px; }
.hedge-filter {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(0, 1fr) minmax(72px, 0.8fr);
  grid-template-areas:
    "phase factor factor del"
    "param how range sort";
  gap: 6px 8px;
  padding: 8px;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.hedge-filter label,
.hedge-policy-grid label {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
}
.hedge-filter-phase { grid-area: phase; }
.hedge-filter-factor { grid-area: factor; }
.hedge-filter-del { grid-area: del; align-self: end; justify-self: end; }
.hedge-filter-param { grid-area: param; }
.hedge-filter-how { grid-area: how; }
.hedge-filter-range { grid-area: range; }
.hedge-filter-sort { grid-area: sort; }
.hedge-policy-grid .span-2 { grid-column: 1 / -1; }
.hedge-sub-actions { display: flex; gap: 6px; margin-top: 8px; }
.hedge-policy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  align-items: end;
}
#hedge-form input:not([type="checkbox"]),
#hedge-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: #0d130e;
  border: 1px solid #2c3a2e;
  padding: 7px 8px;
}
#hedge-form input:focus,
#hedge-form select:focus {
  outline: 1px solid var(--lime);
  border-color: var(--lime);
}
#hedge-form input::placeholder { color: var(--muted); opacity: 0.65; }
.hedge-form-actions { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
#hedge-clock { margin-left: auto; }
.warn-list { margin: 0 0 8px; color: var(--amber); font-size: 12px; }
.badge-pending { color: var(--amber); font-size: 12px; }
.badge-live { color: var(--ok); font-size: 12px; }
.badge-exit { color: var(--ok); font-size: 12px; }
.badge-new { color: var(--rose); font-size: 12px; }
.badge-adjust { color: var(--amber); font-size: 12px; }
.badge-flat { color: var(--muted); font-size: 12px; }
#hedge-body tr.hedge-exit td { background: rgba(80, 140, 90, 0.08); }
#tab-hedge .grid {
  grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
  align-items: start;
  width: 100%;
  min-width: 0;
}
#tab-hedge .grid > .card { min-width: 0; }
.algo-field { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.choice { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
.choice input { width: auto; }
.hedge-kpis { margin-top: 0; }
.hedge-banner {
  margin: 0 0 12px; padding: 8px 10px;
  border: 1px solid #5c4a1f; background: #16120c; color: var(--amber); font-size: 13px;
}
.action-open { color: var(--rose); }
.action-close { color: var(--ok); }
.action-skip { color: var(--muted); }
.overlap { color: var(--amber); font-size: 11px; margin-left: 6px; }
.modal-card.stray-card {
  width: min(960px, 96vw);
  height: min(86vh, 820px);
  max-height: min(86vh, 860px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.stray-card > .hint { margin: 0 0 12px; line-height: 1.4; flex: 0 0 auto; }
.stray-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 10px;
  flex-shrink: 0;
}
.stray-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.stray-toolbar select {
  min-width: 168px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}
.stray-toolbar .danger { margin-left: auto; }
.stray-split {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stray-table-wrap {
  flex: 1 1 42%;
  min-height: 0;
  overflow: auto;
}
.stray-table-wrap table { border-collapse: separate; border-spacing: 0; }
.stray-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
  box-shadow: 0 1px 0 #223026;
}
.stray-log {
  flex: 0 0 200px;
  min-height: 140px;
  max-height: 260px;
}
.stray-actions { margin-top: 8px; flex: 0 0 auto; }
.hedge-confirm-card {
  width: min(520px, 100%);
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.hedge-confirm-card > header { margin-bottom: 10px; }
.hedge-confirm-card #hedge-confirm-summary {
  margin: 0 0 12px;
  line-height: 1.4;
}
.hedge-confirm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}
.hedge-confirm-chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 3px 8px;
  font-size: 12px;
}
.hedge-confirm-chip em {
  color: var(--muted);
  font-style: normal;
  margin-right: 4px;
}
.hedge-confirm-table-label {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 6px;
}
.hedge-run-table {
  flex: 1 1 auto;
  min-height: 88px;
  max-height: none;
  overflow: auto;
}
.hedge-run-table th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  z-index: 1;
}
.hedge-confirm-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}
.hedge-confirm-actions .form-msg { margin-right: auto; }
.hedge-run-log-wrap {
  flex: 1;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  margin: 10px 0 8px;
}
.hedge-run-log {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
.hedge-log-row {
  display: grid;
  grid-template-columns: 62px minmax(72px, 110px) 1fr;
  gap: 4px 8px;
  padding: 3px 4px;
  border-bottom: 1px solid #1a221c;
}
.hedge-log-sym { color: var(--sky, #7eb6ff); }
.hedge-log-msg { color: var(--ink); word-break: break-all; }
.hedge-log-row.is-ok .hedge-log-msg { color: var(--ok); }
.hedge-log-row.is-warn .hedge-log-msg { color: var(--amber); }
.hedge-log-row.is-bad .hedge-log-msg { color: var(--rose); }
.hedge-runs-card {
  width: min(920px, 100%);
  height: min(88vh, 720px);
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.hedge-runs-card > header { align-items: flex-start; }
.hedge-runs-card > header .hint { margin: 4px 0 0; }
.hedge-runs-toolbar {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
  flex-shrink: 0;
}
.hedge-runs-toolbar .ghost {
  padding: 5px 10px;
  font-size: 12px;
}
.hedge-runs-toolbar .ghost.active {
  border-color: #3a4a28;
  background: rgba(198, 240, 77, 0.08);
  color: var(--lime, #c6f04d);
}
.hedge-runs-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 228px 1fr;
  gap: 10px;
}
.hedge-runs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding-right: 2px;
}
.hedge-run-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
}
.hedge-run-item .hedge-run-when {
  font-variant-numeric: tabular-nums;
}
.hedge-run-item .hedge-run-meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}
.hedge-run-item.active { border-color: #3a4a28; background: rgba(198, 240, 77, 0.08); }
.hedge-run-item .ok { color: var(--lime, #c6f04d); }
.hedge-run-item .bad { color: var(--rose); }
.hedge-run-item .warn { color: var(--amber); }
.hedge-run-log {
  min-height: 0;
  height: auto;
}
#tab-hedge .card { margin-bottom: 12px; }

.perf-kpis { grid-template-columns: repeat(8, 1fr); margin-top: 0; }
.perf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.perf-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.perf-toolbar select {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 6px 8px;
}
#perf-clock { margin: 0; flex: 1; }
.perf-note { color: var(--amber); margin: 0 0 12px; }
#tab-perf .table-wrap { max-height: 360px; overflow: auto; }
.perf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.perf-chart { width: 100%; min-width: 0; }
.perf-chart .uplot {
  width: 100%;
  max-width: 100%;
  font: inherit;
  color: var(--muted);
  display: flex;
  flex-direction: column;
}
.perf-chart .u-legend {
  order: -1;
  font-size: 12px;
  text-align: left;
  margin: 0 0 6px;
}
.perf-chart .u-inline tr { margin-right: 12px; }
.perf-chart .u-legend th,
.perf-chart .u-legend .u-value { color: var(--ink); font-weight: 500; }
.perf-chart .u-legend .u-off > * { opacity: 0.35; }
.perf-chart canvas {
  display: block;
  background: #0d130e;
  border: 1px solid var(--line);
}
.perf-chart .u-cursor-x,
.perf-chart .u-cursor-y { border-color: #5a6a56; }
.perf-chart .u-select { background: rgba(198, 240, 77, 0.08); }

.account { margin: 18px 0 16px; }
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 22px 0; }
.account-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 0;
}
.kpis article {
  background: var(--panel); border: 1px solid var(--line); padding: 12px 14px; min-width: 0;
}
.account-grid > article {
  height: 104px;
  display: flex;
  flex-direction: column;
  padding-bottom: 30px;
  position: relative;
}
.kpis label { display: block; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.kpis strong { font-size: 20px; font-weight: 600; }
.account-grid > article > strong { margin-top: auto; }
.kpis .warn { color: var(--amber); }
.kpis .bad { color: var(--rose); }
.kpis .ok { color: var(--ok); }
.pos-ratio { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.pos-ratio i { font-style: normal; color: var(--muted); font-weight: 400; margin: 0 4px; }
.account-grid em {
  position: absolute; left: 14px; right: 14px; bottom: 10px;
  font-style: normal; color: var(--muted); font-size: 12px; letter-spacing: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.grid { display: grid; grid-template-columns: 340px 1fr; gap: 12px; margin-bottom: 12px; }
.card { background: var(--panel-2); border: 1px solid var(--line); padding: 16px; }
#tab-grid > .card { margin-bottom: 12px; }
.card > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card h2 { margin: 0; font-size: 15px; }
.hint { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-search {
  width: 156px;
  min-width: 0;
  padding: 6px 8px;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
}
.hedge-interval-row {
  display: flex;
  gap: 6px;
  min-width: 0;
}
#hedge-form .hedge-interval-row input { flex: 1 1 0; width: auto; }
#hedge-form .hedge-interval-row select { width: auto; flex: 0 0 72px; }
.hedge-auto-toggle {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  min-height: 34px;
  gap: 6px;
  color: var(--ink) !important;
  font-size: 13px !important;
}
.hedge-align-mode {
  border: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.hedge-align-mode legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.hedge-align-mode label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 12px;
  cursor: pointer;
}
.hedge-align-mode label strong { display: block; font-size: 13px; }
.hedge-align-mode label span { line-height: 1.35; }
.hedge-align-mode label em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
.hedge-align-mode label:has(input:checked) {
  border-color: var(--lime);
  background: rgba(198, 240, 77, 0.08);
}
.hedge-align-mode label:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}
.hedge-align-mode input { width: auto; margin-top: 2px; }
.hedge-preview-actions { flex-shrink: 0; }
.col-check { width: 28px; }
input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--lime); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cfg-fields { grid-template-columns: 1fr; }
.cfg-section { margin: 6px 0 0; color: var(--ink); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.fields label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.fields label[hidden] { display: none; }
.field-span { grid-column: 1 / -1; }
#edit-modal .modal-card { width: min(520px, 96vw); }
#edit-form .fields { grid-template-columns: 1fr 1fr; align-items: end; }
#edit-form .fields label:not(.check-row) {
  grid-template-rows: 18px 36px;
  align-content: end;
  gap: 4px;
  min-width: 0;
}
#edit-form .fields input:not([type="checkbox"]):not([type="range"]),
#edit-form .fields select {
  height: 36px;
  margin: 0;
  padding: 0 9px;
}
#edit-form .extra-set {
  min-width: 0;
  height: 36px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid #2c3a2e;
  background: #0d130e;
}
#edit-form .cover-slot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
#edit-form .cover-slot[hidden] { display: none; }
#edit-form .fields label.check-row { min-height: 36px; }
.cover-bounds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.cover-bounds[hidden] { display: none; }
#add-modal .modal-card { overflow: auto; max-height: min(92vh, 720px); }
.combo { position: relative; }
.combo-list {
  margin-top: 4px;
  max-height: 168px;
  overflow: auto;
  background: #0d130e;
  border: 1px solid #2c3a2e;
}
.combo-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
}
.combo-opt.active,
.combo-opt:hover { background: rgba(198, 240, 77, 0.12); }
.combo-empty {
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
}
.check-row { display: flex; align-items: center; gap: 8px; }
.fields label.check-row { display: flex; align-items: center; }
.check-row span { color: var(--ink); font-size: 13px; }
.switch-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.switch-cell input { margin: 0; }
th.col-auto, td.col-auto { width: 1%; }
input, .fields select {
  width: 100%; background: #0d130e; color: var(--ink);
  border: 1px solid #2c3a2e; padding: 8px 9px;
}
input:focus, .fields select:focus { outline: 1px solid var(--lime); border-color: var(--lime); }
.actions { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-msg { margin: 0; color: var(--rose); font-size: 12px; }
.form-msg.ok { color: var(--ok); }

button {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  padding: 7px 12px; cursor: pointer;
}
button.primary { background: var(--lime); color: #13200a; border-color: var(--lime); font-weight: 700; }
button.ghost:hover, button.danger:hover, button.primary:hover, button.start:hover { filter: brightness(1.08); }
button.danger { color: var(--rose); border-color: #4a2626; }
button.start { color: var(--ok); border-color: #1f5c3d; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
#live-table { border-collapse: separate; border-spacing: 0; }
#live-table .col-symbol {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel-2);
  box-shadow: 1px 0 0 #223026;
}
#live-table thead .col-symbol { z-index: 3; }
#live-table tr.out-low .col-symbol,
#live-table tr.out-high .col-symbol {
  background: linear-gradient(rgba(255, 107, 107, 0.06), rgba(255, 107, 107, 0.06)), var(--panel-2);
}
#live-table tr.selected .col-symbol {
  background: linear-gradient(rgba(198, 240, 77, 0.08), rgba(198, 240, 77, 0.08)), var(--panel-2);
}
#live-table .col-metric select {
  max-width: 9.5em;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid #223026; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 500; }
th[data-sort] {
  cursor: pointer;
  user-select: none;
}
th[data-sort]:hover { color: var(--ink); }
th[data-sort]::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  margin-left: 4px;
  font-size: 10px;
  color: var(--muted);
}
th[data-sort].is-sorted[data-dir="asc"]::after { content: "↑"; color: var(--lime); }
th[data-sort].is-sorted[data-dir="desc"]::after { content: "↓"; color: var(--lime); }
tr.empty td { color: var(--muted); text-align: center; padding: 22px; }
.arm-dots {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-left: 8px;
  vertical-align: middle;
}
.arm-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px #4a5a4c;
  vertical-align: middle;
}
.arm-dot.stop { background: var(--rose); box-shadow: none; }
.arm-dot.auto { background: var(--ok); box-shadow: none; }
.grid-title { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.icon-help {
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: 600 13px/20px "IBM Plex Sans", sans-serif;
  cursor: pointer;
}
.icon-help:hover,
.icon-help.is-open { color: var(--ink); border-color: var(--muted); }
.grid-help {
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #10160f;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.grid-help p { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.grid-help p:last-child { margin: 0; }
.phase { font-size: 11px; letter-spacing: 0.04em; padding: 2px 6px; border: 1px solid var(--line); }
.phase.ACTIVE { color: var(--ok); border-color: #245c3d; }
.phase.REDUCE_ONLY { color: var(--amber); border-color: #5c4a1f; }
.phase.HALTED, .phase.LOCK, .phase.LIQ { color: var(--rose); border-color: #5c2424; }
.badge { font-size: 11px; color: var(--sky); }

.bound-banner {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid #5c2424;
  background: #1c1010;
  color: var(--rose);
  font-size: 13px;
}
.bound-log {
  margin: 0 0 10px;
  padding: 6px 10px;
  border: 1px solid #3a2a1a;
  background: #16120c;
  color: var(--amber);
  font-size: 12px;
}
.bound-log div + div { margin-top: 4px; }
tr.out-low, tr.out-high { background: rgba(255, 107, 107, 0.06); }
.bound-tag {
  display: inline-block;
  font-size: 11px; color: var(--rose); border: 1px solid #5c2424; padding: 1px 5px;
}
.px-range-slot {
  flex: 1; min-width: 72px;
  display: flex; align-items: center;
}
.px-range { display: flex; align-items: center; gap: 8px; min-width: 148px; }
.px-range-track {
  position: relative; flex: 1; height: 8px; min-width: 72px;
  background: #141c22; border: 1px solid #3d5a66;
}
.px-range-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--sky);
}
.px-range-mark {
  position: absolute; top: 50%; width: 2px; height: 14px;
  margin: -7px 0 0 -1px;
  background: var(--ink); box-shadow: 0 0 0 1px var(--sky);
}
.px-range.out .px-range-fill { background: var(--rose); }
.px-range.out .px-range-mark { box-shadow: 0 0 0 1px var(--rose); }
.px-range-pct { min-width: 52px; text-align: right; color: var(--sky); }
.px-range.out .px-range-pct { color: var(--rose); }
.extra-set { display: flex; align-items: center; gap: 8px; min-width: 168px; }
.extra-set-track {
  position: relative; flex: 1; height: 6px; min-width: 72px;
  background: #243026; border-radius: 99px;
}
.extra-set-fill {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0;
  background: var(--lime); border-radius: 99px; pointer-events: none;
}
.extra-set-mark {
  position: absolute; top: 50%; z-index: 2; width: 8px; height: 8px;
  margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 0 2px var(--lime);
  pointer-events: none;
}
.extra-set-target {
  position: absolute; top: 50%; z-index: 1; width: 2px; height: 12px;
  margin: -6px 0 0 -1px; background: var(--amber);
  pointer-events: none;
}
.extra-set.out .extra-set-fill { background: var(--rose); }
.extra-set.out .extra-set-mark { box-shadow: 0 0 0 2px var(--rose); }
.extra-set-pct { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.extra-pair {
  display: inline-flex; gap: 4px; min-width: 96px; justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}
.extra-now.out { color: var(--rose); }
.extra-goal { color: var(--muted); }
.extra-goal::before { content: "/ "; }
.extra-set.is-slider .extra-set-track input[type="range"] {
  position: absolute; left: 0; right: 0; top: -8px; bottom: -8px;
  width: 100%; height: auto; margin: 0; padding: 0;
  border: 0; background: transparent; opacity: 0; cursor: pointer;
}
.extra-set.is-slider output { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.toasts {
  position: fixed; right: 18px; top: 18px; z-index: 40;
  display: grid; gap: 8px; max-width: 360px;
}
.toast {
  background: #1c1010; border: 1px solid #5c2424; color: var(--ink);
  padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.toast strong { display: block; color: var(--rose); margin-bottom: 2px; }
.toast span { color: var(--muted); font-size: 12px; }

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  display: grid; place-items: center; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(440px, 100%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 16px;
}
.modal-card.persist-transfer-card { width: min(640px, 96vw); }
#persist-transfer-text {
  width: 100%;
  min-height: 240px;
  margin: 0 0 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.modal-card.hedge-runs-card {
  width: min(920px, 96vw);
  height: min(88vh, 720px);
  max-height: min(88vh, 860px);
}
.modal-card > header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.modal-card h3 { margin: 0; font-size: 15px; }

tr[data-symbol] { cursor: pointer; }
tr.selected { background: rgba(198, 240, 77, 0.08); }
tr.selected td { border-bottom-color: #3a4a28; }
tr.is-open td { border-bottom-color: transparent; }
tr.grid-detail td {
  background: #10160f;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
}
.grid-fold { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.grid-fold > span { display: inline-flex; align-items: center; gap: 8px; }
.grid-fold em { color: var(--muted); font-style: normal; font-size: 12px; }
.grid-fold .fold-px.out { color: var(--rose); font-weight: 700; }

.book-modal { z-index: 55; }
.book-card {
  width: min(1280px, 96vw);
  height: min(80vh, 860px);
  max-width: none;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.book-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 10px;
}
.book-pane, .log-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.log-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
}
.log-toolbar .view-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.log-console {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 6px 8px;
  background: #0d130e;
  border: 1px solid var(--line);
  font: 12px/1.4 "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
.log-row {
  display: grid;
  grid-template-columns: 62px 72px 1fr;
  gap: 4px 8px;
  padding: 4px 6px;
  border-bottom: 1px solid #1a221c;
  cursor: pointer;
}
.log-row:hover { filter: brightness(1.08); }
.log-time { color: var(--muted); }
.log-act { font-weight: 600; }
.log-detail { color: var(--ink); word-break: break-all; }
.log-raw {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  padding: 6px 8px;
  background: #0a0f0b;
  border: 1px solid #2c3a2e;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  font: 11px/1.45 "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
.log-row.log-info .log-act { color: var(--sky); }
.log-row.log-warn .log-act { color: var(--amber); }
.log-row.log-error .log-act { color: var(--rose); }
.log-row.log-buy .log-detail { color: var(--ok); }
.log-row.log-sell .log-detail { color: var(--rose); }
.log-row.log-fill-buy { background: rgba(61, 214, 140, 0.18); }
.log-row.log-fill-sell { background: rgba(255, 107, 107, 0.18); }
.log-row.log-catchup { background: rgba(240, 180, 41, 0.22); }
.log-row.log-cancel {
  background: rgba(138, 154, 134, 0.36);
  text-decoration: line-through;
}
.log-row.log-fail { background: rgba(255, 107, 107, 0.10); }
.log-row.log-fail.log-warn { background: rgba(240, 180, 41, 0.12); }
.log-row.log-fail.log-error { background: rgba(255, 107, 107, 0.16); }
.log-row.log-fail .log-detail { color: #ffd0a8; }
.log-row.log-error .log-detail { color: #ffb4b4; }
.log-row.open { outline: 1px solid #3a4a36; }
.book-empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.book-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-shrink: 0; }
.book-head h3 { margin: 0; font-size: 15px; }
.book-head-actions { display: flex; align-items: center; gap: 8px; }
.book-meta { color: var(--muted); font-size: 12px; line-height: 1.55; margin-bottom: 8px; flex-shrink: 0; }
.book-catchup {
  margin: 0 0 8px; padding: 6px 10px;
  border: 1px solid #5c4a1f; background: #16120c; color: var(--amber); font-size: 12px;
  flex-shrink: 0;
}
.book-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
}
.book-wrap table { border-collapse: separate; border-spacing: 0; }
.book-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #141c15;
  box-shadow: 0 1px 0 #223026;
}
.book-tag {
  display: inline-block; margin-left: 5px;
  font-size: 10px; letter-spacing: 0.04em; padding: 0 4px;
  border: 1px solid var(--line); color: var(--muted);
}
.book-tag.a, .book-tag.c { color: var(--lime); border-color: #3a4a28; }
.book-tag.window { color: var(--sky); border-color: #2a4a52; }
.book-tag.live { color: var(--ok); border-color: #245c3d; }
.book-tag.skip { color: var(--amber); border-color: #5c4a1f; }
.book-tag.leftover { color: var(--rose); border-color: #5c2424; }
tr.book-sell td:nth-child(2), tr.book-sell td:nth-child(3) { color: var(--rose); }
tr.book-buy td:nth-child(2), tr.book-buy td:nth-child(3) { color: var(--ok); }
tr.has-live { background: rgba(61, 214, 140, 0.05); }
tr.book-mark td {
  color: var(--lime); font-weight: 700; text-align: center;
  background: #1c2410; border-bottom-color: #3a4a28;
}

body.book-open { overflow: hidden; }

@media (max-width: 980px) {
  .shell {
    padding: 16px 14px 28px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
  .top { flex-wrap: wrap; align-items: center; gap: 12px; }
  .top-meta { width: auto; margin-left: auto; justify-content: flex-end; }
  .engine-row { grid-template-columns: 1fr; }
  .account { margin: 14px 0; }
  .kpis, .hedge-kpis, .perf-kpis { grid-template-columns: repeat(3, 1fr); margin: 14px 0; }
  .account-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
  .perf-grid { grid-template-columns: 1fr; }
  .kpis article { padding: 10px 10px; }
  .account-grid > article { padding: 10px 10px 28px; }
  .account-grid em { left: 10px; right: 10px; }
  .kpis strong { font-size: 17px; }
  .grid, #tab-hedge .grid { grid-template-columns: minmax(0, 1fr); }
  #tab-hedge .card { margin-bottom: 0; }
  .card > header { flex-wrap: wrap; align-items: flex-start; }
  .book-card { height: min(88vh, 860px); }
  .book-split { grid-template-columns: 1fr; grid-template-rows: minmax(180px, 1fr) minmax(160px, 1fr); }
  .hedge-runs-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 32%) minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: stretch; gap: 10px; }
  .top-meta { width: 100%; margin-left: 0; justify-content: flex-start; }
  .mark { width: 40px; height: 40px; font-size: 11px; }
  h1 { font-size: 18px; }
  .sub { font-size: 12px; word-break: break-all; }
  .engine-cluster, .vip-badge, #engine-switch { word-break: normal; }
  #engine-switch, #vip-badge, #link-pill, #btn-panel-settings {
    height: 44px; min-height: 44px; max-height: 44px;
  }
  #engine-switch { line-height: 42px; }
  #link-pill { width: 44px; }
  .hint-desk { display: none; }
  .user-chip { max-width: 42vw; }
  .kpis, .hedge-kpis, .perf-kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .account-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
  .kpis label { font-size: 11px; }
  .kpis strong, .pos-ratio { font-size: 16px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { flex: 1 0 auto; min-height: 44px; padding: 10px 14px; }
  .fields { grid-template-columns: 1fr; }
  .hedge-add { flex-direction: column; align-items: stretch; }
  .hedge-policy-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
  .hedge-interval,
  .hedge-auto-toggle { grid-column: 1 / -1; }
  .hedge-filter {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "phase del"
      "factor factor"
      "param how"
      "range sort";
  }
  .hedge-form-actions { align-items: stretch; }
  #hedge-clock { margin-left: 0; width: 100%; }
  .table-search { width: 100%; flex: 1 1 140px; }
  .col-opt { display: none; }
  .row-actions { flex-wrap: wrap; justify-content: flex-start; }
  button, a.ghost, .tab {
    min-height: 44px;
    touch-action: manipulation;
  }
  .icon-help { min-height: 22px; width: 22px; height: 22px; }
  .row-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
  .row-actions button,
  .hedge-rule-card button,
  .chip button {
    min-height: 32px;
    padding: 4px 8px;
  }
  input, select, textarea { font-size: 16px; }
  .login-form input { letter-spacing: 0.2em; }
  .login-body { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .login-card { padding: 24px 18px; }
  .modal {
    padding: 0;
    align-items: stretch;
    justify-items: stretch;
  }
  .hedge-align-mode { grid-template-columns: 1fr; }
  .modal-card,
  .book-card,
  .stray-card,
  .hedge-confirm-card,
  .hedge-runs-card,
  .modal-card.hedge-runs-card {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: 100%;
    min-height: 100%;
    border: none;
    padding: 14px;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .book-head { flex-wrap: wrap; }
  .book-head-actions { width: 100%; justify-content: flex-end; }
  .book-split { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .hedge-runs-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(120px, 30%) minmax(0, 1fr);
  }
  .hedge-runs-toolbar .ghost { min-height: 36px; }
  .log-row, .hedge-log-row {
    grid-template-columns: 48px minmax(56px, 72px) 1fr;
    font-size: 11px;
  }
  .toasts {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: none;
  }
}
