/* TREVOR demo — a dense, terminal-style rebuild of the operator hub. Mobile-first.
   Spacing is done with padding and gap only. */

.tv {
  --tv-bg: #07090b;
  --tv-panel: #0f1316;
  --tv-panel-2: #151b20;
  --tv-line: #232c33;
  --tv-text: #d6dee4;
  --tv-dim: #7f8c96;
  --tv-up: #3ddc97;
  --tv-down: #ff6b6b;
  --tv-flat: #c9a227;
  --tv-accent: #5cc8ff;
  --tv-bar: #2f7fb0;
  --tv-off: #3a444c;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  padding-bottom: 3.5rem;
}

html[data-theme="light"] .tv {
  --tv-bg: #eef1f4;
  --tv-panel: #ffffff;
  --tv-panel-2: #f3f6f8;
  --tv-line: #d3dae0;
  --tv-text: #14191e;
  --tv-dim: #5b6670;
  --tv-up: #0a8a5a;
  --tv-down: #c62e2e;
  --tv-flat: #8a6d00;
  --tv-accent: #0a6fa8;
  --tv-bar: #4a90bf;
  --tv-off: #c3ccd3;
  color-scheme: light;
}

.tv *, .tv *::before, .tv *::after { box-sizing: border-box; }
.tv [hidden] { display: none !important; }

/* Labs bar */
.tv-labs-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--tv-line); background: var(--tv-panel);
}
/* The shared .back colour is the light Labs palette's; on this dark bar it measured 1.1:1. */
.tv-labs-bar .back { color: var(--tv-text); }
.tv-labs-bar .back:hover { color: var(--tv-accent); }
.tv-labs-title { font-weight: 700; letter-spacing: 0.08em; }
.tv-demo-badge { font-size: 11px; }

/* Shell: bottom nav on phones, rail on wide screens */
.tv-shell { display: block; }
.tv-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; border-top: 1px solid var(--tv-line); background: var(--tv-panel);
}
.tv-nav a {
  flex: 1; text-align: center; padding: 0.9rem 0.25rem; color: var(--tv-dim);
  text-decoration: none; letter-spacing: 0.12em; font-weight: 700;
}
.tv-nav a.on { color: var(--tv-accent); box-shadow: inset 0 2px 0 var(--tv-accent); }

.tv-body { min-width: 0; }
.tv-top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--tv-line);
}
.tv-engine { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--tv-dim); }
.tv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tv-flat); display: inline-block; }
.tv-tickers { display: flex; flex-wrap: wrap; gap: 0.3rem; flex: 1 1 100%; order: 5; }
.tv-tick {
  padding: 0.1rem 0.4rem; border: 1px solid var(--tv-line); border-radius: 4px;
  color: var(--tv-dim); font-size: 11px;
}
.tv-pill {
  padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid var(--tv-line);
  font-size: 11px; white-space: nowrap;
}
.tv-kill { color: var(--tv-dim); }
.tv-theme { padding-left: 0.6rem; padding-right: 0.6rem; }

.tv-main { padding: 0.75rem; }
.tv-muted { color: var(--tv-dim); }
.tv-error { color: var(--tv-down); }

/* Sub-tabs and switch */
.tv-subtabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding-bottom: 0.75rem; }
.tv-subtabs a {
  padding: 0.35rem 0.7rem; border: 1px solid var(--tv-line); border-radius: 6px;
  color: var(--tv-dim); text-decoration: none;
}
.tv-subtabs a.on { color: var(--tv-text); border-color: var(--tv-accent); }
.tv-spacer { flex: 1; }
.tv-switch { display: inline-flex; border: 1px solid var(--tv-line); border-radius: 6px; overflow: hidden; }
.tv-switch .tv-btn { border: 0; border-radius: 0; }

.tv-btn {
  font: inherit; color: var(--tv-text); background: var(--tv-panel-2);
  border: 1px solid var(--tv-line); border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer;
}
.tv-btn:hover { border-color: var(--tv-accent); }
.tv-btn:focus-visible, .tv-subtabs a:focus-visible, .tv-nav a:focus-visible, .tv-row:focus-visible {
  outline: 2px solid var(--tv-accent); outline-offset: 2px;
}
.tv-btn.on { background: var(--tv-accent); color: var(--tv-bg); }
.tv-btn[disabled] { cursor: not-allowed; opacity: 0.55; }
.tv-btn[disabled]:hover { border-color: var(--tv-line); }

