:root {
  --bg: #0a0c0b;
  --panel: #111615;
  --border: #22302c;
  --blue-metal: #4a7c9b;
  --green-metal: #3d9b7a;
  --text: #f2f5f3;
  --muted: #7c8a86;
  --buy: #00c853;
  --sell: #d32f2f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 5px;
  color: var(--blue-metal);
  font-weight: 800;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  position: relative;
}

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.up { background: var(--buy); box-shadow: 0 0 8px var(--buy); }
.dot.down { background: var(--sell); box-shadow: 0 0 8px var(--sell); }
.dot.wait { background: var(--muted); }

.status.down #status-text { color: var(--sell); }
.status.up #status-text { color: var(--buy); }
.status.wait #status-text { color: var(--muted); }

.reason {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 2px solid var(--sell);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--muted);
  max-width: 560px;
  z-index: 10;
  line-height: 1.5;
  /* Solo informa: no tapa los clics en los botones M1/M5/M15 de debajo. */
  pointer-events: none;
}

.status.up .reason { display: none; }
.reason b { color: var(--text); }

.ticks { margin-left: auto; font-size: 11px; color: var(--muted); }

.quote {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.sym span { font-size: 18px; color: var(--blue-metal); font-weight: 700; letter-spacing: 1px; }
.price { font-size: 34px; font-weight: 800; }
.chg { font-size: 16px; }
.spr { margin-left: auto; font-size: 11px; color: var(--muted); }
.up { color: var(--buy); }
.down { color: var(--sell); }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1px;
  background: var(--border);
}

.panel { background: var(--panel); }
.chart-panel { position: relative; min-height: 460px; }
#chart { width: 100%; height: 100%; position: absolute; inset: 0; display: block; }

.side { padding: 14px; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.side h2 {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--blue-metal);
  text-transform: uppercase;
  margin: 4px 0 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
}

.signal { border: 1px solid var(--border); padding: 10px; margin-bottom: 16px; }
.signal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.signal-bias { font-size: 15px; font-weight: 800; letter-spacing: 1px; }
.signal.buy { border-left: 3px solid var(--buy); }
.signal.buy .signal-bias { color: var(--buy); }
.signal.sell { border-left: 3px solid var(--sell); }
.signal.sell .signal-bias { color: var(--sell); }
.signal-tf { font-size: 10px; color: var(--muted); }
.signal-score { margin-left: auto; font-size: 11px; color: var(--green-metal); }

.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-bottom: 10px; }
.levels label, .meter label { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; }
.levels b, .meter b { font-size: 12px; font-weight: 700; }
.buy-text { color: var(--buy); }
.sell-text { color: var(--sell); }

.factors { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.factors li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: var(--text);
  border-top: 1px solid rgba(74, 124, 155, 0.16);
  padding-top: 3px;
}
.factors li.nao { color: var(--muted); font-style: italic; }
.factors b { color: var(--green-metal); white-space: nowrap; }

.flat { padding: 10px; }
.flat-title { font-size: 14px; color: var(--muted); font-weight: 700; }
.flat-sub { font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.sin-dato { padding: 10px; font-size: 11px; color: var(--muted); }

.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }

footer {
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
}


