/* =========================================================================
 * base.css — tokens, reset, layout primitives and responsive rules only.
 * The terminal-specific look lives in terminal.css.
 * ========================================================================= */

:root {
  /* light theme base */
  --bg: #07090b;
  --bg-panel: #0d1116;
  --bg-panel2: #121820;
  --bg-input: #0a0e12;
  --line: #1d252f;
  --txt: #cfdae5;
  --dim: #6d7c8b;
  --amber: #ffa62b;
  --green: #21d07a;
  --red: #ff4d5e;
  --blue: #4ea1ff;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--txt);
  outline: none;
}

button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.dim { color: var(--dim); }
.small { font-size: 11px; }
.muted { color: var(--dim); }
.muted small, .muted kbd { color: var(--dim); }
.strong { font-weight: 700; }
.center { text-align: center; }

/* ---------- layout primitives ---------- */

.spacer { flex: 1; }

.hidden { display: none !important; }
[hidden] { display: none !important; }
.is-hidden { display: none !important; }

/* ---------- buttons ---------- */

.btn {
  background: #22303d;
  border: 1px solid #2f4354;
  color: #dbe8f4;
  border-radius: 2px;
  padding: 5px 11px;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn--primary { background: var(--green); border-color: var(--green); color: #06110a; }
.btn--primary:hover { background: #2ec48a; }
.btn--danger { background: var(--red); border-color: var(--red); color: #1c0a0d; }
.btn--danger:hover { background: #ff6274; }
.btn--ghost { background: transparent; color: var(--dim); }
.btn--ghost:hover { color: var(--txt); border-color: var(--line); }
.btn--sm { padding: 3px 8px; font-size: 10.5px; }
.btn--block { width: 100%; }
.btn--sm .btn { padding: 3px 8px; }

/* ---------- inputs ---------- */

.input {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 5px 7px;
  width: 100%;
}
.input:focus { border-color: var(--amber); }
.input--search { width: 100%; }
.input--compact { width: 84px; }

textarea { resize: vertical; }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 2px; }
.tab {
  background: transparent;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 2px;
  padding: 5px 8px;
  color: var(--dim);
  cursor: pointer;
  position: relative;
}
.tab:hover { color: var(--txt); border-color: var(--line); }
.tab.is-active { color: var(--amber); }

/* ---------- chips / pills ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-panel2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 6px;
  color: var(--dim);
}
.chip--indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.chip--indicator .chip__label { color: var(--txt); cursor: pointer; }
.chip--indicator .chip__x {
  border-radius: 50%;
  color: var(--dim);
  line-height: 1;
}
.chip--indicator .chip__x:hover { color: var(--red); }
.chip--empty { color: var(--dim); }
.chip__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }

.pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill--plan { background: rgba(255, 166, 43, 0.15); color: var(--amber); border: 1px solid rgba(255, 166, 43, 0.35); }
.pill--core { background: rgba(33, 208, 122, 0.12); color: var(--green); border: 1px solid rgba(33, 208, 122, 0.35); }
.pill--lock { background: rgba(255, 77, 94, 0.12); color: var(--red); border: 1px solid rgba(255, 77, 94, 0.35); }
.pill--admin { background: rgba(78, 161, 255, 0.14); color: var(--blue); border: 1px solid rgba(78, 161, 255, 0.35); }

/* ---------- gate ---------- */

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  background: rgba(8, 11, 14, 0.85);
  backdrop-filter: blur(6px);
  z-index: 50;
}
.gate.is-hidden { display: none; }
.gate__card {
  width: min(360px, 100%);
  max-height: calc(100dvh - 64px);
  overflow-y: auto;
  margin: auto 0;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 22px 24px;
}
.gate__head { margin-bottom: 14px; }
.gate__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1b2530, #2a3540);
  color: var(--amber);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}
.gate__title { margin: 0; font-size: 18px; letter-spacing: 0.06em; }
.gate__note { margin: 0 0 14px; font-size: 12px; line-height: 1.5; color: var(--dim); }
.gate__setup { margin-top: 14px; text-align: center; font-size: 12px; color: var(--dim); }
.gate__link { color: var(--green); font-weight: 600; }
.gate__code, .gate__code kbd {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
  font-size: 11px;
}
.gate__actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.gate__error { color: var(--red); font-size: 11px; margin-bottom: 10px; display: none; }
.gate__error.is-visible { display: block; }

/* ---------- dialogs / popovers ---------- */

.modal {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: var(--bg-panel);
  color: var(--txt);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}
.modal::backdrop { background: rgba(6, 9, 12, 0.6); }
.modal__panel {
  width: 640px;
  max-width: calc(100vw - 32px);
}
.modal__panel--wide { width: min(960px, calc(100vw - 32px)); }
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.modal__title { margin: 0; font-size: 16px; letter-spacing: 0.04em; }
.modal__sub { margin: 4px 0 0; font-size: 12px; color: var(--dim); }
.modal__body { padding: 14px 18px 18px; }
.modal__foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.modal__text { margin: 6px 0; }
.modal--picker { max-width: 760px; }
.modal--settings { max-width: 720px; }

/* ---------- settings dialog ---------- */

.settings {
  display: flex;
  flex-direction: column;
}
.settings__nav {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 0 6px;
}
.settings__nav-item {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  color: var(--dim);
  padding: 6px 8px;
  cursor: pointer;
  text-align: center;
}
.settings__nav-item:hover { color: var(--txt); border-color: var(--line); }
.settings__nav-item.is-active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}
.settings__pane { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 14px 16px; gap: 12px; overflow-y: auto; }
.settings__section {
  margin: 8px 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.settings__section:first-child { border-top: none; }
.settings__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
}
.settings__row--check { flex-direction: row; align-items: center; gap: 8px; }
.settings__row-label { flex: 1; }
.settings__row-hint { color: var(--dim); font-size: 10.5px; }
.settings__candle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings__candle-row .settings__row { flex-direction: column; align-items: flex-start; gap: 6px; }
.settings__candle-row .settings__row-label { flex: none; }
.color-input {
  width: 26px;
  height: 26px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #000;
  cursor: pointer;
}
.settings__note {
  margin: 4px 0;
  color: var(--dim);
  font-size: 10.5px;
}

/* ---------- interval menu ---------- */

.interval-menu {
  width: min(320px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
}
.interval-menu__custom {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--dim);
  text-align: left;
}
.interval-menu__custom:hover { border-color: var(--amber); }
.interval-menu__plus { color: var(--amber); font-weight: 700; }
.interval-menu__form {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.interval-menu__form .input { flex: 1; }
.interval-menu__group { margin-top: 10px; }
.interval-menu__title {
  margin: 8px 0 2px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.interval-menu__note {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: var(--dim);
}
.interval-menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--txt);
  text-align: left;
}
.interval-menu__item:hover { border-color: var(--line); background: var(--bg-panel2); }
.interval-menu__item.is-active { background: #132a22; border-color: var(--green); color: var(--green); }
.interval-menu__item.is-locked { color: var(--dim); }
.interval-menu__item.is-locked:hover { border-color: var(--line); background: transparent; }
.interval-menu__check { color: var(--green); }
.interval-menu__plus, .interval-menu__item .badge { flex-shrink: 0; }

/* ---------- indicator picker ---------- */

.picker { display: flex; min-height: 0; }
.picker__main {
  display: flex;
  flex-direction: column;
  width: 340px;
}
.picker__main .search {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
}
.picker__main .search__input { flex: 1; }
.picker__main .search__icon { color: var(--dim); font-weight: 700; }
.picker__content { display: flex; flex: 1; min-height: 0; }
.picker__side {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  min-width: 150px;
  overflow-y: auto;
}
.picker__group { margin-top: 6px; }
.picker__group-title {
  margin: 8px 6px 2px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.picker__cat {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--dim);
  text-align: left;
  text-transform: capitalize;
}
.picker__cat:hover { border-color: var(--amber); color: var(--txt); }
.picker__cat--active { background: #132a22; border-color: var(--green); color: var(--green); }
.picker__cat-icon { font-family: monospace; font-weight: 700; }
.picker__cat-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker__remove {
  border: none;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  line-height: 1;
  padding: 2px 4px;
}
.picker__remove:hover { color: var(--red); }
.picker__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  text-align: left;
}
.picker__row:hover { border-color: var(--amber); }
.picker__row.is-active { background: #132a22; border-color: var(--green); }
.picker__row.is-locked { opacity: 0.55; }
.picker__row-main { display: flex; flex-direction: column; gap: 2px; }
.picker__name { font-weight: 600; letter-spacing: 0.03em; }
.picker__cat-label { font-size: 10.5px; color: var(--dim); }
.picker__added { font-size: 10px; color: var(--green); }
.picker__row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.picker__row-end .btn { font-size: 10.5px; padding: 3px 8px; }
.picker__empty { color: var(--dim); font-size: 11px; padding: 8px 0; }
.picker__counter { font-size: 10.5px; color: var(--dim); }

/* ---------- modal inner typography ---------- */

.modal__panel { font-size: 13px; }
.modal__head { margin-bottom: 12px; }
.modal__foot { border-top: 1px solid var(--line); }
.modal__text { line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field__label { font-size: 11px; color: var(--dim); letter-spacing: 0.04em; }
.input, select, textarea { width: 100%; }

/* ---------- popover common ---------- */

.popover {
  position: fixed;
  z-index: 60;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

/* ---------- progress ---------- */

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 11px;
  background: #0a0e12;
  pointer-events: none;
}
.chart-loading.is-visible { display: flex; }

/* ---------- workspace ---------- */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr 300px;
  grid-template-rows: 1fr;
  min-width: 0;
}

.rail, .side, .stage, .dock { overflow: hidden; }

/* ---------- rail ---------- */

.rail {
  border-right: 1px solid var(--line);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rail-head { padding: 8px; border-bottom: 1px solid var(--line); }
.rail-head input { width: 100%; }
.class-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
.class-tab {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 3px 7px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.class-tab:hover { border-color: var(--line); }
.class-tab.is-active { background: #132a22; border-color: var(--amber); color: var(--amber); }
.sym-list { overflow-y: auto; flex: 1; min-height: 0; }
.symrow {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: transparent;
  color: var(--txt);
  border: 0;
  border-bottom: 1px solid #141a21;
  text-align: left;
  cursor: pointer;
}
.symrow:hover { background: var(--bg-panel2); }
.symrow.is-active { background: #1b2530; border-left: 2px solid var(--amber); }
.symrow__sym { font-weight: 700; font-size: 12px; letter-spacing: 0.03em; }
.symrow__name { font-size: 10px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.symrow__price { font-size: 11px; font-weight: 700; }
.symrow__change { font-size: 10px; font-weight: 700; }
.symrow__change.is-up { color: var(--green); }
.symrow__change.is-dn { color: var(--red); }
.rail__empty { color: var(--dim); text-align: center; padding: 12px; font-size: 11px; }

/* ---------- stage ---------- */

.stage {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #080b0e;
}
.viewtabs {
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: stretch;
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 0 6px;
}
.vtab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dim);
  padding: 0 10px;
  letter-spacing: 0.08em;
  font-size: 10.5px;
  text-transform: uppercase;
}
.vtab.is-active { color: var(--amber); border-bottom-color: var(--amber); }
.vtab:hover { color: var(--txt); }
.spacer { flex: 1; }
.hint { color: var(--dim); font-size: 10px; align-self: center; padding-right: 6px; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view.is-hidden { display: none; }

.chart-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #0a0e12;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.chart-head::-webkit-scrollbar { display: none; }
.chsym { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; color: #eaf3fb; flex-shrink: 0; }
.chpx { display: flex; align-items: baseline; gap: 8px; font-size: 16px; font-weight: 600; flex-shrink: 0; }
.chpx .is-up { color: var(--green); }
.chpx .is-dn { color: var(--red); }
.chohlc { margin-left: auto; display: flex; gap: 10px; font-size: 10.5px; color: var(--dim); flex-wrap: nowrap; align-items: center; flex-shrink: 0; }
.chohlc .stat { display: flex; flex-direction: row; align-items: baseline; gap: 4px; white-space: nowrap; }
.chohlc .stat__key { font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.chohlc .stat__val { font-size: 11px; }

.chart-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
}
.group { display: flex; gap: 2px; align-items: center; }
.group + .group { padding-left: 12px; border-left: 1px solid var(--line); }
.tb {
  background: var(--bg-panel2);
  border: 1px solid var(--line);
  color: var(--dim);
  min-width: 26px;
  height: 20px;
  padding: 0 6px;
  border-radius: 2px;
  font-size: 10.5px;
}
.tb:hover { color: var(--txt); border-color: var(--line); }
.tb.is-active { background: #2a2113; border-color: var(--amber); color: var(--amber); }
.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  height: 20px;
  padding: 0 7px;
  border-radius: 2px;
  font-size: 10.5px;
}
.chip:hover { color: var(--txt); }
.chip.is-active { background: #132a22; border-color: var(--green); color: var(--green); }

.chart-wrap { position: relative; flex: 1; min-height: 0; }
#chartHost { position: relative; width: 100%; display: block; }

/* ---------- heatmap ---------- */

.heat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px;
  padding: 8px;
  align-content: start;
}
.tile {
  border: 1px solid #0b0f13;
  border-radius: 3px;
  padding: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 56px;
}
.tile:hover { outline: 1px solid var(--amber); }
.tile__sym { font-weight: 700; letter-spacing: 0.05em; font-size: 11.5px; }
.tile__chg { font-size: 13px; font-weight: 700; text-align: right; }
.tile__chg.is-up { color: var(--green); }
.tile__chg.is-dn { color: var(--red); }
.tile__meta { font-size: 10px; color: var(--dim); }

/* ---------- monitor table ---------- */

#monitorView { min-height: 0; overflow: hidden; }
.table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mon--wide { font-size: 11.5px; }
.mon--wide th { font-size: 10px; }
.mon--wide td { font-size: 11px; }

/* ---------- side rail ---------- */

.side {
  border-left: 1px solid var(--line);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel {
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 9px;
  background: #0c1116;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.panel-head .dim { text-transform: none; letter-spacing: 0.04em; }
.wl-list { display: flex; flex-direction: column; }
.wl__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-bottom: 1px solid #12181f;
}
.wl__row:hover { background: var(--bg-panel2); }
.wl__row.is-active { background: #1b2530; }
.wl__sym { font-weight: 700; }
.wl__price { font-size: 11px; }
.wl__change { font-size: 10px; font-weight: 700; }
.wl__change.is-up { color: var(--green); }
.wl__change.is-dn { color: var(--red); }

.quote-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quote-head { display: flex; justify-content: space-between; gap: 10px; }
.quote-sym { font-size: 14px; font-weight: 700; letter-spacing: 0.04em; }
.quote-name { font-size: 10px; color: var(--dim); }
.quote-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.quote-badge.is-up { color: var(--green); background: rgba(33, 208, 122, 0.15); }
.quote-badge.is-dn { color: var(--red); background: rgba(255, 77, 94, 0.15); }
.quote-price { font-size: 22px; font-weight: 700; letter-spacing: 0.04em; }
.kv { display: grid; grid-template-columns: auto 1fr; row-gap: 3px; column-gap: 10px; font-size: 11px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; text-align: right; }
.ticket { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; padding: 8px 9px 10px; }
.ticket input { font-size: 12px; }
.acct { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 9px; }
.acct div span { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.acct b { display: block; font-size: 13px; color: #eaf3fb; margin-top: 1px; }

.tabbed-scroll { display: flex; flex-direction: column; gap: 8px; }
.tab-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.tab-pane + .tab-pane { border-top: 1px solid var(--line); padding-top: 6px; }
.tabbed-scroll .panel-head { font-size: 10px; }
.book {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.book__row {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.75fr);
  gap: 6px;
  padding: 2px 6px;
  font-size: 10.5px;
  overflow: hidden;
}
.book__row > span,
.tape__row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tape { display: flex; flex-direction: column; gap: 2px; }
.tape__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 6px; padding: 1px 6px; font-size: 10.5px; overflow: hidden; }
.news__item {
  padding: 6px 9px;
  border-bottom: 1px solid #12181f;
}
.news__head { font-size: 11.5px; line-height: 1.4; color: #c3d1de; margin: 3px 0 2px; }
.news__meta { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--dim); }
.news__src { color: var(--amber); }
.news__tag { display: inline-block; padding: 1px 6px; border-radius: 2px; font-size: 9.5px; color: var(--dim); background: var(--bg-panel2); }

/* ---------- dock ---------- */

.dock {
  flex: 0 0 246px;
  height: 246px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--bg-panel);
  min-height: 0;
}
.dock-tabs {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 6px;
  border-bottom: 1px solid var(--line);
  background: #0c1116;
  height: 26px;
  flex: 0 0 26px;
}
.dtab {
  background: transparent;
  border: none;
  color: var(--dim);
  padding: 0 10px;
  height: 100%;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
}
.dtab.is-active { color: var(--amber); border-bottom-color: var(--amber); }
.dtab:hover { color: var(--txt); }
.dock-body { flex: 1; min-height: 0; position: relative; display: flex; }
.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  gap: 7px;
  overflow: hidden;
  position: relative;
}
.pane.is-hidden { display: none; }

.jform { display: grid; grid-template-columns: 90px 84px 80px 90px 90px 150px minmax(160px, 1fr) auto; gap: 5px; }
.jform input, .jform select, .bt-controls input, .bt-controls select {
  background: var(--bg-panel2);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 4px 6px;
}
.jform input:focus, .bt-controls input:focus { border-color: var(--amber); }

.bt-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 10.5px; color: var(--dim); }
.bt-controls label { display: flex; gap: 5px; align-items: center; }
.bt-controls input { width: 74px; }
.bt-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 190px minmax(180px, 1fr) minmax(200px, 1.1fr); gap: 10px; }
.bt-stats { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: var(--dim); overflow-y: auto; }
.bt-stat { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted #1b232c; padding: 2px 0; }
.bt-stat b { color: #dbe8f4; }
.bt-chart { min-width: 0; display: flex; }
#btCanvas { flex: 1; width: 100%; min-height: 110px; background: #080b0e; border: 1px solid var(--line); border-radius: 2px; display: block; }
.bt-trades { max-height: none; }

.scr-grid { flex: 1; display: grid; grid-template-columns: minmax(300px, 1.15fr) minmax(220px, 1fr); gap: 10px; min-height: 0; }
.scr-left { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
#scriptSrc {
  flex: 1;
  min-height: 70px;
  resize: none;
  background: #0a0e12;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 7px;
  color: var(--amber);
  outline: none;
  line-height: 1.5;
  font-family: var(--mono);
}
#scriptSrc:focus { border-color: var(--amber); }
.scr-actions { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.scr-actions select { background: var(--bg-panel2); border: 1px solid var(--line); padding: 4px; border-radius: 2px; }
.scr-out, .ai-out {
  margin: 0;
  background: #0a0e12;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 8px;
  overflow: auto;
  color: #9fb0c0;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.scr-help { font-size: 10.5px; line-height: 1.45; }

.access-panel {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.access-head { display: flex; justify-content: space-between; gap: 10px; }
.access-panel .muted { font-size: 10.5px; }

/* ---------- mobile nav ---------- */

.mobilenav {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: var(--bg-panel);
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.mobilenav button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--dim);
  padding: 8px 4px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mobilenav button.is-active { color: var(--amber); border-bottom: 2px solid var(--amber); }
.mobilenav button:hover { color: var(--txt); }

/* ---------- responsive ---------- */

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
  .rail { display: none; }
  body.rail-open .rail {
    display: flex;
    position: fixed;
    inset: 38px 0 0 0;
    z-index: 40;
    width: min(300px, 85vw);
    background: var(--bg-panel);
  }
  .dock { max-height: 200px; flex: 0 0 auto; }
  .dock-collapse { display: none; }
}

@media (max-width: 640px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .rail { display: none; }
  .stage { min-height: 0; }
  .chart-wrap { min-height: 0; }
  .side { display: none; }
  .dock { display: none; }
  .viewtabs { flex: 0 0 28px; }
  .chart-tools { gap: 6px; flex-wrap: wrap; }
  .group + .group { padding-left: 8px; border-left: none; }
  .tf-group { display: flex; gap: 4px; }
  .tf-group .tb { min-width: 22px; height: 18px; font-size: 9.5px; padding: 0 4px; }
}

/* ---------- toast notifications ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--bg-panel2);
  border: 1px solid var(--line);
  color: var(--txt);
  font-size: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast--success { border-color: var(--green); color: var(--green); }
.toast--warn { border-color: var(--amber); color: var(--amber); }
.toast--error { border-color: var(--red); color: var(--red); }
.toast--out { opacity: 0; transform: translateY(8px); }

/* ---------- site footer ---------- */
.site-footer {
  flex: 0 0 auto;
  padding: 5px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-panel);
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-align: center;
}
.site-footer a {
  color: var(--amber);
  font-weight: 600;
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }
.site-footer--gate {
  border-top: 0;
  background: transparent;
  padding: 4px 12px;
}
@media (max-width: 640px) {
  .gate .input { font-size: 16px; }
  .site-footer { font-size: 10px; padding: 4px 8px; }
}