/* Cards */
.tv-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
.tv-card {
  background: var(--tv-panel); border: 1px solid var(--tv-line); border-radius: 8px;
  padding: 0.75rem; min-width: 0; display: flex; flex-direction: column; gap: 0.5rem;
}
.tv-card h2 { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tv-dim); }
.tv-asof { font-size: 11px; color: var(--tv-dim); }
.tv-note { font-size: 12px; color: var(--tv-dim); font-family: var(--sans); }
.tv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.75rem; }
.tv-title { font-size: 16px; font-weight: 700; }

.tv-chips { display: flex; gap: 0.35rem; }
.tv-chips .tv-btn { padding: 0.2rem 0.6rem; }

.tv-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.tv-tile { background: var(--tv-panel-2); border: 1px solid var(--tv-line); border-radius: 6px; padding: 0.5rem; min-width: 0; }
.tv-tile-label { font-size: 11px; color: var(--tv-dim); }
.tv-tile-value { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.tv-tile-sub { font-size: 11px; color: var(--tv-dim); }
.tv-up { color: var(--tv-up); }
.tv-down { color: var(--tv-down); }
.tv-flat { color: var(--tv-flat); }

/* Key-value lists and bar lists */
.tv-kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.75rem; }
.tv-kv .k { color: var(--tv-dim); }
.tv-kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.tv-bars { display: flex; flex-direction: column; gap: 0.3rem; }
.tv-barrow { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) 3rem; align-items: center; gap: 0.5rem; }
.tv-bartrack { height: 8px; background: var(--tv-panel-2); border-radius: 4px; overflow: hidden; }
.tv-barfill { height: 100%; background: var(--tv-bar); width: 0; }
.tv-barn { text-align: right; color: var(--tv-dim); font-variant-numeric: tabular-nums; }

/* Market grid */
.tv-market { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.tv-mcell { border: 1px solid var(--tv-line); border-radius: 6px; padding: 0.4rem 0.5rem; background: var(--tv-panel-2); }
.tv-mname { font-weight: 700; }
.tv-mmeta { font-size: 11px; color: var(--tv-dim); }

/* Tables of rows */
.tv-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tv-filters label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 11px; color: var(--tv-dim); }
.tv-filters select, .tv-filters input {
  font: inherit; color: var(--tv-text); background: var(--tv-panel-2);
  border: 1px solid var(--tv-line); border-radius: 6px; padding: 0.3rem 0.4rem; max-width: 9.5rem;
}
.tv-list { display: flex; flex-direction: column; border-top: 1px solid var(--tv-line); }
.tv-row {
  display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) 4.6rem 4.2rem; gap: 0.4rem;
  padding: 0.45rem 0.25rem; border-bottom: 1px solid var(--tv-line); cursor: pointer;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left;
  font: inherit; color: inherit; width: 100%;
}
.tv-row:hover { background: var(--tv-panel-2); }
.tv-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-row .tv-num { text-align: right; font-variant-numeric: tabular-nums; }
.tv-detail { padding: 0.5rem 0.25rem 0.75rem; border-bottom: 1px solid var(--tv-line); background: var(--tv-panel-2); }
.tv-count { font-size: 11px; color: var(--tv-dim); }

/* Charts */
.tv-chart { width: 100%; height: auto; display: block; }
.tv-chart .axis { stroke: var(--tv-line); stroke-width: 1; }
.tv-chart .zero { stroke: var(--tv-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.tv-chart .line { fill: none; stroke: var(--tv-accent); stroke-width: 2; }
.tv-chart .bar { fill: var(--tv-bar); }
.tv-chart text { fill: var(--tv-dim); font-family: var(--mono); font-size: 10px; }

/* Controls */
.tv-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Setups */
.tv-setup-detail { padding: 0.4rem 0.25rem 0.6rem; background: var(--tv-panel-2); border-bottom: 1px solid var(--tv-line); }
.tv-vs { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); gap: 0.25rem 0.5rem; }
.tv-vs .h { color: var(--tv-dim); font-size: 11px; }

/* MATH */
.tv math { font-size: 1.15em; padding: 0.4rem 0; overflow-x: auto; max-width: 100%; }

@media (min-width: 640px) {
  .tv-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tv-market { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tv-tickers { flex: 1 1 auto; order: 0; }
}

@media (min-width: 900px) {
  .tv { padding-bottom: 0; }
  .tv-shell { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); min-height: 100vh; }
  .tv-nav {
    position: sticky; top: 0; align-self: start; height: 100vh; flex-direction: column;
    border-top: 0; border-right: 1px solid var(--tv-line);
  }
  .tv-nav a { flex: 0 0 auto; padding: 1.1rem 0.25rem; }
  .tv-nav a.on { box-shadow: inset 2px 0 0 var(--tv-accent); }
  .tv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tv-wide { grid-column: 1 / -1; }
}
