:root {
  color-scheme: dark;
  --bg: #060b09;
  --panel: #0d1512;
  --panel-2: #111c18;
  --field: #08100d;
  --line: #24362f;
  --line-bright: #365247;
  --text: #eef8f2;
  --muted: #82978e;
  --green: #5cf09a;
  --green-dim: #2d8754;
  --green-deep: #123b26;
  --orange: #ffb44f;
  --red: #ff6865;
  --radius: 14px;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 0%, rgba(42, 169, 101, .10), transparent 33rem),
    radial-gradient(circle at 100% 100%, rgba(22, 92, 58, .08), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1840px, calc(100% - 28px));
  height: 100dvh;
  margin: 0 auto;
  padding: 13px 0;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr);
  gap: 12px;
}

.topbar {
  position: relative;
  z-index: 20;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(320px, max-content) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(9, 17, 14, .72);
  box-shadow: 0 16px 46px rgba(0, 0, 0, .16);
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 5px; }
.brand-mark i { width: 7px; height: 7px; border: 2px solid var(--green); border-radius: 2px; }
.brand h1 { margin: 0; font-size: 1.12rem; line-height: 1.05; letter-spacing: .045em; text-transform: uppercase; }
.brand p { margin: 5px 0 0; color: #a0b4ab; font: 700 .69rem ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .07em; }
.brand p span { color: var(--green); }

.market-display { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; min-width: 0; }
.market-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
}
.market-switch button {
  min-width: 46px;
  border: 0;
  border-radius: 7px;
  padding: 7px 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 800 .61rem ui-monospace, monospace;
  letter-spacing: .05em;
}
.market-switch button:hover { color: var(--text); }
.market-switch button.active {
  background: var(--green-deep);
  color: var(--green);
  box-shadow: inset 0 0 0 1px #286844;
}
.header-price { min-width: 180px; padding: 4px 8px; text-align: center; }
.header-price span { display: block; color: var(--muted); font: 750 .62rem ui-monospace, monospace; letter-spacing: .12em; }
.header-price strong { display: block; margin-top: 4px; color: var(--green); font: 800 1.25rem ui-monospace, monospace; letter-spacing: .025em; white-space: nowrap; }

