:root {
  color-scheme: dark;
  --bg: #0d0f0e;
  --panel: #121512;
  --panel-2: #171a16;
  --line: #31362f;
  --line-strong: #4b5148;
  --text: #f1f0e8;
  --muted: #aaa99f;
  --faint: #75796f;
  --amber: #e4af42;
  --amber-soft: #2a2415;
  --green: #8fc587;
  --green-soft: #172319;
  --red: #ed766a;
  --red-soft: #281817;
  --blue: #82aeda;
  --tone-success: #8fc587;
  --tone-success-soft: #172319;
  --tone-success-border: #36513a;
  --tone-success-text: #b6ddb0;
  --tone-danger: #ed766a;
  --tone-danger-soft: #281817;
  --tone-danger-border: #70352f;
  --tone-danger-text: #ffb0a8;
  --tone-warning: #e4af42;
  --tone-warning-soft: #2a2415;
  --tone-warning-border: #625228;
  --tone-warning-text: #f4ca72;
  --tone-info: #82aeda;
  --tone-info-soft: #17202a;
  --tone-info-border: #31485e;
  --tone-info-text: #b7d2ee;
  --operations-height: 37px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.35 var(--sans); }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { 
  cursor: pointer; 
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: rgba(228, 175, 66, 0.2);
  user-select: none;
}
button:active:not(:disabled) {
  transform: scale(0.96);
}
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { 
  outline: 2px solid var(--amber); 
  outline-offset: 2px; 
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; letter-spacing: -.02em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--faint); font: 10px/1.2 var(--mono); letter-spacing: .12em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.topbar { height: 54px; position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 180px auto minmax(210px, auto) minmax(180px, 1fr) auto auto; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(13,15,14,.98); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 720; }
.brand small { color: var(--faint); font: 10px var(--mono); text-transform: uppercase; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; background: var(--amber); color: #111; font-weight: 900; }
.connection { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.connection.online i { background: var(--green); box-shadow: 0 0 8px rgba(143,197,135,.5); }
.connection.offline i { background: var(--red); }
.connection strong { color: var(--text); font: 650 11px var(--mono); white-space: nowrap; }
.connection-separator { color: var(--faint); }
.search-wrap { position: relative; width: 100%; min-width: 0; }
.search input, input, select { 
  width: 100%; 
  min-height: 34px; 
  border: 1px solid var(--line-strong); 
  border-radius: 3px; 
  background: #111310; 
  padding: 6px 10px; 
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.search input:hover, input:hover:not(:disabled), select:hover:not(:disabled) {
  border-color: rgba(228, 175, 66, 0.6);
  background: #151814;
}
.search input:focus, input:focus, select:focus {
  border-color: var(--amber);
  outline: none;
  box-shadow: 0 0 0 2px rgba(228, 175, 66, 0.25);
  background: #171c15;
}
.search input { min-width: 0; font: 600 13px var(--mono); }
.search-dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 320px; overflow-y: auto; background: #151814; border: 1px solid var(--amber); border-radius: 3px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.6); list-style: none; margin: 0; padding: 4px 0; }
.search-dropdown-item { padding: 8px 12px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #222621; font: 12px var(--mono); transition: background-color 0.12s ease; }
.search-dropdown-item:last-child { border-bottom: 0; }
.search-dropdown-item:hover, .search-dropdown-item.active { background: #232a21; color: var(--text); }
.search-dropdown-item strong { color: var(--amber); font-weight: 700; font-size: 13px; }
.search-dropdown-item .venues { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.search-dropdown-item .venues span { background: #101210; padding: 1px 4px; border-radius: 2px; border: 1px solid var(--line); }
.page-tabs, .settlement-tabs, .direction-tabs, .book-tabs { display: flex; }
.page-tabs button, .settlement-tabs button, .book-tabs button, .operation-tabs button { 
  border: 0; 
  border-bottom: 2px solid transparent; 
  background: transparent; 
  color: var(--muted); 
  padding: 10px 11px 8px; 
  font-weight: 650; 
  border-radius: 4px 4px 0 0;
}
.page-tabs button:hover, .settlement-tabs button:hover, .book-tabs button:hover, .operation-tabs button:hover {
  color: var(--text);
  background: rgba(228, 175, 66, 0.08);
  border-bottom-color: rgba(228, 175, 66, 0.4);
}
.page-tabs button:active, .settlement-tabs button:active, .book-tabs button:active, .operation-tabs button:active {
  background: rgba(228, 175, 66, 0.16);
  color: var(--amber);
}
.page-tabs button.active, .settlement-tabs button.active, .book-tabs button.active { 
  border-color: var(--amber); 
  color: var(--text); 
  background: rgba(228, 175, 66, 0.12);
}
.clock { justify-self: end; display: flex; align-items: center; gap: 10px; font: 11px var(--mono); color: var(--muted); }
.clock button, .quiet { 
  border: 1px solid var(--line); 
  border-radius: 3px; 
  background: transparent; 
  padding: 5px 8px; 
}
.clock button:hover, .quiet:hover {
  background: #1c221b;
  border-color: var(--line-strong);
  color: var(--text);
}
.clock button:active, .quiet:active {
  background: #252e24;
  border-color: var(--amber);
  transform: scale(0.95);
}
.top-actions { display: flex; gap: 7px; }
.ticket-toggle, .mobile-settings { display: none; }

.account-strip { min-height: 54px; display: grid; grid-template-columns: 150px 1fr; border-bottom: 1px solid var(--line); background: var(--panel); }
.account-total { padding: 8px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.account-total span { color: var(--muted); font-size: 11px; }
.account-total strong { font: 650 18px var(--mono); }
.account-list { min-width: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); overflow-x: auto; scrollbar-width: thin; }
.account { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 14px; border-right: 1px solid var(--line); }
.account strong { font-size: 12px; }
.account .equity { font: 650 13px var(--mono); }
.account small { color: var(--muted); font: 10px var(--mono); }
.skeleton { align-self: center; padding: 0 14px; color: var(--faint); }

.desk-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.workspace { min-width: 0; padding: 18px 20px calc(var(--operations-height) + 30px); border-right: 1px solid var(--line); }
[hidden], .page-view[hidden] { display: none !important; }
.page-heading { min-height: 52px; display: flex; align-items: baseline; gap: 14px; border-bottom: 1px solid var(--line); }
.page-heading p { color: var(--muted); font-size: 11px; }
.market-head { display: flex; align-items: center; justify-content: space-between; min-height: 38px; margin-bottom: 8px; }
.market-head h1 { margin-top: 3px; }
.market-controls { display: flex; align-items: end; gap: 12px; }
.venue-controls { display: flex; gap: 6px; }
.venue-controls button { 
  border: 1px solid var(--line); 
  background: transparent; 
  border-radius: 3px; 
  padding: 5px 8px; 
  color: var(--muted); 
}
.venue-controls button:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.venue-controls button.active { color: var(--text); border-color: var(--line-strong); background: var(--panel-2); }
.venue-controls button.active:hover {
  background: #252d23;
  border-color: var(--amber);
  color: var(--amber);
}
.venue-controls button:not(.active) { opacity: .55; text-decoration: line-through; }
.venue-controls button:not(.active):hover { opacity: .85; }
.market-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.market-table { min-width: 880px; }
.market-table th:first-child, .market-table td:first-child { position: sticky; left: 0; z-index: 2; background: var(--bg); box-shadow: 1px 0 var(--line); width: 34px; min-width: 34px; max-width: 34px; padding: 6px 4px !important; text-align: center !important; }
.market-table input[type="checkbox"],
.venue-checkbox,
#select-all-venues {
  width: 14px !important;
  height: 14px !important;
  min-height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
  padding: 0 !important;
  margin: 0 auto !important;
  display: block !important;
  cursor: pointer;
  accent-color: var(--amber, #f59e0b);
  border-radius: 2px;
}
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-size: 10px; text-align: right; font-weight: 650; padding: 8px 10px; white-space: nowrap; }
th button { border: 0; border-bottom: 1px solid transparent; background: transparent; color: inherit; padding: 0; font: inherit; }
th button:hover, th button.active { color: var(--text); border-color: var(--amber); }
th:first-child, td:first-child { text-align: left; }
td { border-top: 1px solid #242824; padding: 9px 10px; text-align: right; font: 12px var(--mono); white-space: nowrap; }
td.positive { color: var(--green); } td.negative { color: var(--red); }
.risk-ok { color: var(--green); } .risk-block { color: var(--red); font-weight: 700; }

.chart-stack { margin-top: 18px; }
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; }
.chart-status-area { display: flex; align-items: center; gap: 12px; }
.chart-legend-hint { color: var(--muted); font: 11px var(--mono); }
.chart-loading-status { display: inline-flex; align-items: center; gap: 7px; color: var(--amber); font: 600 11px var(--mono); background: rgba(228, 175, 66, 0.08); border: 1px solid rgba(228, 175, 66, 0.25); border-radius: 3px; padding: 2px 8px; }
.chart-loading-status[hidden] { display: none; }
.chart-loading-status[data-state="pending"] { color: var(--muted); background: var(--panel-2); border-color: var(--line); }
.chart-loading-status[data-state="pending"] .chart-spinner { display: none; }
.chart-spinner { display: inline-block; width: 11px; height: 11px; border: 2px solid rgba(228, 175, 66, 0.25); border-top-color: var(--amber); border-radius: 50%; animation: chart-spin 0.75s linear infinite; }
@keyframes chart-spin { to { transform: rotate(360deg); } }
.chart-range-controls, .chart-zoom-controls { display: flex; gap: 4px; }
.zoom-btn { border: 1px solid var(--line-strong); border-radius: 3px; background: #161815; color: var(--text); padding: 3px 8px; font: 600 11px var(--mono); cursor: pointer; }
.zoom-btn:hover { background: #222620; border-color: var(--amber); }
.zoom-btn.active { color: var(--amber); border-color: var(--amber); background: rgba(228, 175, 66, 0.08); }
.chart-panel { border-bottom: 1px solid var(--line); padding: 0 0 16px; margin-bottom: 16px; }
.chart-panel > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.chart-panel header h2 { font-size: 14px; margin: 0; }
.chart-panel header p { color: var(--muted); font-size: 11px; margin-top: 2px; }
.chart-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chart-legend-badge { display: inline-flex; align-items: center; gap: 5px; font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: 0.02em; }
.chart-legend-swatch { display: inline-block; width: 12px; height: 3px; border-radius: 1px; }
.chart-legend-swatch.style-derived { height: 0; border-top: 2px dashed; }
.chart-legend-swatch.style-next-settlement { height: 0; border-top: 2px dotted; }
.chart-legend-swatch.style-actual, .chart-legend-swatch.style-points { width: 6px; height: 6px; border-radius: 50%; }
.chart-legend-text { font-size: 11px; }

.plot-shell { position: relative; height: 250px; border: 1px solid var(--line); background: #0f110f; overflow: hidden; }
.plot-shell .chart-loading-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(15, 17, 15, 0.82); backdrop-filter: blur(2px); z-index: 10; color: var(--amber); font: 600 12px var(--mono); pointer-events: none; }
.plot-shell .chart-loading-overlay[hidden] { display: none; }
.plot-shell canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.plot-shell canvas.dragging { cursor: grabbing; }
.axis-layer { position: absolute; inset: 0; pointer-events: none; color: var(--muted); font: 10px var(--mono); }
.axis-label { position: absolute; padding: 1px 3px; background: rgba(15,17,15,.74); }

.tooltip { position: absolute; min-width: 140px; pointer-events: none; background: rgba(16, 18, 16, 0.94); border: 1px solid var(--line-strong); border-radius: 3px; padding: 6px 9px; box-shadow: 0 8px 24px rgba(0,0,0,0.65); z-index: 15; backdrop-filter: blur(4px); }
.tooltip-inner { display: flex; flex-direction: column; gap: 4px; }
.tooltip-time { color: var(--muted); font: 600 10px var(--mono); padding-bottom: 3px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.tooltip-rows { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.tooltip-row { display: flex; align-items: center; gap: 6px; font: 600 11px var(--mono); white-space: nowrap; }
.tooltip-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.tooltip-name { font-size: 11px; text-transform: uppercase; }
.tooltip-val { font-weight: 700; font-size: 11px; margin-left: auto; padding-left: 8px; }

.verification { border: 1px solid var(--line); background: var(--panel); }
.verification summary { padding: 9px 12px; cursor: pointer; font-weight: 650; }
.verification > div { padding: 10px 12px; border-top: 1px solid var(--line); color: var(--muted); font: 11px var(--mono); white-space: pre-line; line-height: 1.55; }

.books { margin-top: 18px; border-top: 1px solid var(--line); }
.book-tabs { border-bottom: 1px solid var(--line); }
.book-toolbar { min-height: 44px; display: flex; align-items: center; gap: 14px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.book-toolbar label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.book-toolbar select { min-height: 29px; width: auto; padding: 3px 26px 3px 7px; }
.book-toolbar > span { margin-left: auto; font-size: 11px; }
.book-content { min-height: 120px; overflow: auto; }
#page-discover .book-content { max-height: calc(100vh - 250px); border-bottom: 1px solid var(--line); }
.book-content tr:hover { background: #171a16; }
.book-content button { 
  border: 1px solid var(--line-strong); 
  border-radius: 3px; 
  background: transparent; 
  padding: 4px 7px; 
  transition: all 0.15s ease;
}
.book-content button:hover:not(:disabled) {
  background: #252d23;
  border-color: var(--amber);
  color: var(--amber);
}
.book-content button:active:not(:disabled) {
  background: #333d2e;
  transform: scale(0.95);
}
.book-actions { display: flex; justify-content: flex-end; gap: 5px; }
.book-actions button[data-action="view"]:hover:not(:disabled),
.book-actions button[data-action="edit"]:hover:not(:disabled) {
  background: #252d23;
  border-color: var(--amber);
  color: var(--amber);
}
.book-actions button[data-action="execute"]:hover:not(:disabled) {
  background: rgba(143, 197, 135, 0.22);
  border-color: var(--green);
  color: #86efac;
}
.book-actions button[data-action="cancel"]:hover:not(:disabled) {
  background: rgba(224, 108, 117, 0.22);
  border-color: var(--red);
  color: #fca5a5;
}
.book-content td:first-child button[data-action="view"] { width: 100%; border: 0; background: transparent; color: var(--text); padding: 0; text-align: left; font: inherit; }
.book-content td:first-child button[data-action="view"]:hover { color: var(--tone-warning-text); text-decoration: underline; text-underline-offset: 3px; }
.book-content td:first-child button[data-action="view"]:disabled { color: var(--faint); cursor: not-allowed; text-decoration: none; }
.positions-table td { vertical-align: middle; }
.position-detail-row td { padding: 0 10px 8px; text-align: left; background: #101210; }
.position-details summary { width: max-content; padding: 7px 0; color: var(--muted); font: 10px var(--mono); cursor: pointer; transition: color 0.15s ease; }
.position-details summary:hover { color: var(--text); }
.position-details[open] summary { color: var(--text); }
.position-lots { margin: 0 0 5px; border: 1px solid var(--line); }
.position-lots th, .position-lots td { padding: 7px 9px; }
.status-success { color: var(--tone-success-text); }
.status-warning { color: var(--tone-warning-text); }
.status-danger { color: var(--tone-danger-text); }
.status-muted { color: var(--muted); }
.deviation { font-weight: 800; }
.empty { text-align: center !important; color: var(--faint); padding: 24px !important; font-family: var(--sans) !important; }

.order-ticket { position: sticky; top: 54px; max-height: calc(100vh - 54px - var(--operations-height)); overflow-y: auto; padding: 12px 16px 16px; background: var(--panel); scrollbar-width: thin; }
.order-ticket > header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.order-ticket h2 { font-size: 18px; }
.ticket-header-actions { display: flex; align-items: center; gap: 8px; }
.ticket-close { display: none; }
.mode { color: var(--amber); border: 1px solid #625228; padding: 3px 6px; font: 10px var(--mono); text-transform: uppercase; }
.direction-tabs { margin: 9px 0 10px; border-bottom: 1px solid var(--line); }
.direction-tabs button { 
  flex: 1; 
  border: 0; 
  border-bottom: 2px solid transparent; 
  background: transparent; 
  padding: 9px; 
  font-size: 15px; 
  font-weight: 780; 
  transition: all 0.15s ease;
}
.direction-tabs .buy { color: var(--green); } 
.direction-tabs .sell { color: var(--red); }
.direction-tabs .buy:hover { background: rgba(143, 197, 135, 0.12); color: #86efac; border-bottom-color: rgba(143, 197, 135, 0.5); }
.direction-tabs .sell:hover { background: rgba(224, 108, 117, 0.12); color: #fca5a5; border-bottom-color: rgba(224, 108, 117, 0.5); }
.direction-tabs .buy.active { border-color: var(--green); background: var(--green-soft); color: #86efac; }
.direction-tabs .sell.active { border-color: var(--red); background: var(--red-soft); color: #fca5a5; }
.ticket-fields { padding: 0 1px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 7px; }
.strategy-settings { margin: 8px 0 10px; border: 1px solid var(--line); background: #0e120f; }
.strategy-settings summary { cursor: pointer; padding: 9px 10px; color: var(--text); font: 700 11px var(--sans); list-style-position: inside; }
.strategy-settings[open] summary { border-bottom: 1px solid var(--line); color: var(--amber); }
.strategy-settings > .field-grid, .strategy-settings > .checkbox-line { margin-inline: 9px; }
.strategy-settings .field-grid { margin-top: 9px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; margin: 8px 0 10px; color: var(--muted); font-size: 11px; }
.checkbox-line input { width: 16px; height: 16px; min-height: 16px; margin: 0; accent-color: var(--amber); }
.single-field { margin-bottom: 9px; }
label { display: block; color: var(--muted); font-size: 11px; font-weight: 650; }
label input, label select { display: block; margin-top: 4px; color: var(--text); font: 600 13px var(--mono); }
.static-field { display: flex; align-items: center; min-height: 34px; margin-top: 4px; border: 1px solid var(--line); border-radius: 3px; padding: 6px 10px; color: var(--text); background: #101310; font: 600 13px var(--mono); }
.unit-input { position: relative; display: block; }
.unit-input span { position: absolute; right: 9px; bottom: 8px; color: var(--muted); font: 10px var(--mono); }
.unit-input input { padding-right: 38px; }
.risk-card { margin-top: 8px; padding: 9px 10px; border: 1px solid var(--line); background: #101310; }
.leverage-label { margin: 0 0 9px; }
.leverage-readout { float: right; display: inline-flex; align-items: baseline; gap: 7px; }
.leverage-label output { color: var(--text); font: 700 13px var(--mono); }
.leverage-label small { color: var(--faint); font: 9px var(--mono); }
input[type="range"] { appearance: none; height: 4px; min-height: 4px; padding: 0; margin-top: 13px; background: var(--line-strong); border: 0; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; border-radius: 50%; background: var(--amber); transition: transform 0.1s ease, box-shadow 0.15s ease; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); box-shadow: 0 0 10px rgba(228, 175, 66, 0.6); }
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.1); }
.risk-status { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); color: var(--green); font-size: 10px; }
.risk-status span:last-child { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-facts { margin: 10px 0; border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 4px; padding: 10px 12px; background: #0f130f; display: flex; flex-direction: column; gap: 9px; }
.route-facts > div { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.route-facts dt { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.route-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font: 500 13px var(--mono); color: var(--text); }
.route-facts .fact-main { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.route-facts .fact-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.route-facts .edge-badge { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 11px; font-weight: 700; }
.route-facts .edge-badge.positive { background: rgba(143, 197, 135, 0.2); color: var(--green); border: 1px solid rgba(143, 197, 135, 0.4); }
.route-facts .edge-badge.negative { background: rgba(228, 175, 66, 0.18); color: var(--amber); border: 1px solid rgba(228, 175, 66, 0.35); }
.pnl-preview { margin-top: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 0; }
.pnl-preview > div { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
.pnl-preview span { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 10px; }
.pnl-preview span + span { border-left: 1px solid var(--line); padding-left: 8px; }
.pnl-preview strong { color: var(--text); font: 700 14px var(--mono); }
.pnl-preview strong.positive { color: var(--green); }
.pnl-preview strong.negative { color: var(--red); }
.pnl-preview p { margin-top: 7px; color: var(--muted); font: 10px var(--mono); overflow-wrap: anywhere; }
.pnl-preview #pnl-formula { color: var(--text); }
.form-status { margin: 9px 0; color: var(--green); overflow-wrap: anywhere; }
.form-error { margin: 9px 0; color: var(--red); overflow-wrap: anywhere; }
.primary { 
  border: 0; 
  border-radius: 3px; 
  background: var(--amber); 
  color: #15120a; 
  padding: 9px 13px; 
  font-weight: 800; 
  transition: all 0.15s ease;
}
.primary:hover:not(:disabled) {
  background: #fcd34d;
  color: #000;
  box-shadow: 0 0 14px rgba(228, 175, 66, 0.45);
  transform: translateY(-1px);
}
.primary:active:not(:disabled) {
  background: #d97706;
  transform: scale(0.97) translateY(0);
  box-shadow: 0 0 6px rgba(228, 175, 66, 0.3);
}
.primary:disabled { opacity: .45; cursor: not-allowed; }
.arm { position: sticky; bottom: 0; z-index: 3; width: 100%; margin-top: 10px; min-height: 42px; font-size: 15px; box-shadow: 0 -8px 16px var(--panel); }

.edit-dialog { width: min(520px, calc(100vw - 28px)); border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); padding: 0; box-shadow: 0 24px 90px rgba(0,0,0,.68); }
.edit-dialog::backdrop { background: rgba(0,0,0,.7); }
.edit-dialog form { padding: 16px; }
.edit-dialog header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.edit-dialog label > small { display: block; margin: 3px 0 7px; color: var(--muted); font-weight: 400; }
.edit-dialog .primary { width: 100%; margin-top: 15px; }

.operations { position: fixed; z-index: 30; bottom: 0; left: 0; right: 0; height: 150px; border-top: 1px solid var(--line-strong); background: #111310; }
.operations.collapsed { height: 37px; }
.operations.collapsed .operation-rows { display: none; }
.operations > header { height: 37px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.operations nav { display: flex; }
.operations nav button { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 0 14px; font-weight: 650; white-space: nowrap; }
.operations nav button.active { color: var(--text); border-color: var(--amber); }
.operations header > button { border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); padding: 0 12px; }
.operation-rows { height: 113px; overflow: auto; font: 11px var(--mono); }
.operation-row { display: grid; grid-template-columns: 90px 64px 180px 180px 1fr 100px; gap: 8px; border-bottom: 1px solid #242824; padding: 6px 12px; }
.severity-critical, .severity-error { color: var(--red); } .severity-warning { color: var(--amber); } .severity-info { color: var(--blue); }

.login-shell { min-height: 100vh; display: grid; place-items: center; background: #111410; }
.login-panel { width: min(370px, calc(100vw - 32px)); border: 1px solid var(--line-strong); background: var(--panel); padding: 28px; }
.login-panel .brand-mark { margin-bottom: 18px; }
.login-panel h1 { margin: 4px 0; font-size: 28px; }
.login-panel form { margin-top: 22px; }
.login-panel label { margin-bottom: 12px; }
.login-panel button { width: 100%; margin-top: 5px; }

.settings-shell { min-height: 100vh; background: #10120f; }
.settings-topbar { height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 22px; border-bottom: 1px solid var(--line); background: var(--bg); }
.settings-topbar > :last-child { justify-self: end; }
.settings-page { width: min(980px, calc(100vw - 32px)); margin: 0 auto; padding: 34px 0 70px; }
.settings-heading { margin-bottom: 18px; }
.settings-heading h1 { margin: 5px 0; font-size: 27px; }
.settings-heading > p:last-child { color: var(--muted); }
.settings-message { min-height: 24px; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.settings-message.success { color: var(--tone-success-text); }
.settings-message.failure { color: var(--tone-danger-text); }
.settings-section { margin-top: 12px; border: 1px solid var(--line); background: var(--panel); }
.settings-section > header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.settings-section > header h2 { font-size: 16px; }
.settings-section > header p, .settings-note { margin-top: 2px; color: var(--muted); font-size: 11px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 14px; border-bottom: 1px solid #252925; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row strong { color: var(--text); }
.switch-row small, .settings-grid small { color: var(--muted); font-weight: 400; }
.switch-row input { width: 19px; min-height: 19px; accent-color: var(--amber); }
.settings-note { padding: 9px 14px 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.settings-grid > label { min-width: 0; padding: 13px 14px; border-right: 1px solid #252925; border-bottom: 1px solid #252925; }
.settings-grid > label small { display: block; margin: 2px 0 7px; }
.connection-list { display: grid; grid-template-columns: repeat(2, 1fr); }
.connection-setting { display: grid; grid-template-columns: 1fr auto; gap: 3px 14px; padding: 13px 14px; border-right: 1px solid #252925; border-bottom: 1px solid #252925; }
.connection-setting small { grid-column: 1 / -1; color: var(--muted); }
.status-ready { color: var(--green); }
.status-blocked { color: var(--red); }
.employee-form { display: grid; grid-template-columns: 1fr 1.5fr 150px auto; align-items: end; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.employee-form .primary { min-height: 34px; }
.employee-table-wrap { overflow-x: auto; }
.employee-table-wrap th, .employee-table-wrap td { text-align: left; }
.employee-table-wrap td:last-child, .employee-table-wrap th:last-child { text-align: right; }
.employee-table-wrap button:disabled { opacity: .35; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Mobile & Small-Screen Ergonomic Overhaul (Touch Targets >= 44px)
   -------------------------------------------------------------------------- */

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, a, input, select, summary {
  touch-action: manipulation;
}

button {
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 1120px) {
  .desk-layout { grid-template-columns: minmax(0, 1fr) 330px; }
  .topbar { grid-template-columns: auto auto auto minmax(160px, 1fr) auto; }
  .topbar .clock, .topbar .quiet, .topbar .connection { display: none; }
}

@media (max-width: 820px) {
  .desk-layout { display: block; }
  .workspace { border-right: 0; padding: 12px 12px calc(var(--operations-height) + 24px); }

  /* Mobile Full-Screen Order Ticket Drawer */
  .order-ticket {
    display: none !important;
  }
  .order-ticket.open {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 9999 !important;
    padding: 0 16px env(safe-area-inset-bottom, 24px) !important;
    border: 0 !important;
    background: #121512 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .order-ticket > header {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0 -16px 14px;
    padding: 16px 16px 12px;
    background: rgba(18, 21, 18, 0.98);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .ticket-close {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    min-width: 44px;
    padding: 8px 16px;
    font-size: 13.5px;
    font-weight: 750;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text);
  }
  .direction-tabs {
    min-height: 46px;
    border-radius: 6px;
    overflow: hidden;
    margin: 10px 0 14px;
    background: var(--panel-2);
    border: 1px solid var(--line);
  }
  .direction-tabs button {
    min-height: 46px;
    font-size: 15px;
    font-weight: 800;
    padding: 10px;
  }
  .field-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
  }
  .field-grid label {
    font-size: 12px;
    font-weight: 700;
  }
  .field-grid input, .field-grid select, .static-field {
    min-height: 44px;
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
    padding: 10px 12px;
    border-radius: 6px;
  }
  .unit-input span {
    font-size: 12px;
    right: 12px;
    bottom: 12px;
  }
  .unit-input input {
    padding-right: 44px;
  }
  .risk-card {
    padding: 12px 14px;
    border-radius: 6px;
    margin-top: 12px;
  }
  .leverage-label {
    font-size: 13px;
  }
  .leverage-label output {
    font-size: 15px;
  }
  input[type="range"] {
    min-height: 36px;
    margin-top: 6px;
  }
  input[type="range"]::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }
  .pnl-preview {
    padding: 12px;
    background: #0f130f;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-top: 12px;
  }
  .pnl-preview strong {
    font-size: 15px;
  }
  .route-facts {
    padding: 12px 14px;
    margin: 12px 0;
    border-radius: 6px;
  }
  .arm {
    position: sticky;
    bottom: env(safe-area-inset-bottom, 12px);
    z-index: 10;
    min-height: 50px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 6px;
    margin: 16px 0 24px;
    box-shadow: 0 -10px 24px rgba(18, 21, 18, 0.95);
  }

  /* Mobile Top Bar Header */
  .topbar {
    height: auto;
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid !important;
    grid-template-columns: 1fr auto auto !important;
    grid-template-areas:
      "brand settings order"
      "search search search"
      "nav nav nav" !important;
    gap: 7px 8px;
    padding: 8px 10px;
    background: rgba(13, 15, 14, 0.98);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
  }
  .topbar > .brand { grid-area: brand !important; font-size: 15px; gap: 8px; }
  .topbar > .brand-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 4px; }
  .topbar > .connection { grid-area: stream !important; display: none !important; }
  .topbar > .clock, .topbar > .top-actions { display: none !important; }
  .topbar > .mobile-settings {
    grid-area: settings !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    min-width: 38px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 650;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
  }
  .topbar > .ticket-toggle {
    grid-area: order !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--tone-warning-border);
    border-radius: 6px;
    background: var(--amber);
    color: #111;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 800;
  }
  .brand small { display: none; }

  .topbar > .search-wrap { grid-area: search !important; min-width: 0; width: 100%; }
  .topbar > .search-wrap input {
    min-height: 40px;
    font-size: 14px;
    border-radius: 6px;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
  }
  .topbar > .page-tabs {
    grid-area: nav !important;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px;
    padding: 3px;
    background: #181c17;
    border: 1px solid var(--line);
    border-radius: 6px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .topbar > .page-tabs button {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 750;
    border-radius: 4px;
    border: 1px solid transparent !important;
    text-align: center;
    white-space: nowrap;
    color: var(--muted);
    background: transparent;
  }
  .topbar > .page-tabs button.active {
    background: #252d22 !important;
    color: var(--amber) !important;
    border-color: var(--line-strong) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  }

  /* Mobile Account Strip */
  .account-strip {
    min-height: 58px;
    grid-template-columns: 120px minmax(0, 1fr);
  }
  .account-total {
    position: sticky;
    left: 0;
    z-index: 2;
    padding: 8px 12px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    justify-content: center;
  }
  .account-total strong { font-size: 16px; }
  .account-list {
    grid-auto-columns: minmax(190px, auto);
    padding: 4px 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .account {
    scroll-snap-align: start;
    padding: 8px 12px;
    border-radius: 4px;
  }

  /* Market & Route Controls */
  .market-head {
    align-items: flex-start;
    gap: 10px;
  }
  .market-head h1 {
    font-size: 18px;
    max-width: none;
  }
  .market-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
  }
  .settlement-tabs {
    border: 1px solid var(--line);
    border-radius: 4px;
    overflow: hidden;
    background: var(--panel);
  }
  .settlement-tabs button {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
  }
  .venue-controls {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
  }
  .venue-controls button {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 4px;
    white-space: nowrap;
  }

  /* Horizontally Scrollable Tables with Sticky First Column */
  .market-table-wrap {
    margin: 8px -12px;
    padding: 0 12px;
    -webkit-overflow-scrolling: touch;
  }
  .market-table {
    min-width: 820px;
  }
  .market-table th, .market-table td {
    padding: 11px 12px;
    font-size: 12.5px;
  }
  .market-table th:first-child, .market-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg);
    box-shadow: 2px 0 8px rgba(0,0,0,0.5);
  }

  /* Charts on Mobile */
  .chart-stack { margin-top: 14px; }
  .chart-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }
  .chart-legend-hint { font-size: 11px; }
  .chart-zoom-controls { gap: 6px; }
  .zoom-btn {
    min-height: 38px;
    min-width: 38px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 4px;
  }
  .plot-shell { height: 210px; border-radius: 4px; }
  .chart-panel > header { align-items: flex-start; gap: 8px; }

  /* Discovery & Orders Books */
  .book-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 10px;
  }
  .book-toolbar label {
    flex: 1 1 140px;
    font-size: 12px;
    font-weight: 650;
  }
  .book-toolbar select {
    min-height: 42px;
    font-size: 14px;
    border-radius: 4px;
    padding: 8px 12px;
    width: 100%;
  }
  .book-toolbar > span { width: 100%; margin-left: 0; font-size: 11.5px; }
  .book-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    display: flex;
    gap: 4px;
    padding: 6px 12px;
  }
  .book-tabs button {
    min-height: 42px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 4px;
  }
  /* Discovery Mobile Opportunity Cards */
  #discover-content table {
    min-width: 0 !important;
    width: 100% !important;
    border: 0 !important;
    display: block !important;
  }
  #discover-content thead {
    display: none !important;
  }
  #discover-content tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }
  #discover-content tr {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    grid-template-areas:
      "route route dev"
      "settle settle settle"
      "m15 m10 buy"
      "sell v24 fund" !important;
    gap: 6px 8px !important;
    padding: 12px 14px !important;
    background: #151915 !important;
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease !important;
    cursor: pointer !important;
  }
  #discover-content tr:not([data-empty="true"]):hover {
    background: #1a201a !important;
    border-color: rgba(228, 175, 66, 0.4) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5) !important;
  }
  #discover-content tr:not([data-empty="true"]):active {
    transform: scale(0.985) !important;
    background: #202720 !important;
    border-color: var(--amber) !important;
  }
  #discover-content tr[data-empty="true"] {
    display: block !important;
    padding: 16px !important;
    text-align: center !important;
    cursor: default !important;
  }
  #discover-content td {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 13px !important;
  }
  #discover-content td:first-child {
    grid-area: route !important;
    position: static !important;
    box-shadow: none !important;
    align-self: center !important;
  }
  #discover-content td:first-child button {
    background: transparent !important;
    border: 0 !important;
    color: #fff !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    text-align: left !important;
    padding: 0 !important;
    min-height: auto !important;
  }
  #discover-content td:nth-child(5) {
    grid-area: dev !important;
    justify-self: end !important;
    align-self: center !important;
    font-size: 13.5px !important;
    font-weight: 800 !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
  }
  #discover-content td:nth-child(2) {
    grid-area: settle !important;
    font-size: 12px !important;
    color: var(--muted) !important;
    margin-bottom: 2px !important;
  }
  #discover-content td:nth-child(3) { grid-area: m15 !important; }
  #discover-content td:nth-child(4) { grid-area: m10 !important; }
  #discover-content td:nth-child(6) { grid-area: buy !important; }
  #discover-content td:nth-child(7) { grid-area: sell !important; }
  #discover-content td:nth-child(8) { display: none !important; }
  #discover-content td:nth-child(9) { grid-area: v24 !important; }
  #discover-content td:nth-child(10) { grid-area: fund !important; }

  #discover-content td:nth-child(3),
  #discover-content td:nth-child(4),
  #discover-content td:nth-child(6),
  #discover-content td:nth-child(7),
  #discover-content td:nth-child(9),
  #discover-content td:nth-child(10) {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    padding: 6px 8px !important;
    background: #1c221b !important;
    border-radius: 4px !important;
    border: 1px solid #232a21 !important;
    font-size: 12px !important;
    font-weight: 650 !important;
  }
  #discover-content td:nth-child(3)::before,
  #discover-content td:nth-child(4)::before,
  #discover-content td:nth-child(6)::before,
  #discover-content td:nth-child(7)::before,
  #discover-content td:nth-child(9)::before,
  #discover-content td:nth-child(10)::before {
    content: attr(data-label) !important;
    font-size: 9.5px !important;
    font-weight: 750 !important;
    color: #839282 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.4px !important;
  }

  /* Orders & Positions Book Mobile Cards */
  #book-content table {
    min-width: 0 !important;
    width: 100% !important;
    border: 0 !important;
    display: block !important;
  }
  #book-content thead { display: none !important; }
  #book-content tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }
  #book-content tr:not(.position-detail-row) {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px 8px !important;
    padding: 12px 14px !important;
    background: #151915 !important;
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease !important;
  }
  #book-content tr:not(.position-detail-row):hover {
    background: #1a201a !important;
    border-color: rgba(228, 175, 66, 0.3) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5) !important;
  }
  #book-content td {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 13px !important;
  }
  #book-content td:first-child {
    grid-column: 1 / -1 !important;
    position: static !important;
    box-shadow: none !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    color: #fff !important;
    padding-bottom: 4px !important;
    border-bottom: 1px solid var(--line) !important;
    margin-bottom: 4px !important;
  }
  #book-content td:not(:first-child):not(.book-actions) {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    padding: 6px 8px !important;
    background: #1c221b !important;
    border-radius: 4px !important;
    border: 1px solid #232a21 !important;
    font-size: 12px !important;
    font-weight: 650 !important;
  }
  #book-content td:not(:first-child):not(.book-actions)::before {
    content: attr(data-label) !important;
    font-size: 9.5px !important;
    font-weight: 750 !important;
    color: #839282 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.4px !important;
  }
  #book-content .book-actions {
    grid-column: 1 / -1 !important;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    margin-top: 6px !important;
    padding-top: 6px !important;
  }
  #book-content .book-actions button {
    min-height: 40px !important;
    font-size: 13px !important;
    font-weight: 750 !important;
    border-radius: 6px !important;
    width: 100% !important;
    transition: all 0.15s ease !important;
  }
  #book-content .book-actions button[data-action="edit"]:hover {
    background: #252d23 !important;
    border-color: var(--amber) !important;
    color: var(--amber) !important;
  }
  #book-content .book-actions button[data-action="execute"]:hover {
    background: rgba(143, 197, 135, 0.25) !important;
    border-color: var(--green) !important;
    color: #86efac !important;
  }
  #book-content .book-actions button[data-action="cancel"]:hover {
    background: rgba(224, 108, 117, 0.25) !important;
    border-color: var(--red) !important;
    color: #fca5a5 !important;
  }
  #book-content .book-actions button:active {
    transform: scale(0.95) !important;
  }

  /* Operations Console on Mobile */
  .operations:not(.collapsed) { height: min(50vh, 380px); }
  .operations:not(.collapsed) .operation-rows { height: calc(min(50vh, 380px) - 44px); }
  .operations > header {
    height: 44px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .operations nav { min-width: max-content; }
  .operations nav button {
    min-height: 44px;
    padding: 0 16px;
    font-size: 13px;
  }
  .operations header > button {
    min-height: 44px;
    min-width: 60px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 750;
  }
  .operation-row {
    grid-template-columns: 72px 55px 130px 1fr;
    padding: 8px 12px;
  }
  .operation-row span:nth-child(4), .operation-row span:nth-child(6) { display: none; }

  /* Settings Mobile Styles */
  .settings-page { width: min(100% - 24px, 980px); padding-top: 16px; }
  .settings-topbar { padding-inline: 14px; min-height: 52px; }
  .settings-grid, .connection-list { grid-template-columns: 1fr; }
  .settings-grid > label { padding: 12px 14px; border-right: 0; }
  .settings-grid input { min-height: 44px; font-size: 15px; }
  .switch-row { min-height: 54px; padding: 14px; }
  .switch-row input { width: 24px; min-height: 24px; }
  .employee-form { grid-template-columns: 1fr; gap: 12px; padding: 14px; }
  .employee-form input, .employee-form select { min-height: 44px; font-size: 15px; }
  .employee-form .primary { min-height: 44px; font-size: 15px; }
  body.ticket-open { overflow: hidden; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  .topbar {
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "brand settings order"
      "search search search"
      "nav nav nav";
    gap: 7px 8px;
    padding: 8px 10px;
  }
  .page-tabs {
    grid-template-columns: repeat(3, 1fr);
  }
  .page-tabs button {
    min-height: 38px;
    font-size: 13px;
    padding: 8px 6px;
  }
  .account-strip { grid-template-columns: 104px minmax(0, 1fr); min-height: 54px; }
  .account-total { padding-inline: 10px; }
  .account-total strong { font-size: 15px; }
  .account-list { grid-auto-columns: 175px; }
  .account { padding-inline: 10px; }
  .workspace { padding: 10px 10px calc(var(--operations-height) + 20px); }
  .market-head h1 { font-size: 17px; }
  .market-controls { gap: 6px; }
  .settlement-tabs button { min-height: 38px; padding: 6px 10px; font-size: 12px; }
  .venue-controls button { min-height: 38px; padding: 6px 10px; font-size: 11.5px; }
  .market-table { min-width: 780px; }
  .market-table th, .market-table td { padding: 9px 10px; }
  .chart-stack { margin-top: 12px; }
  .chart-toolbar { padding: 6px 8px; gap: 6px; }
  .chart-legend-hint { max-width: 100%; font-size: 10.5px; }
  .zoom-btn { min-height: 36px; min-width: 36px; padding: 4px 8px; font-size: 11.5px; }
  .plot-shell { height: 190px; }
  .chart-panel { margin-bottom: 12px; padding-bottom: 12px; }
  .chart-panel > header { margin-bottom: 6px; }
  .chart-panel header h2 { font-size: 13.5px; }
  .chart-panel header p { font-size: 10.5px; }
  .tooltip { min-width: 120px; font-size: 10.5px; }
  .book-toolbar { padding: 8px 10px; gap: 8px; }
  .book-toolbar label { flex: 1 1 100%; }
  .direction-tabs button { font-size: 14px; }
  .field-grid { gap: 8px; margin-bottom: 8px; }
  .field-grid label { font-size: 11.5px; }
  .field-grid input, .field-grid select, .static-field { min-height: 42px; font-size: 16px; }
  .arm { min-height: 48px; font-size: 15.5px; }
  .operations:not(.collapsed) { height: min(52vh, 360px); }
  .operations:not(.collapsed) .operation-rows { height: calc(min(52vh, 360px) - 44px); }
}

.operation-action { margin-left: 8px; padding: 2px 7px; border: 1px solid var(--line-strong); background: transparent; color: var(--amber); font: inherit; cursor: pointer; }
.operation-action:hover { background: rgba(228, 175, 66, .12); }
.danger-btn {
  color: var(--red) !important;
  border-color: rgba(239, 83, 80, 0.4) !important;
}
.danger-btn:hover {
  background: rgba(239, 83, 80, 0.15) !important;
}
