/* tn-live — Trade Navigator streams. Dark, mobile first (the viewer page lives inside Telegram). */
:root {
  --bg: #0b111c;
  --panel: #121a29;
  --card: #172134;
  --line: #24314a;
  --text: #e8eefb;
  --mut: #8a9bbb;
  --acc: #3b7bff;
  --ok: #2fbf84;
  --warn: #f0b03a;
  --bad: #ef4f5a;
  --live: #ff3b4e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: #8fb4ff; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.mut { color: var(--mut); }
.small { font-size: 12px; }
.hide { display: none !important; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--acc); color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn.big { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.red { background: var(--bad); }
.btn.green { background: var(--ok); }
.btn.sm { padding: 5px 9px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: #0e1625; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--acc); }
label { display: block; font-size: 12px; color: var(--mut); margin: 10px 0 4px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--card); font-size: 12px; }
.livebadge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 59, 78, .14); color: #ff8b96; font-weight: 700; font-size: 12px; letter-spacing: .3px; }
.livebadge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #1f2b44; border: 1px solid var(--line); color: var(--text); padding: 9px 14px; border-radius: 10px; z-index: 60; max-width: 92vw; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.4); }

/* ── viewer (mini app) ── */
.v { display: flex; flex-direction: column; height: 100%; max-width: 900px; margin: 0 auto; }
.vhead { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.vhead .t { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vhead .cnt { color: var(--mut); font-size: 13px; }
.stage { position: relative; background: #000; aspect-ratio: 16 / 9; width: 100%; flex: none; }
.stage video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.stage .over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; background: rgba(0,0,0,.35); }
.stage .sound { position: absolute; left: 10px; top: 10px; }
.vctl { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; z-index: 5; }
.vvol { position: absolute; left: 8px; top: 8px; display: flex; gap: 8px; align-items: center; z-index: 5; background: rgba(11, 17, 28, .72); border: 1px solid rgba(255, 255, 255, .18); border-radius: 10px; padding: 2px 8px 2px 2px; backdrop-filter: blur(4px); }
.vvol .btn { background: transparent; border: 0; }
.vvol input[type=range] { width: 96px; padding: 0; border: 0; background: transparent; accent-color: var(--acc); }
body.theater .stage .vvol { top: calc(8px + env(safe-area-inset-top)); }
.vctl .btn { background: rgba(11, 17, 28, .72); border-color: rgba(255, 255, 255, .18); backdrop-filter: blur(4px); }
/* the player over the whole window / screen */
body.theater { overflow: hidden; }
body.theater .stage { position: fixed; inset: 0; z-index: 40; width: 100vw; height: 100vh; height: 100dvh; aspect-ratio: auto; }
body.theater .stage .vctl { top: calc(8px + env(safe-area-inset-top)); }
.stage:fullscreen { width: 100vw; height: 100vh; aspect-ratio: auto; }
.banner { position: absolute; left: 8px; right: 8px; bottom: 8px; background: rgba(18, 26, 41, .96); border: 1px solid var(--acc); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: rise .25s ease-out; }
.banner .bt { flex: 1; min-width: 0; }
.banner .bt b { display: block; }
.banner .bt span { color: var(--mut); font-size: 13px; }
.banner .x { background: transparent; border: 0; color: var(--mut); font-size: 18px; padding: 0 4px; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.pin { padding: 7px 12px; background: #13213a; border-bottom: 1px solid var(--line); font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.pin b { color: #8fb4ff; }
.chat { flex: 1; min-height: 120px; overflow-y: auto; padding: 8px 12px; -webkit-overflow-scrolling: touch; }
.msg { padding: 4px 6px; border-radius: 8px; margin: 1px 0; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .n { font-weight: 600; color: #9fc0ff; margin-right: 6px; }
.msg.staff .n { color: var(--warn); }
.msg.staff .n::after { content: " ★"; }
.msg.mine { background: rgba(59, 123, 255, .08); }
.msg .tm { color: var(--mut); font-size: 11px; margin-left: 6px; }
.msg.modable { cursor: pointer; }
.msg.modable:hover { background: rgba(255,255,255,.04); }
.sys { color: var(--mut); font-size: 13px; text-align: center; padding: 6px; }
.newmsg { position: sticky; bottom: 4px; left: 0; right: 0; margin: 0 auto; display: block; }
.compose { display: flex; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.compose input { flex: 1; }
.compose .note { flex: 1; color: var(--mut); font-size: 13px; padding: 8px 4px; }
.screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px 22px; gap: 12px; }
.screen .ic { font-size: 46px; }
.screen h2 { margin: 0; font-size: 21px; }
.screen p { margin: 0; color: var(--mut); max-width: 420px; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); max-height: 82vh; overflow: auto; }
.sheet .box h3 { margin: 0 0 8px; font-size: 16px; }
.sheet .acts { display: grid; gap: 8px; }
.sheet .acts .btn { width: 100%; }
@media (min-width: 900px) {
  .sheet { align-items: center; }
  .sheet .box { border-radius: 16px; }
}

/* ── studio & admin (desktop) ── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 16px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.top h1 { font-size: 20px; margin: 0; flex: 1; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.tabs button.on { background: var(--acc); border-color: var(--acc); color: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--mut); font-weight: 600; font-size: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; min-width: 160px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.kpi .n { font-size: 22px; font-weight: 800; }
.kpi .l { font-size: 12px; color: var(--mut); }
.preview { background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; }
.preview video { width: 100%; height: 100%; display: block; object-fit: contain; }
.status { font-weight: 700; }
.status.on { color: #ff8b96; }
.status.wait { color: var(--warn); }
.chatbox { display: flex; flex-direction: column; height: 70vh; min-height: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.rec { background: var(--bg); }
.recwrap { max-width: 980px; margin: 0 auto; padding: 18px; display: grid; gap: 12px; }
.recwrap h1 { margin: 0; font-size: 22px; }
.recwrap video { width: 100%; border-radius: 12px; background: #000; }
