/* terminal.css — Sheeplz Terminal HUD. Soft slate dark, monospace numbers, venue colours. */
:root {
  color-scheme: dark;
  --t-bg: #1d2233;
  --t-panel: #232a3e;
  --t-panel-2: #2a3249;
  --t-line: #343d57;
  --t-grid: rgba(150, 165, 210, 0.08);
  --t-text: #e8ebf7;
  --t-text-2: #9aa3c2;
  --t-text-3: #6f7898;
  --t-up: #22c7a0;
  --t-down: #f0567a;
  --t-accent: #8f7dff;
  --t-accent-2: #4fd1e8;
  --t-cross: rgba(210, 218, 245, 0.45);
  --t-label: #3a4462;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--t-bg);
  color: var(--t-text);
  font: 13px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.t-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

:focus-visible {
  outline: 2px solid var(--t-accent-2);
  outline-offset: 2px;
  border-radius: 4px;
}

.t-app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
}

/* ---- top bar ---- */
.t-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 14px;
  background: var(--t-panel);
  border-bottom: 1px solid var(--t-line);
}

.t-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.t-logo img {
  width: 30px;
  height: auto;
  padding: 2px;
  background: #fff;
  border-radius: 7px;
}

.t-logo b {
  background: linear-gradient(90deg, var(--t-accent), var(--t-accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.t-seg {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  border-radius: 9px;
}

.t-seg button {
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--t-text-2);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.t-seg button:hover {
  color: var(--t-text);
}

.t-seg button[aria-pressed="true"] {
  background: var(--t-panel-2);
  color: var(--t-text);
  box-shadow: inset 0 0 0 1px var(--t-line);
}

.t-ticker {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  min-width: 190px;
}

#t-price {
  font-size: 17px;
  font-weight: 600;
}

#t-change.up {
  color: var(--t-up);
}

#t-change.down {
  color: var(--t-down);
}

#t-vol {
  color: var(--t-text-3);
  font-size: 11px;
}

.t-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--t-panel-2);
  border: 1px solid var(--t-line);
  color: var(--t-text);
  font-weight: 500;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.t-btn:hover {
  border-color: var(--t-accent);
}

.t-btn svg {
  width: 15px;
  height: 15px;
  color: var(--t-accent-2);
}

.t-primary {
  background: var(--t-accent);
  border-color: var(--t-accent);
  color: #fff;
}

.t-venues {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
}

.t-venue {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--t-text-2);
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.t-venue:hover {
  border-color: var(--t-text-3);
}

.t-venue i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--vc);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--vc) 25%, transparent);
}

.t-venue small {
  color: var(--t-text-3);
  font-size: 10px;
}

.t-venue.connecting i {
  animation: t-pulse 1s ease-in-out infinite;
}

.t-venue.down {
  border-color: color-mix(in srgb, var(--t-down) 50%, var(--t-line));
}

.t-venue.down i {
  background: var(--t-down);
}

.t-venue.off {
  opacity: 0.45;
}

.t-venue.off i {
  background: var(--t-text-3);
  box-shadow: none;
}

@keyframes t-pulse {
  50% {
    opacity: 0.3;
  }
}

.t-link {
  color: var(--t-text-2);
  font-weight: 500;
}

.t-link:hover {
  color: var(--t-text);
}

/* ---- main layout ---- */
.t-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 0;
}

.t-chart {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.t-canvas {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.t-canvas canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.t-canvas canvas.dragging {
  cursor: grabbing;
}

.t-hint {
  padding: 4px 12px;
  font-size: 11px;
  color: var(--t-text-3);
  border-top: 1px solid var(--t-line);
}

.t-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: var(--t-bg);
  color: var(--t-text-2);
}

.t-loading[hidden] {
  display: none;
}

.t-loading img {
  width: 96px;
  animation: t-float 2.4s ease-in-out infinite;
}

.t-loading.error {
  color: var(--t-down);
}

@keyframes t-float {
  50% {
    transform: translateY(-8px);
  }
}

/* ---- side panels ---- */
.t-side {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border-left: 1px solid var(--t-line);
  background: var(--t-panel);
}

.t-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.t-panel + .t-panel {
  border-top: 1px solid var(--t-line);
}

.t-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
}

.t-panel h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--t-text-2);
}

.t-panel h2 img {
  width: 20px;
  height: 20px;
}

.t-select {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--t-text-3);
}

.t-select select {
  padding: 2px 6px;
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
}

.t-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 0 12px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t-text-3);
}

.t-cols span:not(:first-child) {
  text-align: right;
}

.t-book {
  font-family: var(--mono);
  font-size: 11.5px;
}

.t-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 1.5px 12px;
}

.t-row.empty {
  visibility: hidden;
}

.t-row span {
  position: relative;
  text-align: right;
}

.t-row .t-px {
  text-align: left;
}

.t-row.ask .t-px {
  color: var(--t-down);
}

.t-row.bid .t-px {
  color: var(--t-up);
}

.t-row .t-cum {
  color: var(--t-text-3);
}