.tabs {
  display: flex;
  gap: 1px;
  overflow-x: auto;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.tab {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tab b { color: var(--text); font-weight: 600; }
.tab.on { background: var(--bg); color: var(--blue-metal); box-shadow: inset 0 -2px 0 var(--blue-metal); }
.tab i { font-style: normal; font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.tab i.buy { color: var(--buy); }
.tab i.sell { color: var(--sell); }
.tab i.blocked { color: var(--muted); }

.m5 { display: flex; flex-direction: column; gap: 3px; font-size: 11px; margin-bottom: 14px; }
.m5 span { color: var(--muted); font-size: 10px; line-height: 1.5; }

.forecasts-panel { padding: 12px 18px; border-top: 1px solid var(--border); }
.forecasts-panel h2 {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--blue-metal);
  text-transform: uppercase;
  margin: 0 0 8px;
}
.forecasts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.forecasts li:not(.sin-dato) {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11px;
  padding: 5px 8px;
  border-left: 3px solid var(--border);
  background: var(--bg);
}
.forecasts li.buy { border-left-color: var(--buy); }
.forecasts li.buy b { color: var(--buy); }
.forecasts li.sell { border-left-color: var(--sell); }
.forecasts li.sell b { color: var(--sell); }
.forecasts time { color: var(--muted); }
.aviso { font-size: 10px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.source { color: var(--blue-metal); margin-bottom: 4px; }

@media (max-width: 760px) {
  header { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .quote { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .price { font-size: 26px; }
  main { grid-template-columns: 1fr; }
  .chart-panel { min-height: 300px; }
  .forecasts-panel, footer { padding-left: 16px; padding-right: 16px; }
  .reason { left: 0; max-width: calc(100vw - 32px); }
}

.signal.blocked { border-left: 3px solid var(--muted); }
.signal.blocked .signal-bias { color: var(--muted); }
.guard { margin: 8px 0 10px; font-size: 10px; line-height: 1.5; }
.guard-title { font-weight: 800; letter-spacing: 1px; margin-bottom: 3px; }
.guard.no .guard-title { color: var(--sell); }
.guard.si .guard-title { color: var(--buy); }
.guard ul { list-style: none; margin: 0; padding: 0; }
.guard li.ok b { color: var(--buy); }
.guard li.ko { color: var(--text); }
.guard li.ko b { color: var(--sell); }
.guard-status { font-size: 10px; color: var(--muted); margin: -8px 0 14px; }

.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; margin-bottom: 16px; }
.calc label { display: flex; flex-direction: column; gap: 3px; font-size: 9px; color: var(--muted); text-transform: uppercase; }
.calc .wide { grid-column: 1 / -1; }
.calc input, .calc select, .calc button {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 8px;
  min-width: 0;
  width: 100%;
}
.calc button { cursor: pointer; color: var(--blue-metal); text-transform: none; }
.calc button:hover { border-color: var(--blue-metal); }
.calc .origin { font-size: 9px; color: var(--muted); line-height: 1.4; }
.calc output { display: flex; flex-direction: column; gap: 4px; font-size: 11px; line-height: 1.5; }
.calc .lot b { font-size: 16px; }
.calc .lot.ok b { color: var(--buy); }
.calc .lot.ko b, .calc .ko { color: var(--sell); }

.forecasts li.blocked { border-left-color: var(--muted); color: var(--muted); }
.forecasts li.blocked b { color: var(--muted); }
.forecasts .why { flex-basis: 100%; font-size: 10px; }
.calc .hint { color: var(--muted); font-size: 10px; }

.alerts {
  font: inherit;
  font-size: 11px;
  color: var(--blue-metal);
  background: transparent;
  border: 1px solid var(--blue-metal);
  padding: 4px 10px;
  cursor: pointer;
  margin-left: auto;
}
.alerts.on { color: var(--bg); background: var(--buy); border-color: var(--buy); font-weight: 700; }
.alerts + .ticks { margin-left: 0; }

.frame { border: 1px solid var(--border); padding: 10px; margin-bottom: 10px; }
.frame.flat { padding: 10px; }
.frame-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.frame-head b { font-size: 13px; color: var(--blue-metal); }
.frame-head .tf-on { font-size: 9px; font-weight: 800; letter-spacing: 1px; color: var(--buy); }
.frame-head .tf-off { font-size: 9px; font-weight: 800; letter-spacing: 1px; color: var(--sell); }
.frame-measure { font-size: 9px; color: var(--muted); line-height: 1.4; margin-bottom: 8px; }
.flat-when { font-size: 9px; font-weight: 400; margin-left: 6px; }
.conds { list-style: none; margin: 6px 0 0; padding: 0; font-size: 10px; line-height: 1.5; }
.conds li.ok b { color: var(--buy); }
.conds li.ko { color: var(--muted); }
.conds li.ko b { color: var(--sell); }

.alerts.mute { color: var(--bg); background: #f5a623; border-color: #f5a623; font-weight: 700; animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { to { opacity: 0.45; } }

/* Aviso central de señal: imposible de no ver. */
.alert-center {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.alert-center[hidden], .alert-pause[hidden], .toast[hidden] { display: none; }
.ac-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 3px solid var(--border);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.alert-center.buy .ac-card { border-color: var(--buy); animation: glow-buy 1.4s ease-in-out infinite; }
.alert-center.sell .ac-card { border-color: var(--sell); animation: glow-sell 1.4s ease-in-out infinite; }
.alert-center.expired .ac-card { border-color: var(--muted); }
@keyframes glow-buy { 50% { box-shadow: 0 0 40px var(--buy); } }
@keyframes glow-sell { 50% { box-shadow: 0 0 40px var(--sell); } }
@media (prefers-reduced-motion: reduce) {
  .alert-center .ac-card, .alerts.mute { animation: none; }
}
.ac-count { font-size: 11px; letter-spacing: 3px; color: var(--muted); }
.ac-action { font-size: 54px; font-weight: 900; letter-spacing: 6px; line-height: 1; }
.alert-center.buy .ac-action { color: var(--buy); }
.alert-center.sell .ac-action { color: var(--sell); }
.alert-center.expired .ac-action { color: var(--muted); text-decoration: line-through; }
.ac-symbol { font-size: 28px; font-weight: 800; color: var(--text); }
.ac-symbol span { font-size: 16px; color: var(--blue-metal); margin-left: 6px; }
.ac-levels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; background: var(--bg); padding: 10px; }
.ac-levels label { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; }
.ac-levels b { font-size: 15px; }
.ac-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.ac-time { font-size: 12px; color: var(--text); }
.ac-time.ko { color: var(--sell); font-weight: 800; letter-spacing: 1px; }
.ac-buttons { display: flex; gap: 10px; }
.ac-buttons button, .ac-rest button {
  font: inherit;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.ac-buttons button { flex: 1; padding: 12px; font-size: 14px; }
.ac-buttons button.primary { background: var(--blue-metal); border-color: var(--blue-metal); font-weight: 800; }
.ac-rest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.ac-rest button { padding: 4px 8px; font-size: 11px; font-weight: 700; }
.ac-rest button.buy { color: var(--buy); border-color: var(--buy); }
.ac-rest button.sell { color: var(--sell); border-color: var(--sell); }
.ac-rest button.expired { color: var(--muted); text-decoration: line-through; }

.alert-pause {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  background: #f5a623;
  color: var(--bg);
  font-size: 12px;
  text-align: center;
}
.alert-pause b { font-size: 18px; letter-spacing: 1px; }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  font-size: 12px;
  background: var(--panel);
  border: 1px solid var(--buy);
  color: var(--text);
}
.toast.ko { border-color: var(--sell); }

@media (max-width: 760px) {
  .ac-action { font-size: 40px; }
  .ac-symbol { font-size: 22px; }
  .ac-levels { grid-template-columns: 1fr 1fr; }
}

/* --- Cabina sin scroll (2026-10-23) ------------------------------------------
   En el ordenador todo cabe en la pantalla: barra, radar de activos, gráfico con
   la última vela siempre a la vista, columna de señales con scroll propio e
   historial en una franja baja. En el móvil se mantiene el scroll vertical. */
header, .tabs, .quote, .forecasts-panel, footer { flex-shrink: 0; }
main { min-height: 0; grid-template-rows: minmax(0, 1fr); }
.side { min-height: 0; }

@media (min-width: 761px) {
  body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  .chart-panel { min-height: 0; }
  footer { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 4px 18px; }
  footer .source { display: inline; margin: 0 12px 0 0; }
}

.quote { padding: 8px 18px; align-items: center; }
.price { font-size: 28px; }

.tf-buttons { display: flex; gap: 4px; margin-left: 10px; }
.tf-buttons button {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
}
.tf-buttons button:hover { color: var(--text); border-color: var(--blue-metal); }
.tf-buttons button.on { color: var(--bg); background: var(--blue-metal); border-color: var(--blue-metal); }

/* Tarjetas M5 / M1 / M15 compactas: una línea; el detalle con un clic. */
.frame { padding: 7px 9px; margin-bottom: 6px; }
.frame summary { list-style: none; cursor: pointer; }
.frame summary::-webkit-details-marker { display: none; }
.frame-line { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 11px; }
.frame-line .tf-name { font-size: 13px; color: var(--blue-metal); }
.frame-line .tf-on, .frame-line .tf-off { font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.frame-line .tf-on { color: var(--buy); }
.frame-line .tf-off { color: var(--sell); }
.frame-line .flat-title { font-size: 11px; }
.frame-line .flat-trend { font-size: 10px; }
.frame-line .signal-bias { font-size: 14px; }
.dots { margin-left: auto; font-size: 10px; letter-spacing: 1px; white-space: nowrap; }
.dots i { font-style: normal; }
.dots i.ok { color: var(--buy); }
.dots i.ko { color: var(--sell); }
.frame-line::after { content: "▸"; color: var(--muted); font-size: 10px; }
.frame[open] .frame-line::after { content: "▾"; }
.frame .levels { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 6px 0 0; }
.frame[open] > :not(summary) { margin-top: 6px; }
.frame .frame-measure { margin-bottom: 0; }
.frame .conds { margin-top: 4px; }

/* Calculadora plegable: se abre sola al llegar una señal. */
.calc-box > summary { list-style: none; cursor: pointer; }
.calc-box > summary::-webkit-details-marker { display: none; }
.calc-box > summary h2::after { content: " ▸"; }
.calc-box[open] > summary h2::after { content: " ▾"; }
.calc-box[open] > summary { margin-bottom: 8px; }

/* Historial en franja horizontal con scroll propio; clic = abrir el activo. */
.forecasts-panel { padding: 6px 18px 8px; }
.forecasts-panel h2 { margin: 0 0 6px; }
.forecasts-panel h2 .aviso { display: inline; margin: 0 0 0 10px; letter-spacing: 0; text-transform: none; font-size: 9px; }
.forecasts { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
.forecasts li:not(.sin-dato) {
  flex: 0 0 auto;
  max-width: 300px;
  gap: 2px 10px;
  cursor: pointer;
}
.forecasts li:not(.sin-dato):hover { background: var(--panel); outline: 1px solid var(--border); }
.forecasts li.sin-dato { padding: 4px 0; font-size: 10px; }
.forecasts .why { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 760px) {
  .tf-buttons { margin-left: 0; }
  .frame .levels { grid-template-columns: 1fr 1fr; }
  .forecasts-panel h2 .aviso { display: block; margin: 4px 0 0; }
}

/* --- Diario de operaciones (panel lateral) --------------------------------------- */
.diario-btn {
  font: inherit;
  font-size: 11px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 10px;
  cursor: pointer;
  margin-left: auto;
}
.diario-btn:hover { border-color: var(--blue-metal); }
.diario-btn.on { border-color: var(--buy); color: var(--buy); font-weight: 700; }
.diario-btn + .alerts { margin-left: 0; }

.diario { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.5); display: flex; justify-content: flex-end; }
.diario[hidden] { display: none; }
.dj-panel {
  width: min(620px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.dj-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.dj-head > b { margin-right: auto; }
.dj-user { font-size: 10px; color: var(--muted); }
.dj-close { font: inherit; background: none; border: none; color: var(--text); font-size: 16px; cursor: pointer; }
.dj-body { overflow-y: auto; padding: 0 16px 24px; }
.dj-section { border-bottom: 1px solid var(--border); padding: 12px 0; font-size: 11px; }
.dj-section h3 { font-size: 10px; letter-spacing: 2px; color: var(--blue-metal); text-transform: uppercase; margin: 0 0 8px; }
.dj-section p { margin: 4px 0; line-height: 1.5; }
.tag { font-size: 9px; letter-spacing: 1px; color: var(--muted); font-weight: 400; text-transform: none; margin-left: 6px; }
.muted { color: var(--muted); }
.ko { color: var(--sell); }
.diario button {
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 10px;
}
.diario button.primary { background: var(--blue-metal); border-color: var(--blue-metal); font-weight: 800; }
.diario button.danger { color: var(--sell); }
.diario button.link { background: none; border: none; padding: 0; color: var(--blue-metal); text-decoration: underline; }
.diario button.dj-close { border: none; background: none; }
.dj-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.dj-form h3 { grid-column: 1 / -1; }
.dj-form .wide { grid-column: 1 / -1; }
.diario label { display: flex; flex-direction: column; gap: 3px; font-size: 9px; color: var(--muted); text-transform: uppercase; }
.diario label.check { flex-direction: row; align-items: center; text-transform: none; font-size: 11px; color: var(--text); }
.diario input, .diario select {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 8px;
  min-width: 0;
  width: 100%;
}
.diario label.check input { width: auto; }
.dj-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dj-op { border: 1px solid var(--border); border-left: 3px solid var(--border); padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px; }
.dj-op.buy { border-left-color: var(--buy); }
.dj-op.buy b { color: var(--buy); }
.dj-op.sell { border-left-color: var(--sell); }
.dj-op.sell b { color: var(--sell); }
.dj-op-line { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.dj-op-line time { margin-left: auto; color: var(--muted); font-size: 10px; }
.dj-close-row { display: grid; grid-template-columns: 1fr 1fr auto auto auto; gap: 8px; align-items: end; }
.dj-stats { width: 100%; border-collapse: collapse; font-size: 11px; }
.dj-stats th { font-size: 9px; color: var(--muted); font-weight: 400; text-align: right; padding: 3px 4px; }
.dj-stats td { text-align: right; padding: 4px; border-top: 1px solid var(--border); }
.dj-stats td:first-child, .dj-stats th:first-child { text-align: left; }
.dj-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dj-history li { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 5px 8px; border-left: 3px solid var(--border); background: var(--bg); }
.dj-history li.buy { border-left-color: var(--buy); }
.dj-history li.sell { border-left-color: var(--sell); }
.dj-history time { color: var(--muted); }

@media (max-width: 760px) {
  .dj-form { grid-template-columns: 1fr 1fr; }
  .dj-close-row { grid-template-columns: 1fr 1fr; }
}

.ac-timing { font-size: 10px; color: var(--muted); line-height: 1.5; }
.forecasts .muted { color: var(--muted); }

/* --- Libro de ordenes y operaciones pactadas en tiempo real ------------------- */
.book-btn {
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  margin-left: 6px;
}
.book-btn:hover { color: var(--text); border-color: var(--blue-metal); }
.book-btn.on { color: var(--bg); background: var(--blue-metal); border-color: var(--blue-metal); }

@media (min-width: 761px) {
  main.with-book { grid-template-columns: minmax(0, 1fr) 252px 330px; }
}

.ob-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.ob-panel[hidden] { display: none; }
.ob-panel.stale .ob-book,
.ob-panel.stale .ob-trades { opacity: 0.45; }

.ob-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  flex-shrink: 0;
}
.ob-title {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--blue-metal);
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.ob-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ob-dot.up { background: var(--buy); box-shadow: 0 0 6px var(--buy); }
.ob-dot.down { background: var(--sell); }
.ob-dot.wait { background: var(--muted); }
.ob-lat {
  color: var(--muted);
  font-size: 9px;
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ob-unit,
.ob-close {
  font: inherit;
  font-size: 9px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 5px;
  cursor: pointer;
  flex-shrink: 0;
}
.ob-unit:hover,
.ob-close:hover { color: var(--text); border-color: var(--blue-metal); }
.ob-close { font-size: 12px; line-height: 1; padding: 1px 5px; }

.ob-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.ob-tabs button {
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 5px 4px;
  cursor: pointer;
}
.ob-tabs button:hover { color: var(--text); }
.ob-tabs button.on { color: var(--text); border-bottom-color: var(--blue-metal); background: var(--panel); }

.ob-empty {
  padding: 18px 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.ob-book {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}
.ob-panel[data-view="both"] .ob-book { flex: 0 0 auto; }

.ob-cols,
.ob-t-head {
  display: grid;
  grid-template-columns: 1fr 0.85fr 0.85fr;
  padding: 4px 8px;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ob-cols span:not(:first-child),
.ob-t-head span:not(:first-child) { text-align: right; }

.ob-asks,
.ob-bids {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.ob-panel[data-view="book"] .ob-asks,
.ob-panel[data-view="book"] .ob-bids {
  flex: 1 1 0;
}
.ob-asks { justify-content: flex-end; }
.ob-bids { justify-content: flex-start; }

.ob-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 0.85fr 0.85fr;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.35;
  height: 19px;
}
.ob-row[hidden] { display: none; }
.ob-row .ob-bar {
  position: absolute;
  inset: 0;
  transform-origin: right center;
  transform: scaleX(0);
  pointer-events: none;
  will-change: transform;
}
.ob-row.ask .ob-bar { background: rgba(211, 47, 47, 0.2); }
.ob-row.bid .ob-bar { background: rgba(0, 200, 83, 0.18); }
.ob-row span { position: relative; z-index: 1; white-space: nowrap; }
.ob-row .ob-px { font-weight: 700; }
.ob-row.ask .ob-px { color: #ff6b6b; }
.ob-row.bid .ob-px { color: var(--buy); }
.ob-row .ob-sz { text-align: right; color: var(--text); }
.ob-row .ob-tot { text-align: right; color: var(--muted); }

.ob-mid {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.ob-spread {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
}
.ob-spread b { color: var(--text); font-size: 11px; }
.ob-spread .ob-sp-pct { margin-left: auto; font-size: 9px; }

.ob-imb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 700;
}
.ob-imb-b { color: var(--buy); min-width: 26px; }
.ob-imb-s { color: #ff6b6b; min-width: 26px; text-align: right; }
.ob-imb-track {
  position: relative;
  flex: 1;
  height: 4px;
  background: rgba(211, 47, 47, 0.55);
  overflow: hidden;
}
.ob-imb-fill {
  position: absolute;
  inset: 0;
  background: var(--buy);
  transform-origin: left center;
  transform: scaleX(0.5);
  will-change: transform;
}

.ob-trades {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
  border-top: 1px solid var(--border);
}
.ob-panel[data-view="trades"] .ob-trades { border-top: 0; }
.ob-t-head { grid-template-columns: 1fr 0.75fr 0.85fr; background: var(--bg); }
.ob-t-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.ob-t-row {
  display: grid;
  grid-template-columns: 1fr 0.75fr 0.85fr;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.35;
  height: 19px;
}
.ob-t-row[hidden] { display: none; }
.ob-t-row.buy .ob-t-px { color: var(--buy); font-weight: 700; }
.ob-t-row.sell .ob-t-px { color: #ff6b6b; font-weight: 700; }
.ob-t-row .ob-t-qty { text-align: right; color: var(--text); }
.ob-t-row .ob-t-tm { text-align: right; color: var(--muted); font-size: 10px; }
.ob-t-row.buy.big { background: rgba(0, 200, 83, 0.16); }
.ob-t-row.sell.big { background: rgba(211, 47, 47, 0.2); }
.ob-t-row.big .ob-t-qty { font-weight: 800; }

@media (max-width: 760px) {
  .book-btn { margin-left: 0; }
  .ob-panel { max-height: 460px; border-top: 1px solid var(--border); }
}
