/* MOR Trading Desk v1.2 — soft dark · center focus · side rails · bottom row
   HAL · 260807 · trading-desk-v1.2
*/
:root {
  --bg: #151a23;
  --panel: #1c2430;
  --panel2: #222b38;
  --border: #2f3b4d;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --cyan: #38bdf8;
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --tile: #263041;
  --ok-bg: rgba(74, 222, 128, 0.12);
  --bad-bg: rgba(248, 113, 113, 0.12);
  --warn-bg: rgba(251, 191, 36, 0.12);
  --info-bg: rgba(56, 189, 248, 0.12);
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: Consolas, "Cascadia Mono", monospace;
  --center-min: 420px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ticker */
.top-strip {
  flex: 0 0 auto;
  height: 42px;
  overflow: hidden;
  background: #0f141c;
  border-bottom: 1px solid var(--border);
}
.ticker-host { height: 42px; overflow: hidden; }
.ticker-host .tradingview-widget-container,
.ticker-host iframe { height: 42px !important; }

/* toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 5px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { font-weight: 800; font-size: 13px; letter-spacing: .03em; }
.brand span { color: var(--cyan); font-weight: 700; font-size: 11px; margin-left: 4px; }
.stamp { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 700; }
label.ctl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}
select, button, input, textarea {
  font: inherit;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--tile);
  color: var(--text);
  padding: 5px 8px;
}
button {
  cursor: pointer;
  font-weight: 700;
  background: #2a3545;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: var(--panel2); }
button.ok { background: var(--ok-bg); color: var(--green); border-color: #166534; }
button.warn { background: var(--warn-bg); color: var(--amber); border-color: #854d0e; }
button.bad { background: var(--bad-bg); color: var(--red); border-color: #7f1d1d; }
button.cyan { background: var(--info-bg); color: var(--cyan); border-color: #075985; }
button.sm { padding: 4px 8px; font-size: 11px; }

body.chrome-hidden .toolbar,
body.chrome-hidden .midbar .tui { display: none; }
body.chrome-hidden .midbar { padding: 0; border: 0; }
body.chrome-hidden .live-feed { border-radius: 0; }
#btnChromeFloat {
  position: fixed;
  top: 48px;
  right: 10px;
  z-index: 50;
  display: none;
  box-shadow: var(--shadow);
}
body.chrome-hidden #btnChromeFloat { display: inline-block; }

/* midbar */
.midbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 1fr);
  gap: 8px;
  padding: 6px 10px;
  background: #18202b;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
@media (max-width: 900px) {
  .midbar { grid-template-columns: 1fr; }
}
.tui {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto auto;
  gap: 6px;
  align-items: center;
}
.tui input[type=text] {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 10px;
  background: var(--panel);
}
.queue-count {
  font-size: 11px;
  color: var(--amber);
  font-weight: 800;
  min-width: 24px;
  text-align: center;
}

.live-feed {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 38px;
  max-height: 64px;
}
.live-label {
  flex: 0 0 auto;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background: #0f141c;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  padding: 4px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.live-scroll {
  flex: 1;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
  padding: 4px 8px;
}
.live-scroll-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: feed-scroll 30s linear infinite;
}
.live-scroll:hover .live-scroll-inner { animation-play-state: paused; }
@keyframes feed-scroll {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}
.feed-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-line .t { color: var(--cyan); font-weight: 800; margin-right: 6px; }
.feed-line.up { color: var(--green); }
.feed-line.dn { color: var(--red); }

.toast {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f141c;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: 90vw;
}

/* ===== CENTER FOCUS STAGE ===== */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(200px, 22%) minmax(var(--center-min), 1fr) minmax(200px, 22%);
  grid-template-rows: 1fr minmax(140px, 28%);
  grid-template-areas:
    "left center right"
    "bottom bottom bottom";
  gap: 8px;
  padding: 8px 10px 6px;
  overflow: hidden;
}
.rail.left { grid-area: left; }
.rail.right { grid-area: right; }
.center { grid-area: center; }
.bottom-row { grid-area: bottom; }

.rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}
.bottom-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

/* cards */
.slot {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 0;
}
.rail .slot {
  flex: 1 1 0;
  min-height: 120px;
}
.center .slot {
  height: 100%;
  min-height: var(--center-min);
  border-color: #3d4f66;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12), var(--shadow);
}
.center .slot-head {
  background: linear-gradient(180deg, #263244, var(--panel2));
}
.center .slot-head h3 {
  color: var(--cyan);
  font-size: 12px;
}
.bottom-row .slot {
  min-height: 0;
  height: 100%;
}

.slot-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.slot-head h3 {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-head select {
  font-size: 10px;
  padding: 2px 4px;
  max-width: 130px;
}
.center .slot-head select { max-width: 200px; font-size: 11px; }
.slot-body {
  padding: 8px;
  overflow: auto;
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  min-height: 0;
}
.center .slot-body { padding: 10px; font-size: 13px; }

.card-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.sym-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--tile);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
}
.sym-chip.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--info-bg);
}
.dropdown-panel {
  background: #18202b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-top: 6px;
}
.dropdown-panel.hidden { display: none; }