/* Stacked bar: one segment per venue, growing from the right edge. */
.t-row .t-bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 0;
  left: 0;
  display: flex;
  flex-direction: row-reverse;
  opacity: 0.32;
  pointer-events: none;
}

.t-row .t-bar i {
  display: block;
  height: 100%;
  transition: width 0.2s ease;
}

.t-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.t-mid {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 3px 0;
  padding: 5px 12px;
  background: var(--t-bg);
  border-block: 1px solid var(--t-line);
}

#t-mid-px {
  font-size: 14px;
  font-weight: 600;
}

#t-spread {
  font-size: 10.5px;
  color: var(--t-text-3);
}

#t-spread.crossed {
  color: var(--t-accent-2);
}

.t-imb {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 4px;
  font-size: 10px;
  color: var(--t-text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.t-imb b {
  font-family: var(--mono);
  color: var(--t-text);
  min-width: 3.5em;
  text-align: right;
}

.t-imb-bar {
  height: 6px;
  border-radius: 6px;
  background: var(--t-down);
  overflow: hidden;
}

.t-imb-bar i {
  display: block;
  height: 100%;
  width: 50%;
  background: var(--t-up);
  transition: width 0.3s ease;
}

.t-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 4px 12px 10px;
  font-size: 10.5px;
  color: var(--t-text-2);
}

.t-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 2px;
  background: var(--vc);
}

.t-tape-cols {
  grid-template-columns: 38px 1fr 0.8fr 0.7fr 62px;
  gap: 6px;
}

.t-tape {
  list-style: none;
  overflow-y: auto;
  min-height: 0;
  font-family: var(--mono);
  font-size: 11px;
}

.t-tape li {
  display: grid;
  grid-template-columns: 38px 1fr 0.8fr 0.7fr 62px;
  gap: 6px;
  padding: 1.5px 12px;
  animation: t-in 0.4s ease;
}

.t-tape li span {
  text-align: right;
}

.t-tape li.buy span:nth-child(2) {
  color: var(--t-up);
}

.t-tape li.sell span:nth-child(2) {
  color: var(--t-down);
}

.t-tape li.whale {
  font-weight: 600;
}

.t-tape li.whale.buy {
  background: rgba(34, 199, 160, 0.12);
}

.t-tape li.whale.sell {
  background: rgba(240, 86, 122, 0.12);
}

.t-tape .t-tv {
  text-align: left;
  color: var(--vc);
  font-weight: 600;
}

.t-tape .t-time {
  color: var(--t-text-3);
}

@keyframes t-in {
  from {
    background: rgba(143, 125, 255, 0.18);
  }
}

/* ---- indicator dialog ---- */
.t-dialog {
  margin: auto;
  width: min(760px, calc(100vw - 24px));
  max-height: min(86vh, 900px);
  background: var(--t-panel);
  color: var(--t-text);
  border: 1px solid var(--t-line);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
}

.t-dialog::backdrop {
  background: rgba(10, 13, 24, 0.55);
  backdrop-filter: blur(3px);
}

.t-dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--t-panel);
  border-bottom: 1px solid var(--t-line);
}

.t-dialog-head div {
  display: flex;
  gap: 6px;
}

.t-dialog h2 {
  font-size: 16px;
}

.t-dialog-body {
  padding: 4px 16px 16px;
}

.t-dialog h3 {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--t-text-3);
}

.t-note {
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--t-text-2);
}

.t-ind-list {
  list-style: none;
  display: grid;
  gap: 4px;
}

.t-ind-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  border-radius: 9px;
}

.t-ind-list small {
  margin-left: 8px;
  color: var(--t-text-3);
}

.t-ind-list p {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--t-text-2);
}

.t-ind-list em {
  display: block;
  color: var(--t-down);
  font-style: normal;
  font-size: 11.5px;
}

.t-params {
  display: flex;
  align-items: center;
  gap: 6px;
}

.t-params label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--t-text-3);
}

.t-params input,
.t-script input[type="text"] {
  width: 64px;
  padding: 3px 6px;
  background: var(--t-panel);
  border: 1px solid var(--t-line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
}

.t-x {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--t-text-3);
}

.t-x:hover {
  background: color-mix(in srgb, var(--t-down) 20%, transparent);
  color: var(--t-down);
}

.t-script p {
  color: var(--t-text-2);
  font-size: 12px;
  margin-bottom: 6px;
}

.t-script textarea {
  width: 100%;
  padding: 10px;
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  tab-size: 2;
}

.t-script-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.t-script-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--t-text-2);
}

.t-script input[type="text"] {
  width: 160px;
}

.t-script-row .t-primary {
  margin-left: auto;
}

.t-err {
  margin-top: 6px;
  min-height: 1em;
  color: var(--t-down) !important;
  font-family: var(--mono);
}

/* ---- small screens ---- */
@media (max-width: 1000px) {
  .t-app {
    height: auto;
    min-height: 100dvh;
  }

  .t-main {
    grid-template-columns: 1fr;
  }

  .t-chart {
    height: 72dvh;
  }

  .t-side {
    border-left: 0;
    border-top: 1px solid var(--t-line);
  }

  .t-tape {
    max-height: 420px;
  }

  .t-venues {
    margin-left: 0;
  }
}
