:root {
  --bg: #070d14; --panel: #0c1620; --panel2: #101e2b; --line: #17293a; --text: #e6eef6; --muted: #7f93a6;
  --green: #22c55e; --red: #ef4444; --amber: #f59e0b; --accent: #38bdf8;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
h1, h2 { margin: 0; }
h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }

.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side { padding: 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; background: #08111a; }
.main { padding: 14px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.side-card { padding: 12px; }
.label { font-size: 11px; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .strong { font-weight: 600; }
.pos { color: var(--green); } .neg { color: var(--red); }
.row { display: flex; align-items: center; gap: 8px; } .spread { justify-content: space-between; }

.brand { display: flex; gap: 10px; align-items: center; padding: 4px 4px 8px; }
.logo { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, #0ea5e9, #22c55e); display: grid; place-items: center; font-weight: 800; color: #04121c; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .02em; } .brand-sub { font-size: 10px; color: var(--muted); letter-spacing: .12em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { text-align: left; background: none; border: 1px solid transparent; border-radius: 8px; padding: 9px 12px; cursor: pointer; color: #b9c8d6; }
.nav-item:hover { background: var(--panel2); }
.nav-item.active { background: #0f2a3d; border-color: #1b4a68; color: #fff; }

.bot-state { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.bot-state.ok { color: var(--green); } .bot-state.warn { color: var(--amber); } .bot-state.bad { color: var(--red); }
.btn { width: 100%; margin-top: 10px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; }
.btn:hover { border-color: #2a4a63; }
.btn.primary { background: #0e7490; border-color: #0e7490; color: #fff; }
.btn.danger { background: #7f1d1d; border-color: #b91c1c; color: #fff; }
.btn.danger:hover { background: #991b1b; }
.btn:disabled { opacity: .5; cursor: default; }
.kv { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv.wide { grid-template-columns: 260px 1fr; margin: 12px 0; } .kv.wide dd { text-align: left; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); display: inline-block; }
.dot.ok { background: var(--green); } .dot.bad { background: var(--red); }

.topbar { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr auto; gap: 12px; align-items: stretch; }
.stat { padding: 12px 14px; min-width: 0; } .stat-win { display: flex; justify-content: space-between; align-items: center; }
/* every canvas needs a CSS size: the drawing code sizes its bitmap from the element, so an unsized canvas grows on each redraw on scaled screens */
#ring { width: 64px; height: 64px; flex: none; }
.big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.badge { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #134e4a; color: #5eead4; font-size: 10px; }
.badge.live { background: #7f1d1d; color: #fecaca; }
.top-right { display: flex; align-items: center; gap: 14px; padding: 0 6px; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12px; }
.pill.ok { color: var(--green); } .pill.warn { color: var(--amber); } .pill.bad { color: var(--red); }
.pill.ok .dot { background: var(--green); } .pill.bad .dot { background: var(--red); }
.clock { color: #b9c8d6; font-variant-numeric: tabular-nums; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; }
.icon-btn:hover { background: var(--panel2); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 40px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; min-width: 160px; z-index: 5; overflow: hidden; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; cursor: pointer; }
.menu button:hover { background: #17334a; }
.notice { margin: 0; padding: 10px 14px; border-radius: 8px; background: #3b2a08; border: 1px solid #78561a; color: #fcd34d; }
.notice.bad { background: #3b0d0d; border-color: #7f1d1d; color: #fecaca; }

.view { display: flex; flex-direction: column; gap: 12px; }
.chart-card { padding: 12px 14px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: none; cursor: pointer; font-weight: 600; }
.tab.active { background: #0f2a3d; border-color: #1b4a68; }
.price-block { display: flex; align-items: baseline; gap: 10px; }
.chart-price { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-change { font-size: 14px; font-weight: 600; }
.chart-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
select { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.chip { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.chip[aria-pressed="true"] { background: #0f2a3d; border-color: #1b4a68; }
.tv-wrap { margin-top: 8px; } .tv-wrap .tradingview-widget-container { height: 520px !important; width: 100% !important; background: var(--panel); border-radius: 8px; overflow: hidden; }
/* TradingView sizes its frame with inline styles, which our security policy (rightly) blocks, so size it from here instead */
#tv-container .tradingview-widget-container__widget { width: 100%; height: 100%; }
#tv-container iframe { display: block; width: 100% !important; height: 100% !important; border: 0; }
.tv-note { margin: 6px 0 0; } .chart-card:fullscreen .tv-wrap .tradingview-widget-container { height: calc(100vh - 190px) !important; }
.legend { margin: 6px 0; min-height: 18px; }
.legend-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.hint { margin-bottom: 4px; }
.zoom-group { display: flex; gap: 4px; align-items: center; }
.zoom-group .icon-btn { font-size: 18px; line-height: 1; }
.canvas-wrap canvas { cursor: grab; touch-action: pan-y; } .canvas-wrap canvas.grabbing { cursor: grabbing; }
.canvas-wrap { position: relative; height: 380px; }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-card:fullscreen { padding: 20px; overflow: auto; } .chart-card:fullscreen .canvas-wrap { height: calc(100vh - 160px); }
.tip { position: absolute; pointer-events: none; background: #0b1722ee; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; font-family: var(--mono); white-space: nowrap; }
.empty { margin: 14px 0 4px; color: var(--muted); text-align: center; }

.grid3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 12px; }
.list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow: auto; }
.list li { display: flex; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid #12212f; font-size: 13px; }
.list li .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list li .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { min-width: 44px; text-align: center; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.tag.buy { background: #052e16; color: #4ade80; border: 1px solid #14532d; }
.tag.sell { background: #3b0d0d; color: #f87171; border: 1px solid #7f1d1d; }
.tag.info { background: #0c2a3d; color: #7dd3fc; border: 1px solid #1b4a68; }
.tag.warn { background: #3b2a08; color: #fcd34d; border: 1px solid #78561a; }
.tag.err { background: #3b0d0d; color: #f87171; border: 1px solid #7f1d1d; }
.loglist { max-height: none; } .loglist li { font-family: var(--mono); font-size: 12px; align-items: flex-start; }
.link-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 100%; padding: 8px; cursor: pointer; color: #b9c8d6; }
.link-btn:hover { background: var(--panel2); }

.mini4, .cards4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.cards4 { grid-template-columns: repeat(4, 1fr); }
.mini { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.mini .k { font-size: 11px; color: var(--muted); } .mini .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.curve { width: 100%; height: 150px; display: block; } .big-curve { height: 300px; }
.note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; letter-spacing: .06em; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px; border-bottom: 1px solid #12212f; white-space: nowrap; }

.gate { position: fixed; inset: 0; background: #050a10ee; display: grid; place-items: center; z-index: 20; padding: 16px; }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.gate-card input { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.gate-card .btn { margin-top: 0; }
.gate-error { color: #f87171; margin: 0; }

@media (max-width: 1100px) { .grid3 { grid-template-columns: 1fr; } .cards4 { grid-template-columns: repeat(2, 1fr); } .topbar { grid-template-columns: 1fr 1fr; } .top-right { grid-column: 1 / -1; justify-content: flex-end; } }
@media (max-width: 800px) { .app { grid-template-columns: 1fr; } .side { border-right: 0; border-bottom: 1px solid var(--line); } .nav { flex-direction: row; flex-wrap: wrap; } .kv.wide { grid-template-columns: 1fr; } .canvas-wrap { height: 300px; } }
