/* PAMPUSHKA panel — dark trading-desk theme. Charts keep their own colors (set in app.js). */
:root {
  --bg: var(--tg-theme-bg-color, #0b0e14);
  --bg2: var(--tg-theme-secondary-bg-color, #131824);
  --card: #171d2b;
  --card-hi: #1c2334;
  --line: #242c3d;
  --line-hi: #313b52;
  --text: var(--tg-theme-text-color, #e6e9ef);
  --muted: var(--tg-theme-hint-color, #8b94a7);
  --accent: var(--tg-theme-button-color, #3b82f6);
  --up: #22c55e;
  --down: #ef4444;
  --warn: #f59e0b;
  --up-soft: rgba(34, 197, 94, .12);
  --down-soft: rgba(239, 68, 68, .12);
  --warn-soft: rgba(245, 158, 11, .12);
  --accent-soft: rgba(59, 130, 246, .14);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 6px 18px -10px rgba(0, 0, 0, .6);
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
.row, .fi .m, .tile, .sheet-info td { overflow-wrap: anywhere; min-width: 0; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, select, input { font: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; height: 44px;
  padding: 0 12px; background: color-mix(in srgb, var(--bg2) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .12em; font-size: 12px; }
.logo { width: 18px; height: 18px; border-radius: 5px; flex: none;
  background: linear-gradient(135deg, var(--accent), #8b5cf6); box-shadow: 0 0 12px -2px var(--accent); }
.status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; flex: 1; min-width: 0; }
.status span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.ok .dot { background: var(--up); }
.status.ok .dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--up);
  animation: pulse 2s var(--ease) infinite; }
.status.bad .dot { background: var(--down); }
.status.bad { color: var(--down); }
.status.replay .dot { background: var(--warn); }
@keyframes pulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(2.6); opacity: 0; } }
.pnl { font-family: var(--mono); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
  padding: 3px 9px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.pnl:has(.up) { background: var(--up-soft); border-color: rgba(34, 197, 94, .3); }
.pnl:has(.down) { background: var(--down-soft); border-color: rgba(239, 68, 68, .3); }
.pnl:empty { display: none; }

/* ---------------------------------------------------------------- tabs */
.tabs { position: sticky; top: 44px; z-index: 4; display: flex; gap: 2px; padding: 4px 8px 0;
  background: color-mix(in srgb, var(--bg2) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); }
.tab { position: relative; flex: 1; padding: 9px 4px 11px; border: 0; background: none; color: var(--muted);
  cursor: pointer; font-weight: 500; font-size: 13.5px; transition: color .15s var(--ease); }
.tab::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform .2s var(--ease); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { transform: scaleX(1); }

/* ---------------------------------------------------------------- layout */
main { padding: 12px 12px 28px; max-width: 1100px; margin: 0 auto; }
.pane { display: none; }
.pane.active { display: block; animation: fade .18s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
h3 { margin: 20px 0 8px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .08em; }

.toolbar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar select, .toolbar input { background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; min-width: 0; transition: border-color .15s; color-scheme: dark; }
.toolbar select:hover, .toolbar input:hover { border-color: var(--line-hi); }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar input[type=search] { flex: 1; text-transform: uppercase; }
.btn { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; cursor: pointer;
  transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--line-hi); background: var(--card-hi); }
.btn:active { transform: translateY(1px); }
.chips { gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
  font-size: 12px; cursor: pointer; color: var(--muted); transition: all .15s var(--ease); }
.chip:hover { color: var(--text); border-color: var(--line-hi); }
.chip.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- stat cards */
.strat-row { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; scrollbar-width: none; }
.strat-row::-webkit-scrollbar { display: none; }
.stat { flex: none; background: linear-gradient(180deg, var(--card-hi), var(--card)); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 12px; min-width: 120px; box-shadow: var(--shadow); }
.stat:first-child { border-color: var(--line-hi); }
.stat .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat .v { font-family: var(--mono); font-weight: 700; font-size: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 11px; color: var(--muted); font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- rows */
.list { display: flex; flex-direction: column; gap: 6px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; border: 1px dashed var(--line); border-radius: var(--radius); }
.unmanaged { margin-top: 16px; }
.unmanaged summary { color: var(--muted); cursor: pointer; padding: 6px 0; font-size: 13px; }
.unmanaged summary:hover { color: var(--text); }
.unmanaged .hint { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.row { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 12px 9px 14px; cursor: pointer; overflow: hidden; box-shadow: var(--shadow);
  transition: border-color .15s, background .15s, transform .1s; }
.row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-hi); }
.row[data-pnl="up"]::before { background: var(--up); }
.row[data-pnl="down"]::before { background: var(--down); }
.row:hover { border-color: var(--line-hi); background: var(--card-hi); }
.row:active { transform: scale(.995); border-color: var(--accent); }
.row.static { cursor: default; }
.row.static:active { transform: none; }
.row .l1, .row .l2 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row .l2 { color: var(--muted); font-size: 12px; margin-top: 3px; }
.row .sym { font-weight: 700; letter-spacing: .02em; }
.row .tag { font-size: 10.5px; color: var(--muted); margin-left: 7px; font-weight: 500; padding: 1px 6px;
  border-radius: 5px; background: rgba(139, 148, 167, .1); vertical-align: 1px; }
.num { font-family: var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .l1 .num { font-weight: 600; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 6px; position: relative; overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; width: 2px; }

/* ---------------------------------------------------------------- feed */
.feed { display: flex; flex-direction: column; font-size: 12.5px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
.feed:empty { display: none; }
.fi { display: grid; grid-template-columns: 62px 16px 1fr; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line);
  transition: background .12s; }
.fi:last-child { border-bottom: 0; }
.fi:hover { background: var(--card-hi); }
.fi .t { font-family: var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.fi .m { word-break: break-word; }
.fi .m b { cursor: pointer; }
.fi .m b:hover { color: var(--accent); }
.fi .src { color: var(--muted); font-size: 10.5px; margin-right: 5px; padding: 0 5px; border-radius: 4px;
  background: rgba(139, 148, 167, .1); }
.k-entry { background: linear-gradient(90deg, var(--up-soft), transparent 40%); }
.k-exit { background: linear-gradient(90deg, var(--down-soft), transparent 40%); }
.k-warn { background: linear-gradient(90deg, var(--down-soft), transparent 40%); }
.k-signal .ic::before { content: "◆"; color: var(--accent); }
.k-entry .ic::before { content: "▲"; color: var(--up); }
.k-exit .ic::before { content: "▼"; color: var(--down); }
.k-skip .ic::before { content: "○"; color: var(--muted); }
.k-broker .ic::before { content: "!"; color: var(--warn); font-weight: 700; }
.k-warn .ic::before { content: "⚠"; color: var(--down); }
.k-info .ic::before { content: "·"; color: var(--muted); }

/* ---------------------------------------------------------------- health */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { position: relative; background: linear-gradient(180deg, var(--card-hi), var(--card)); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 12px; overflow: hidden; box-shadow: var(--shadow); }
.tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: transparent; }
.tile .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.tile .v { font-family: var(--mono); font-size: 19px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 11px; color: var(--muted); }
.tile.bad { border-color: rgba(239, 68, 68, .5); background: linear-gradient(180deg, var(--down-soft), var(--card)); }
.tile.bad::before { background: var(--down); }
.tile.warn { border-color: rgba(245, 158, 11, .5); background: linear-gradient(180deg, var(--warn-soft), var(--card)); }
.tile.warn::before { background: var(--warn); }
.hchart { height: 170px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

/* ---------------------------------------------------------------- chart sheet */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column;
  animation: rise .22s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.sheet-title { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-tools { display: flex; gap: 6px; }
.sheet-tools select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px; color-scheme: dark; }
.chart { flex: 1; min-height: 240px; }
.sheet-info { max-height: 34vh; overflow: auto; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12.5px; background: var(--bg2); }
.sheet-info table { border-collapse: collapse; width: 100%; }
.sheet-info tr + tr td { border-top: 1px solid var(--line); }
.sheet-info td { padding: 5px 8px 5px 0; vertical-align: top; }
.sheet-info td:first-child { color: var(--muted); white-space: nowrap; }
.sheet-info .msg { color: var(--muted); padding: 8px 0; }

/* ---------------------------------------------------------------- TEMP: connection diagnostics */
.dbg-btn { padding: 3px 7px; font-size: 13px; line-height: 1; }
.diag-tools { padding: 10px 12px 0; margin: 0; }
.diag-log { flex: 1; margin: 10px 12px 12px; padding: 10px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 11.5px/1.45 var(--mono); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  user-select: text; -webkit-user-select: text; }

/* ---------------------------------------------------------------- scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-hi) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-hi); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