.status-stack { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; justify-self: end; }
.badge, .counter, .safety-dot, .signal-badge {
  border: 1px solid var(--line);
  background: rgba(8, 15, 12, .88);
  border-radius: 999px;
  padding: 7px 10px;
  font: 750 .62rem ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-mode { color: var(--orange); border-color: #65451b; }
.badge[data-status="RUNNING"] { background: var(--green-deep); border-color: #286844; color: var(--green); }
.badge[data-status="RECOVERING"] { color: var(--orange); }
.badge[data-status="ERROR"] { color: var(--red); }
.connection-badge[data-connection="online"] { color: var(--green); border-color: #286844; }
.connection-badge[data-connection="reconnecting"] { color: var(--orange); border-color: #65451b; }
.notification-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  background: #101915;
  color: var(--text);
  cursor: pointer;
  font-size: .73rem;
  font-weight: 700;
}
.notification-button:hover { border-color: var(--line-bright); background: #14201b; }
.notification-button b { color: var(--muted); font: 750 .62rem ui-monospace, monospace; }
.notification-button b[data-configured="true"] { color: var(--green); }
.notification-button b[data-emergency="true"] { color: var(--red); }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 21fr) minmax(620px, 38fr) minmax(650px, 41fr);
  gap: 12px;
  min-height: 0;
}
.panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(17, 28, 24, .97), rgba(10, 17, 14, .98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 64px rgba(0, 0, 0, .17);
}
.controls, .overview, .impulse-panel, .ladder-panel { padding: 14px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.compact-heading { margin-bottom: 12px; }
.section-kicker { margin: 0; color: var(--green); font-size: .61rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h2 { margin: 3px 0 0; font-size: 1rem; line-height: 1.1; letter-spacing: -.015em; }
.safety-dot { color: var(--muted); font-size: .6rem; }
.counter { min-width: 34px; text-align: center; color: var(--green); }

.controls { display: flex; flex-direction: column; }
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 10px;
  align-content: start;
}
.grid-selector-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: .78fr 1.22fr 38px;
  gap: 8px;
  align-items: end;
}
.grid-manager-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-bright);
  border-radius: 9px;
  background: #101b16;
  color: var(--green);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
}
.grid-manager-button:hover { border-color: var(--green-dim); background: var(--green-deep); }
.symbol-field { grid-column: 1 / -1; }
label { display: grid; gap: 5px; margin: 0; color: #b5c8bf; font-size: .67rem; font-weight: 680; min-width: 0; }
.field-label { display: flex; align-items: center; gap: 5px; min-width: 0; }
.field-help {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 1px solid var(--line-bright);
  border-radius: 50%;
  color: var(--green);
  background: rgba(8, 16, 13, .96);
  cursor: help;
  font: 800 .58rem/1 ui-monospace, monospace;
  outline: none;
}
.field-help::after {
  content: attr(data-tooltip);
  box-sizing: border-box;
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: min(290px, 72vw);
  padding: 9px 10px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background: #101a16;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
  font: 550 .68rem/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
.field-help:hover::after,
.field-help:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.field-help:focus-visible { border-color: var(--green); box-shadow: 0 0 0 3px rgba(80, 221, 139, .09); }
.tooltip-field { position: relative; }
.tooltip-field .field-help { position: static; }
.tooltip-field .field-help::after {
  top: calc(100% + 8px);
  right: auto;
  bottom: auto;
  left: 0;
  width: calc(200% + 10px);
  max-width: none;
}
input, select {
  width: 100%;
  height: 39px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  font: 550 .78rem ui-monospace, SFMono-Regular, Consolas, monospace;
}
input:focus, select:focus { border-color: #3b9d67; box-shadow: 0 0 0 3px rgba(80, 221, 139, .09); }
input:disabled { cursor: not-allowed; opacity: .42; }
.is-disabled { opacity: .55; }
.range-preview-box > span { display: block; color: #b5c8bf; font-size: .64rem; font-weight: 680; }
.range-preview-box {
  min-width: 0;
  padding: 8px 10px;
  border: 1px dashed #315244;
  border-radius: 9px;
  background: rgba(18, 59, 38, .12);
}
.range-preview-box strong { display: block; margin-top: 7px; color: var(--green); font: 700 .66rem ui-monospace, monospace; white-space: nowrap; }
.controls-footer { margin-top: auto; padding-top: 11px; }
.button-preview { width: 100%; margin-bottom: 8px; color: var(--green); border-color: #315b45; background: rgba(25, 83, 52, .16); }
.button-preview-both { color: #dce8e2; border-color: #3b5449; background: rgba(50, 76, 64, .18); }
.grid-preview-result {
  margin: 0 0 8px;
  padding: 9px 10px;
  border: 1px solid #315b45;
  border-radius: 9px;
  background: rgba(13, 43, 28, .2);
  color: var(--text);
  font-size: .68rem;
  line-height: 1.4;
}
.grid-preview-result.error { border-color: #75403e; background: rgba(93, 25, 24, .12); }
.grid-preview-result strong { display: block; margin-bottom: 4px; color: var(--green); font-size: .72rem; }
.grid-preview-result.error strong { color: var(--red); }
.grid-preview-result span { color: var(--muted); }
.grid-preview-result ul { margin: 5px 0 0; padding-left: 16px; color: var(--red); }
.dual-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 7px; }
.dual-preview-card { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(4, 12, 9, .36); }
.dual-preview-card[data-valid="true"] { border-color: #315b45; }
.dual-preview-card[data-valid="false"] { border-color: #75403e; }
.dual-preview-card b { display: block; margin-bottom: 4px; color: #eef7f2; }
.dual-preview-card p { margin: 2px 0; color: var(--muted); }
@media (max-width: 700px) { .dual-preview-grid { grid-template-columns: 1fr; } }
.actions { display: grid; grid-template-columns: 1.45fr 1fr; gap: 9px; }
.button {
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  background: #16201c;
  color: var(--text);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 750;
}
.button:hover { border-color: var(--line-bright); transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; transform: none; }
.button-primary { background: var(--green); border-color: var(--green); color: #06120b; }
.button-danger { border-color: #75403e; color: #ff9793; background: rgba(93, 25, 24, .12); }
.message { min-height: 16px; margin: 7px 0 0; color: var(--green); font-size: .66rem; line-height: 1.35; }
.message.error { color: var(--red); }

.overview { display: flex; flex-direction: column; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.metric-pair { min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: rgba(5, 11, 8, .55); }
.metrics article { min-width: 0; padding: 9px 10px; }
.metrics article + article { border-top: 1px solid var(--line); }
.metrics span { display: block; color: var(--muted); font-size: .6rem; margin-bottom: 5px; white-space: nowrap; }
.metrics strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 clamp(.7rem, .84vw, .84rem) ui-monospace, monospace; }

.view-tabs { display: flex; flex: 0 0 auto; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 9px; scrollbar-width: thin; }
.view-tab { border: 0; border-bottom: 2px solid transparent; padding: 6px 10px 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: .68rem; font-weight: 750; }
.view-tab:hover { color: var(--text); }
.view-tab.active { color: var(--green); border-bottom-color: var(--green); }
.monitor-view { display: none; min-height: 0; flex: 1; overflow: hidden; }
.monitor-view.active { display: flex; flex-direction: column; }
#diagnosticsView { overflow-y: auto; padding: 0 4px 6px 0; }
.table-wrap { min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 10px; scrollbar-color: #3b5f4f transparent; scrollbar-width: thin; }
.orders-table-wrap { height: 100%; }
.view-scope-toolbar { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.history-periods { display: flex; flex: 0 0 auto; gap: 5px; }
.view-scope-label { min-width: 0; color: var(--muted); font-size: .61rem; white-space: nowrap; }
.view-scope-label strong { margin-left: 4px; color: var(--text); font: 750 .64rem ui-monospace, monospace; }
.events-scope-toolbar { justify-content: flex-end; }
.diagnostics-scope-toolbar { justify-content: flex-end; }
.history-period { border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; background: #0b1410; color: var(--muted); font-size: .6rem; font-weight: 750; cursor: pointer; }
.history-period.active { border-color: var(--green-dim); background: rgba(45, 135, 84, .13); color: var(--green); }
.history-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); flex: 0 0 auto; gap: 6px; margin-bottom: 8px; }
.history-summary article { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: rgba(5, 11, 8, .5); }
.history-summary span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .59rem; }
.history-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 .65rem ui-monospace, monospace; }
.history-table-wrap { flex: 1; }
.history-table { min-width: 760px; }
.history-status { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px; color: var(--orange); font: 750 .58rem ui-monospace, monospace; }
.history-status.closed { color: var(--green); border-color: #2f744b; }
.order-cancel-button { padding: 5px 8px; border: 1px solid #75413c; border-radius: 7px; background: rgba(133, 46, 40, .1); color: var(--red); font-size: .62rem; font-weight: 750; cursor: pointer; }
.order-cancel-button:hover { border-color: var(--red); background: rgba(133, 46, 40, .2); }
.order-cancel-button:disabled { opacity: .45; cursor: wait; }
table { width: 100%; border-collapse: collapse; font-size: .7rem; }
thead { position: sticky; top: 0; z-index: 1; background: #101a16; }
th { color: var(--muted); font-size: .6rem; text-transform: uppercase; letter-spacing: .075em; text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 9px; border-bottom: 1px solid rgba(37, 51, 46, .62); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(99, 239, 155, .025); }
.empty td { color: var(--muted); text-align: center; padding: 26px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.role { display: inline-block; border-radius: 5px; padding: 3px 5px; font: 750 .59rem ui-monospace, monospace; }
.role.sell { color: var(--orange); background: rgba(255, 180, 92, .09); }
.role.buy { color: var(--green); background: rgba(99, 239, 155, .09); }
.simulation-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex: 0 0 auto; margin-top: 9px; padding: 9px 10px; border: 1px dashed #304a3f; border-radius: 10px; background: rgba(5, 11, 8, .55); }
.simulation-box p { margin: 3px 0 0; color: var(--muted); font-size: .61rem; line-height: 1.3; }
.scenario-compact-status { display: block; margin-top: 5px; color: var(--green); font: 700 .62rem ui-monospace, monospace; }
.simulation-action { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; min-width: 260px; }
.simulation-action input { height: 36px; }
.simulation-action .button { min-height: 36px; padding-inline: 10px; }
.volume-summary { display: flex; justify-content: flex-end; gap: 14px; margin: 0 2px 7px; color: var(--muted); font-size: .61rem; }
.volume-summary strong { color: var(--text); font-family: ui-monospace, monospace; }
.volume-note { margin: 7px 2px 0; color: var(--muted); font-size: .61rem; }
.volume-comparison-note { margin-top: 3px; }
.volume-table { min-width: 0; table-layout: fixed; font-size: .67rem; }
.volume-table th, .volume-table td { overflow: hidden; padding: 6px 5px; text-overflow: ellipsis; }
.volume-table th:nth-child(1), .volume-table td:nth-child(1) { width: 10%; }
.volume-table th:nth-child(2), .volume-table td:nth-child(2) { width: 16%; }
.volume-table th:nth-child(3), .volume-table td:nth-child(3) { width: 16%; }
.volume-table th:nth-child(4), .volume-table td:nth-child(4) { width: 25%; }
.volume-table th:nth-child(5), .volume-table td:nth-child(5) { width: 18%; }
.volume-table th:nth-child(6), .volume-table td:nth-child(6) { width: 15%; }
.volume-with-comparison { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.volume-comparison { display: inline; margin-left: 3px; color: var(--muted); font-size: .59rem; font-style: normal; }
.volume-comparison i { color: var(--muted); font-style: normal; }
.comparison-unavailable { color: var(--muted); }
.signals-table { min-width: 720px; }
.signals-table td { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.signal-pending { color: var(--muted); font-size: .6rem; }
.delta-positive { color: var(--green); }
.delta-negative { color: var(--red); }
.warning { color: var(--orange); }
.event-log { min-height: 0; overflow: auto; padding-right: 4px; scrollbar-color: #3b5f4f transparent; scrollbar-width: thin; }
.event { display: grid; grid-template-columns: 70px 1fr; gap: 10px; border-bottom: 1px solid var(--line); padding: 9px 4px; }
.event time { color: var(--muted); font: .61rem ui-monospace, monospace; }
.event strong { color: var(--green); font: 750 .61rem ui-monospace, monospace; text-transform: uppercase; }
.event p { margin: 3px 0 0; color: #c1d1c9; font-size: .69rem; line-height: 1.35; }
.empty-state { color: var(--muted); text-align: center; padding: 26px 10px; font-size: .7rem; }

.right-rail { display: grid; grid-template-rows: max-content minmax(260px, 1fr); gap: 12px; min-width: 0; min-height: 0; }
.impulse-panel { display: flex; flex-direction: column; align-self: start; width: 100%; }
.signal-badge { color: var(--muted); }
.signal-badge[data-signal="BUY"] { color: var(--green); border-color: #2f744b; background: rgba(34, 111, 67, .13); }
.signal-badge[data-signal="SELL"] { color: var(--red); border-color: #6f3937; background: rgba(120, 35, 33, .12); }
.signal-badge[data-diagnostics="OK"] { color: var(--green); border-color: #2f744b; }
.signal-badge[data-diagnostics="MISMATCH"], .signal-badge[data-diagnostics="ERROR"] { color: var(--red); border-color: #6f3937; }
.signal-badge[data-backup="OK"] { color: var(--green); border-color: #2f744b; }
.signal-badge[data-backup="ERROR"] { color: var(--red); border-color: #6f3937; }
.signal-badge[data-runtime="OK"] { color: var(--green); border-color: #2f744b; }
.signal-badge[data-runtime="WARNING"], .signal-badge[data-runtime="STALE"] { color: var(--orange); border-color: #65451b; }
.signal-badge[data-runtime="UNAVAILABLE"] { color: var(--red); border-color: #6f3937; }
.runtime-health-card { flex: 0 0 auto; }
.runtime-health-summary { margin-bottom: 8px; }
.runtime-stream-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.runtime-stream-grid article { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; background: rgba(5, 11, 8, .5); }
.runtime-stream-grid span, .runtime-stream-grid small { display: block; color: var(--muted); font-size: .61rem; }
.runtime-stream-grid strong { display: block; margin: 4px 0; color: var(--text); font: 750 .67rem ui-monospace, monospace; }
.runtime-stream-grid strong[data-status="OK"] { color: var(--green); }
.runtime-stream-grid strong[data-status="ERROR"], .runtime-stream-grid strong[data-status="STALE"] { color: var(--red); }
.runtime-stream-grid strong[data-status="PENDING"] { color: var(--orange); }
.runtime-rest-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 9px 0 6px; color: var(--muted); font-size: .62rem; }
.runtime-rest-heading > strong { color: var(--green); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; }
.runtime-rest-table-wrap { max-height: 190px; }
.runtime-rest-table-wrap table { min-width: 650px; }
.runtime-rest-table-wrap td { padding-block: 6px; font-size: .64rem; }
.signal-badge[data-rest="OK"] { color: var(--green); border-color: #2f744b; }
.signal-badge[data-rest="WARNING"], .signal-badge[data-rest="PENDING"] { color: var(--orange); border-color: #65451b; }
.signal-badge[data-rest="ERROR"] { color: var(--red); border-color: #6f3937; }
.backup-status-card { flex: 0 0 auto; }
.backup-summary { margin-bottom: 8px; }
.diagnostics-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; color: var(--muted); font-size: .62rem; }
.diagnostics-summary strong { color: var(--text); font-family: ui-monospace, monospace; }
.diagnostics-table-wrap {
  flex: 0 0 clamp(120px, 20dvh, 220px);
  min-height: 120px;
  max-height: 220px;
}
.diagnostics-actions { display: grid; grid-template-columns: auto minmax(140px, 1fr) auto; gap: 8px; margin-top: 10px; }
.diagnostics-live { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.diagnostics-live-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.diagnostics-live-heading h3 { margin: 2px 0 0; font-size: .82rem; }
.live-readiness-wrap { max-height: 180px; margin-bottom: 9px; }
.diagnostics-live > .button { margin-right: 6px; }
.diagnostic-history-table-wrap { max-height: 180px; margin-bottom: 8px; }
.diagnostic-history-table-wrap td[data-diagnostics="OK"] { color: var(--green); }
.diagnostic-history-table-wrap td[data-diagnostics="MISMATCH"],
.diagnostic-history-table-wrap td[data-diagnostics="ERROR"] { color: var(--red); }
.gate-testnet-actions { display: grid; grid-template-columns: minmax(210px, 1fr) auto; gap: 8px; margin-top: 8px; }
.signal-badge[data-readiness="READY"] { color: var(--green); border-color: #2f744b; }
.signal-badge[data-readiness="FAILED"] { color: var(--red); border-color: #6f3937; }
.signal-badge[data-readiness="NOT_CONFIGURED"] { color: var(--orange); border-color: #65451b; }
.impulse-section-title { margin: 9px 1px 6px; color: var(--green); font-size: .61rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.impulse-section-title span { color: var(--text); }
.impulse-windows { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; flex: 0 0 auto; min-width: 0; }
.impulse-window { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: rgba(5, 11, 8, .55); }
.impulse-window > span { display: block; color: var(--muted); font-size: .68rem; font-weight: 700; }
.impulse-window > strong { display: block; overflow: hidden; margin: 4px 0 6px; color: var(--green); font: 750 .68rem ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.impulse-shares { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.impulse-shares small { color: var(--muted); font: .63rem ui-monospace, monospace; white-space: nowrap; }
.impulse-shares small:first-child b { color: var(--green); }
.impulse-shares small:last-child b { color: var(--red); }
.impulse-split { display: flex; height: 4px; margin-top: 6px; overflow: hidden; border-radius: 999px; background: #17221d; }
.impulse-split i, .impulse-split em { display: block; width: 0; height: 100%; transition: width .25s ease; }
.impulse-split i { background: var(--green); }
.impulse-split em { background: var(--red); }
.rsi-title { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.rsi-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; min-height: 0; }
.rsi-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px; background: rgba(5, 11, 8, .55); }
.rsi-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; min-width: 0; }
.rsi-card-head > span { color: var(--muted); font-size: .65rem; font-weight: 700; white-space: nowrap; }
.rsi-card strong { margin: 0; font: 750 .74rem ui-monospace, monospace; white-space: nowrap; }
.rsi-card small { display: none; }
.rsi-card svg { display: block; width: 100%; height: clamp(52px, 7dvh, 68px); margin-top: 5px; overflow: visible; }
.rsi-axis { position: relative; height: 14px; margin-top: 2px; color: var(--muted); font: .61rem ui-monospace, monospace; }
.rsi-axis span { position: absolute; top: 3px; white-space: nowrap; }
.rsi-axis span::before { content: ""; position: absolute; top: -3px; left: 50%; width: 1px; height: 3px; background: rgba(130, 151, 142, .55); }
.rsi-axis span:first-child { left: 0; }
.rsi-axis span:first-child::before { left: 0; }
.rsi-axis span:last-child { left: 50%; transform: translateX(-50%); }
.rsi-card svg line { stroke: rgba(130, 151, 142, .42); stroke-width: .65; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.rsi-card svg .rsi-segment { stroke-width: 1.5; stroke-dasharray: none; vector-effect: non-scaling-stroke; }
.rsi-card svg .rsi-segment.neutral { stroke: #eef5f1; }
.rsi-card svg .rsi-segment.overbought { stroke: var(--red); }
.rsi-card svg .rsi-segment.oversold { stroke: var(--green); }
.rsi-card svg circle { stroke-width: 3; vector-effect: non-scaling-stroke; }
.rsi-card[data-zone="OVERBOUGHT"] strong { color: var(--red); }
.rsi-card[data-zone="OVERBOUGHT"] svg circle { fill: var(--red); stroke: rgba(255, 107, 119, .28); }
.rsi-card[data-zone="OVERSOLD"] strong { color: var(--green); }
.rsi-card[data-zone="OVERSOLD"] svg circle { fill: var(--green); stroke: rgba(92, 240, 154, .28); }
.rsi-card[data-zone="NEUTRAL"] strong { color: #eef5f1; }
.rsi-card[data-zone="NEUTRAL"] svg circle { fill: #eef5f1; stroke: rgba(238, 245, 241, .28); }
.rsi-card[data-alert-enabled="true"] { border-color: #3b9d67; box-shadow: inset 0 0 0 1px rgba(99, 239, 155, .08); }
.rsi-card[data-mode="live"] .rsi-card-head > span::after { content: " LIVE"; color: var(--orange); font-size: .54rem; font-weight: 800; }

.ladder-panel { display: flex; flex-direction: column; }
.ladder-head { display: grid; grid-template-columns: 1fr 1.2fr .8fr; gap: 8px; padding: 0 7px 7px; color: var(--muted); font-size: .6rem; text-transform: uppercase; letter-spacing: .07em; }
.ladder-head span:nth-child(2), .ladder-head span:nth-child(3) { text-align: right; }
.grid-ladder { min-height: 0; flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: rgba(5, 11, 8, .48); scrollbar-color: #3b5f4f transparent; scrollbar-width: thin; }
.ladder-row { position: relative; display: grid; grid-template-columns: 1fr 1.2fr .8fr; gap: 8px; align-items: center; min-height: 37px; padding: 7px 8px; border-bottom: 1px solid rgba(37, 51, 46, .62); overflow: hidden; }
.ladder-row:last-child { border-bottom: 0; }
.ladder-bar { position: absolute; left: 62px; bottom: 4px; height: 3px; max-width: calc(100% - 76px); border-radius: 999px; background: rgba(92, 240, 154, .75); pointer-events: none; }
.ladder-row.buyback .ladder-bar { background: rgba(255, 180, 79, .75); }
.ladder-level { position: relative; z-index: 1; font: 750 .64rem ui-monospace, monospace; }
.ladder-price, .ladder-offset { position: relative; z-index: 1; text-align: right; font: .62rem ui-monospace, monospace; }
.ladder-offset { color: var(--green); }
.ladder-row.buyback .ladder-offset { color: var(--orange); }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(1, 5, 3, .76); backdrop-filter: blur(7px); }
.modal-dialog { position: relative; width: min(620px, 100%); max-height: calc(100dvh - 36px); overflow: auto; border: 1px solid var(--line-bright); border-radius: 16px; padding: 20px; background: linear-gradient(145deg, #132019, #0b120f); box-shadow: 0 34px 110px rgba(0, 0, 0, .62); scrollbar-color: #3b5f4f transparent; scrollbar-width: thin; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.modal-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: #121b17; color: var(--muted); cursor: pointer; font-size: 1.25rem; line-height: 1; }
.modal-close:hover { color: var(--text); border-color: var(--line-bright); }
.modal-description { margin: 0 0 15px; color: var(--muted); font-size: .73rem; line-height: 1.5; }
.grid-manager-dialog { width: min(590px, 100%); }
.grid-manager-list { display: grid; gap: 7px; max-height: 240px; overflow: auto; margin-bottom: 14px; }
.grid-manager-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 12, 9, .55);
  cursor: pointer;
}
.grid-manager-item:hover, .grid-manager-item.active { border-color: var(--green-dim); }
.grid-manager-item.active { background: rgba(18, 59, 38, .42); }
.grid-manager-item strong { display: block; font-size: .77rem; }
.grid-manager-item small { color: var(--muted); font: 650 .62rem ui-monospace, monospace; }
.grid-manager-item .grid-status { color: var(--green); font: 750 .62rem ui-monospace, monospace; }
.grid-manager-item .grid-order-count { color: var(--muted); font-size: .65rem; }
.grid-manager-create { display: grid; grid-template-columns: minmax(0, 1fr) 110px; align-items: end; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }
.grid-manager-delete { display: grid; grid-template-columns: minmax(0, 1fr) 190px; align-items: end; gap: 9px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.grid-manager-delete p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .68rem; }
.grid-manager-delete .button { min-height: 38px; }
.live-activation-dialog { width: min(580px, 100%); }
.live-warning { display: grid; gap: 6px; margin-bottom: 14px; padding: 12px; border: 1px solid #75413c; border-radius: 10px; background: rgba(133, 46, 40, .1); }
.live-warning strong { color: var(--red); font-size: .75rem; }
.live-warning span { color: #c8b5b1; font-size: .66rem; line-height: 1.4; }
.live-activation-form { display: grid; gap: 12px; }
.risk-acknowledgement { display: flex; align-items: flex-start; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; color: #c5d4cd; font-size: .69rem; line-height: 1.4; }
.risk-acknowledgement input { width: auto; height: auto; margin-top: 2px; accent-color: var(--red); }
.live-activation-result { margin-top: 13px; padding: 11px; border: 1px solid #2f744b; border-radius: 9px; color: #bcd2c7; background: rgba(34, 111, 67, .08); font: .64rem/1.6 ui-monospace, monospace; white-space: pre-line; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rsi-settings { display: grid; gap: 14px; }
.rsi-intervals { display: grid; gap: 7px; border: 0; padding: 0; margin: 0; }
.rsi-intervals legend { width: 100%; margin-bottom: 4px; color: #b5c8bf; font-size: .68rem; font-weight: 700; }
.rsi-intervals legend span, .rsi-intervals legend small { display: inline-block; width: calc(100% - 158px); }
.rsi-intervals legend small { width: 150px; color: var(--muted); font-weight: 600; }
.rsi-mode-row { display: grid; grid-template-columns: 1fr 150px; gap: 8px; }
.rsi-intervals label { display: flex; align-items: center; gap: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(5, 11, 8, .48); }
.rsi-mode-row select { height: 35px; font-size: .68rem; }
.rsi-intervals input { width: auto; height: auto; accent-color: var(--green); }
.modal-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: 9px; }
.safety-actions { grid-template-columns: 1fr 1fr; margin-top: 14px; }
.safety-actions #resetEmergencyButton { grid-column: 1 / -1; }
.modal-divider { height: 1px; margin: 18px 0; background: var(--line); }
.impulse-settings { display: grid; gap: 13px; }
.settings-title-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.settings-title-row h3 { margin: 3px 0 0; font-size: .9rem; }
.switch-label { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(5, 11, 8, .48); cursor: pointer; }
.switch-label input { width: auto; height: auto; accent-color: var(--green); }
.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.scenario-dialog { width: min(560px, 100%); }
.replay-dialog { width: min(760px, 100%); }
.replay-source { display: grid; gap: 4px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5, 11, 8, .55); }
.replay-source span { color: var(--muted); font-size: .61rem; }
.replay-source strong { color: var(--text); font: 700 .68rem ui-monospace, monospace; }
.replay-source small { color: var(--green); font-size: .62rem; line-height: 1.4; }
.replay-report .scenario-report-grid { grid-template-columns: repeat(3, 1fr); }
.scenario-form { display: grid; gap: 14px; }
.scenario-progress { display: grid; gap: 7px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5, 11, 8, .55); }
.scenario-progress > div { display: flex; justify-content: space-between; gap: 10px; color: #b5c8bf; font-size: .68rem; }
.scenario-progress strong { color: var(--green); font-family: ui-monospace, monospace; }
.scenario-progress > i { display: block; height: 7px; overflow: hidden; border-radius: 999px; background: #173125; }
.scenario-progress > i b { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.scenario-progress small { color: var(--muted); font-size: .61rem; line-height: 1.35; }

.history-import-box { display: grid; grid-template-columns: minmax(0, 1fr) 9rem 8.5rem; gap: 10px; align-items: center; padding: 11px; border: 1px dashed var(--line-bright); border-radius: 11px; background: rgba(6, 14, 10, .55); }
.history-import-box > div { min-width: 0; }
.history-import-box span, .history-import-box strong, .history-import-box small { display: block; }
.history-import-box span { color: var(--muted); font-size: .72rem; }
.history-import-box strong { margin: 3px 0; color: var(--text); font-size: .78rem; }
.history-import-box small { color: var(--muted); font-size: .68rem; }
.history-import-box select, .history-import-box button { height: 38px; }
.history-import-box > i { grid-column: 1 / -1; height: 4px; overflow: hidden; border-radius: 999px; background: var(--green-deep); }
.history-import-box > i > b { display: block; width: 0; height: 100%; background: var(--green); transition: width .2s ease; }
.scenario-report { padding: 11px; border: 1px solid #2b5a42; border-radius: 10px; background: rgba(34, 111, 67, .08); }
.scenario-report-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.scenario-report-heading span { display: block; color: var(--muted); font-size: .6rem; }
.scenario-report-heading strong { display: block; margin-top: 3px; color: var(--green); font: 800 .9rem ui-monospace, monospace; }
.scenario-report-heading small { color: var(--green); font: 750 .7rem ui-monospace, monospace; }
.scenario-report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.scenario-report-grid article { min-width: 0; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: rgba(5, 11, 8, .5); }
.scenario-report-grid span, .scenario-report-grid small { display: block; color: var(--muted); font-size: .59rem; }
.scenario-report-grid strong { display: block; margin: 4px 0 3px; overflow: hidden; color: var(--text); font: 700 .64rem ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
body.modal-open { overflow: hidden; }

.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 15%, rgba(40, 106, 71, .18), transparent 42%), var(--background); }
.auth-card { width: min(410px, 100%); padding: 26px; border: 1px solid var(--line-bright); border-radius: 18px; background: linear-gradient(145deg, #132019, #0a120e); box-shadow: 0 30px 100px rgba(0, 0, 0, .55); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-brand h1 { margin: 0; font-size: 1.35rem; }
.auth-brand p { margin: 4px 0 0; color: var(--green); font: 700 .67rem ui-monospace, monospace; text-transform: uppercase; letter-spacing: .11em; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 7px; color: #c9d8d0; font-size: .75rem; font-weight: 700; }
.auth-form input { min-height: 45px; }
.auth-form .button { min-height: 45px; margin-top: 4px; }
.auth-form .message { min-height: 18px; margin: 0; }
.auth-help, .auth-disabled { margin: -8px 0 20px; color: var(--muted); font-size: .73rem; line-height: 1.5; }
.account-menu { position: relative; flex: 0 0 auto; color: var(--text); font-size: .68rem; }
.account-menu summary {
  min-width: 0;
  max-width: 170px;
  min-height: 32px;
  padding: 6px 9px 6px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 15, 12, .88);
  cursor: pointer;
  list-style: none;
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-chevron { flex: 0 0 auto; color: var(--green); font-size: .9rem; line-height: 1; transition: transform .15s ease; }
.account-menu[open] .account-menu-chevron { transform: rotate(180deg); }
.account-menu-panel {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 7px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line-bright);
  border-radius: 11px;
  background: #0b1510;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .5);
}
.account-menu-panel a,
.account-menu-panel button {
  width: 100%;
  min-height: 31px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  color: var(--green);
  background: transparent;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font: 750 .68rem Inter, system-ui, sans-serif;
}
.account-menu-panel a:hover { color: var(--text); background: #13231a; }
.account-menu-panel button { margin-top: 3px; border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; color: var(--muted); }
.account-menu-panel button:hover { color: var(--red); background: #211311; }
.telegram-account-link {
  margin-bottom: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(5, 11, 8, .45);
  font-size: .72rem;
}
.telegram-account-link a { flex: 0 0 auto; color: var(--green); font-weight: 800; text-decoration: none; }
.main-navigation { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #0a120e; }
.brand .main-navigation { margin-left: 18px; }
.main-navigation a { padding: 5px 9px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 800; }
.main-navigation a:hover { color: var(--text); }
.main-navigation a.active { color: #05110b; background: var(--green); }
.page-trading .service-page-content { display: none !important; }
.page-service .trading-page-content { display: none !important; }
.page-service .workspace { grid-template-columns: minmax(0, 1fr); }
.page-service .overview { min-height: calc(100dvh - 116px); }
.page-service .view-tabs { margin-top: 0; }
.page-service .monitor-view.active { min-height: 0; overflow: visible; }
.page-service .simulation-box { margin-top: 14px; }
.auth-page { height: auto; overflow: auto; }
.admin-card { width: min(1400px, 100%); margin-block: 18px; }
.admin-toolbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 22px; }
.admin-toolbar a { color: var(--green); text-decoration: none; }
.admin-toolbar-links { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.admin-user-form { grid-template-columns: 1fr 1fr 1.25fr .9fr .58fr auto auto; gap: 10px; align-items: end; }
.admin-user-form .button { margin: 0; }
.admin-access-toggle { min-height: 45px; display: flex !important; align-items: center; gap: 8px !important; white-space: nowrap; }
.admin-access-toggle input { width: 18px; height: 18px; min-height: 18px; flex: 0 0 18px; padding: 0; accent-color: var(--green); }
.admin-create-button { min-width: 110px; }
.admin-users { display: grid; gap: 10px; margin-top: 20px; }
.admin-user { display: grid; grid-template-columns: minmax(140px, .7fr) minmax(140px, .8fr) minmax(250px, 1.35fr) minmax(480px, 2.15fr); gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: rgba(5, 11, 8, .28); }
.admin-user > div:first-child { display: grid; gap: 3px; }
.admin-user small { color: var(--muted); }
.admin-user > small { line-height: 1.45; }
.admin-user-actions { min-width: 0; display: grid; grid-template-columns: minmax(150px, 1fr) auto auto; gap: 8px; align-items: center; }
.admin-user-actions .button { min-height: 39px; margin: 0; white-space: nowrap; }
.admin-user-actions input { min-height: 39px; }
.admin-user-policy { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(170px, 1fr) 76px auto; gap: 8px; }
.admin-user-policy select { min-width: 0; }
.admin-user-policy input { width: 76px; }
.admin-password-input { grid-column: 1 / 3; width: 100%; }
.admin-password-button { grid-column: 3; }
.billing-card { width: min(1120px, 100%); }
.billing-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; margin-bottom: 18px; }
.billing-user { display: grid; gap: 7px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.billing-user small { color: var(--muted); }
.billing-values { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; }
.billing-values .paid { color: var(--green); }
.billing-values .due { color: var(--red); }
.billing-payment-form { grid-template-columns: 1fr .7fr 1.5fr auto; align-items: end; margin-bottom: 8px; }
.billing-payment-form .button { margin: 0; }
.billing-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.billing-table { width: 100%; border-collapse: collapse; }
.billing-table th, .billing-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.billing-table th { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.billing-table tr:last-child td { border-bottom: 0; }
.billing-table tr.reversal { color: var(--muted); }
.account-billing-card { width: min(900px, 100%); }
.account-billing-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0 26px; }
.account-billing-value { display: grid; gap: 8px; min-height: 90px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.account-billing-value span { color: var(--muted); font-size: .76rem; }
.account-billing-value strong { align-self: end; font-size: 1.05rem; }
.account-billing-value.paid strong { color: var(--green); }
.account-billing-value.due strong { color: var(--red); }
.audit-page { place-items: start center; }
.audit-card { width: min(1500px, 100%); margin-block: 18px; }
.audit-filters { display: grid; grid-template-columns: minmax(260px, 1fr) 120px 130px; gap: 10px; align-items: end; }
.audit-filters label { display: grid; gap: 6px; color: #c9d8d0; font-size: .7rem; font-weight: 700; }
.audit-filters select, .audit-filters .button { min-height: 39px; }
.audit-table-wrap { max-height: calc(100dvh - 220px); margin-top: 10px; overflow: auto; }
.audit-table { min-width: 1050px; }
.audit-table th { position: sticky; top: 0; z-index: 1; background: #101b15; }
.audit-table td { font-size: .68rem; vertical-align: top; }
.audit-table td:nth-child(1), .audit-table td:nth-child(5) { white-space: nowrap; }
.audit-table td:nth-child(4), .audit-table td:nth-child(6) { font-family: ui-monospace, monospace; }
.security-shell { width: min(980px, 100%); max-width: 980px; margin-block: 18px; }
.security-section { margin-top: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5, 11, 8, .35); }
.security-section h2 { margin-top: 0; }
.security-status-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.security-status-panel h2 { margin: 4px 0; }
.security-status-panel p { margin: 0; color: var(--muted); }
#mfaStatusBadge[data-state="on"] { color: var(--green); border-color: #236845; }
#mfaStatusBadge[data-state="required"] { color: var(--yellow); border-color: #6d5727; }
.security-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-top: 16px; }
.security-form label { display: grid; gap: 6px; min-width: 220px; color: #c9d8d0; font-size: .78rem; font-weight: 700; }
.security-form input, .security-form .button { min-height: 42px; }
.integrations-shell { width: min(1080px, 100%); max-width: 1080px; }
.integration-warning { padding: 12px; border: 1px solid #75413c; border-radius: 10px; color: var(--red); background: #211311; }
.integration-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.integration-heading h2 { margin: 0; }
.integration-card-primary { border-color: #286844; }
.integration-card .security-form { align-items: end; }
.integration-card .security-form label { flex: 1 1 230px; }
.integration-actions { display: flex; gap: 9px; margin-top: 10px; }
.integration-delete { margin-top: 10px; }
.integration-actions .integration-delete { margin-top: 0; }
.integration-exchange-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.integration-status[data-state="on"] { color: var(--green); border-color: #286844; }
.integration-status[data-state="off"] { color: var(--muted); }
.danger-form { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.mfa-qr-area { display: flex; gap: 22px; align-items: center; margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: #132019; }
.mfa-qr-area img { width: 210px; height: 210px; object-fit: contain; }
.mfa-qr-area code { display: block; max-width: 430px; padding: 10px; border-radius: 7px; background: #dce9e2; overflow-wrap: anywhere; font-size: .9rem; }
.mfa-qr-area .muted { color: #496156; }
.recovery-panel { border-color: #77612c; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 8px; max-width: 520px; margin: 15px 0; }
.recovery-codes code { padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); font-size: .92rem; letter-spacing: .06em; }
@media (max-width: 760px) {
  .billing-payment-form { grid-template-columns: 1fr; }
  .account-billing-summary { grid-template-columns: repeat(2, 1fr); }
  .audit-filters { grid-template-columns: 1fr; }
  .mfa-qr-area { align-items: flex-start; flex-direction: column; }
  .recovery-codes { grid-template-columns: 1fr; }
  .integration-exchange-grid { grid-template-columns: 1fr; }
  .telegram-account-link { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 1180px) {
  .admin-user-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-create-button { width: 100%; }
  .admin-user { grid-template-columns: minmax(140px, .7fr) minmax(180px, 1.3fr); }
  .admin-user-actions { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .admin-toolbar { align-items: flex-start; flex-direction: column; }
  .admin-toolbar-links { justify-content: flex-start; }
  .admin-user-form, .admin-user { grid-template-columns: 1fr; }
  .admin-user-actions { grid-column: auto; grid-template-columns: 1fr; }
  .admin-user-policy { grid-column: auto; grid-template-columns: 1fr 82px; }
  .admin-user-policy .button { grid-column: 1 / -1; }
  .admin-password-input, .admin-password-button { grid-column: auto; width: 100%; }
}

@media (max-width: 1700px) {
  .workspace { grid-template-columns: minmax(310px, .82fr) minmax(500px, 1.3fr) minmax(460px, 1.1fr); }
  .shell { width: calc(100% - 20px); }
  .controls, .overview, .impulse-panel, .ladder-panel { padding: 11px; }
  .status-stack { gap: 5px; }
  .badge { padding-inline: 8px; }
  .account-menu summary { max-width: 145px; }
}

@media (max-width: 1320px) {
  body { height: auto; overflow: auto; }
  .shell { height: auto; min-height: 100dvh; grid-template-rows: auto auto; padding: 10px 0 20px; }
  .topbar { display: flex; flex-wrap: wrap; }
  .market-display { margin-left: auto; }
  .status-stack { justify-self: auto; }
  .brand .main-navigation { margin-left: 8px; }
  .workspace { grid-template-columns: minmax(300px, .8fr) minmax(500px, 1.2fr); }
  .right-rail { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; grid-template-rows: 420px; }
  .controls, .overview { min-height: 720px; }
}

@media (max-width: 760px) {
  .brand { flex-wrap: wrap; }
  .brand .main-navigation { width: 100%; margin-left: 0; order: 2; }
  .status-stack { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .workspace { display: flex; flex-direction: column; }
  .controls, .overview { min-height: 720px; }
  .right-rail { display: flex; flex-direction: column; }
  .impulse-panel { min-height: 0; }
  .ladder-panel { min-height: 380px; }
  .metrics { grid-template-columns: 1fr; }
  .metric-pair { display: grid; grid-template-columns: 1fr 1fr; }
  .history-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article + article { border-top: 0; border-left: 1px solid var(--line); }
  .history-import-box { grid-template-columns: 1fr 1fr; }
  .history-import-box > div { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .topbar { align-items: flex-start; }
  .brand h1 { font-size: .95rem; }
  .market-display { width: 100%; justify-content: space-between; order: 2; }
  .market-switch { flex: 0 0 auto; }
  .header-price { min-width: 140px; padding-inline: 4px; }
  .header-price strong { font-size: 1.05rem; }
  .controls-grid, .row, .modal-actions, .settings-grid, .diagnostics-actions, .gate-testnet-actions, .grid-manager-create, .grid-manager-delete { grid-template-columns: 1fr; }
  .grid-selector-row { grid-template-columns: 1fr 1fr 38px; }
  .tooltip-field .field-help::after { width: 100%; }
  .controls { min-height: 1050px; }
  .overview { min-height: 760px; }
  .notification-button { width: 100%; justify-content: center; }
  .rsi-mode-row { grid-template-columns: 1fr 135px; }
  .scenario-report-grid { grid-template-columns: 1fr 1fr; }
  .runtime-stream-grid { grid-template-columns: 1fr; }
  .simulation-box, .simulation-action { flex-direction: column; align-items: stretch; min-width: 0; }
}
.shell[data-system-admin="false"] .system-admin-only {
  display: none !important;
}