.tv-widget-host {
  width: 100%;
  min-height: 160px;
  height: calc(100% - 40px);
  border-radius: 8px;
  overflow: hidden;
  background: #131722;
  flex: 1;
}
.center .tv-widget-host { min-height: 320px; height: calc(100% - 48px); }
.tv-widget-host iframe { width: 100% !important; height: 100% !important; border: 0; }
.widget-fill {
  width: 100%;
  height: 100%;
  min-height: 160px;
  border: 0;
  border-radius: 8px;
  background: #131722;
}

.gex-bar-row {
  display: grid;
  grid-template-columns: 48px 1fr 40px;
  gap: 5px;
  align-items: center;
  font-size: 10px;
  margin: 2px 0;
}
.gex-bar {
  height: 8px;
  border-radius: 4px;
  background: #2a3545;
  overflow: hidden;
}
.gex-bar > i { display: block; height: 100%; border-radius: 4px; }
.gex-pos { background: linear-gradient(90deg, #166534, var(--green)); }
.gex-neg { background: linear-gradient(90deg, var(--red), #7f1d1d); margin-left: auto; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #273142;
  font-size: 12px;
}
.row:last-child { border-bottom: none; }
.muted { color: var(--muted); font-weight: 500; }
.mono { font-family: var(--mono); font-size: 11px; }
.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--tile);
}
.pill.ok { color: var(--green); background: var(--ok-bg); border-color: #166534; }
.pill.bad { color: var(--red); background: var(--bad-bg); border-color: #7f1d1d; }
.pill.warn { color: var(--amber); background: var(--warn-bg); border-color: #854d0e; }
.pill.info { color: var(--cyan); background: var(--info-bg); border-color: #075985; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.dash-tile {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  text-align: center;
}
.dash-tile .k { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dash-tile .v { font-size: 14px; font-weight: 800; margin-top: 2px; font-family: var(--mono); }

table.mini { width: 100%; border-collapse: collapse; font-size: 11px; }
table.mini th, table.mini td { text-align: left; padding: 4px 3px; border-bottom: 1px solid #273142; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 9px; text-transform: uppercase; }
.up { color: var(--green); }
.dn { color: var(--red); }

.submit-item, .alert-item, .cat-item, .flow-item {
  background: var(--tile);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 5px;
  font-size: 11px;
}
.submit-item { cursor: pointer; }
.submit-item:hover, .flow-item:hover { border-color: var(--cyan); }
.submit-item .meta, .cat-item .meta, .flow-item .meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
}
.submit-item .title, .cat-item .title { font-weight: 700; }
.alert-item { border-left: 3px solid var(--amber); border-radius: 0 8px 8px 0; }
.alert-item .t { font-weight: 800; color: var(--amber); }
.flow-item { border-left: 3px solid var(--purple, #c084fc); border-radius: 0 8px 8px 0; }
.flow-item.call { border-left-color: var(--green); }
.flow-item.put { border-left-color: var(--red); }
.cat-item { border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0; }

.watch-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 5px 4px;
  border-bottom: 1px solid #273142;
  cursor: pointer;
}
.watch-row:hover { background: rgba(56, 189, 248, 0.06); }
.watch-row b { font-size: 12px; }

.key-ok { color: var(--green); }
.key-miss { color: var(--red); }

a { color: var(--cyan); }
code {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--tile);
  padding: 1px 4px;
  border-radius: 3px;
}
footer {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
  background: var(--panel);
}
pre.snip {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 10px;
  background: #18202b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  max-height: 100px;
  overflow: auto;
  color: var(--text);
  font-weight: 500;
}

.fin-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  height: calc(100% - 36px);
  min-height: 180px;
}
.fin-split iframe {
  width: 100%;
  height: 100%;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f141c;
}
.heat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.heat-cell-btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 4px;
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.heat-cell-btn span { font-family: var(--mono); font-size: 11px; }

@media (max-width: 1100px) {
  .stage {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "center center"
      "left right"
      "bottom bottom";
    overflow: auto;
  }
  .center .slot { min-height: 360px; }
  .rail { max-height: 420px; }
}
@media (max-width: 700px) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-areas:
      "center"
      "left"
      "right"
      "bottom";
  }
  .tui { grid-template-columns: 1fr 1fr 1fr; }
  .tui input { grid-column: 1 / -1; }
  .fin-split { grid-template-columns: 1fr; }
}
