:root {
  --bg: #070b16;
  --bg-soft: #0b1120;
  --card: #0f1626;
  --card-2: #121b2f;
  --border: #1d2942;
  --border-soft: #16203a;
  --text: #e8eefb;
  --muted: #8ba0c2;
  --muted-2: #64769a;
  --green: #2ee6a8;
  --green-dim: #17b183;
  --red: #ff5f74;
  --red-dim: #cf4157;
  --amber: #ffc44d;
  --blue: #5aa9ff;
  --violet: #a97cff;
  --indigo: #7c8cff;
  --orange: #f7931a;
  --radius: 14px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(90, 169, 255, .13), transparent 60%),
    radial-gradient(900px 520px at 92% 0%, rgba(46, 230, 168, .10), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
h3 { font-size: 17px; }
h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }
p { margin: 0; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.hidden { display: none !important; }

/* ---------------- top bar ---------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 18px 26px 14px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: .04em; color: #04121a;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: 0 6px 18px rgba(46, 230, 168, .25);
}
.brand-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.status-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  white-space: nowrap;
}
.badge-live { color: var(--green); border-color: rgba(46, 230, 168, .45); background: rgba(46, 230, 168, .08); }
.badge-archive { color: var(--amber); border-color: rgba(255, 196, 77, .38); background: rgba(255, 196, 77, .07); }
.badge-err { color: var(--red); border-color: rgba(255, 95, 116, .45); background: rgba(255, 95, 116, .08); }
.badge-ok { color: var(--green); }

.banner {
  margin: 0 26px 14px; padding: 11px 14px; border-radius: 12px; font-size: 13px;
  border: 1px solid rgba(255, 196, 77, .35); background: rgba(255, 196, 77, .08); color: #ffe0a3;
}
.banner.err { border-color: rgba(255, 95, 116, .4); background: rgba(255, 95, 116, .08); color: #ffc3cb; }

/* ---------------- controls ---------------- */

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.controls {
  display: flex; gap: 26px; align-items: flex-start; flex-wrap: wrap;
  margin: 0 26px 16px; padding: 13px 18px;
}
.control-block { display: flex; flex-direction: column; gap: 7px; }
.control-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted-2); }
.row-gap { display: flex; gap: 8px; align-items: center; }

.segmented { display: inline-flex; background: #0a1120; border: 1px solid var(--border); border-radius: 11px; padding: 3px; }
.seg-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit;
  transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: linear-gradient(180deg, #1c2c4b, #16233c); color: #fff; box-shadow: inset 0 0 0 1px rgba(124, 140, 255, .35); }

.btn {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: #131d33; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; transition: background .15s, border-color .15s;
}
.btn:hover { background: #18243d; border-color: #2a3c60; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-icon { padding: 8px 10px; min-width: 38px; }
.btn-play { background: linear-gradient(180deg, rgba(46, 230, 168, .22), rgba(46, 230, 168, .08)); border-color: rgba(46, 230, 168, .35); }
.btn-play.playing { background: linear-gradient(180deg, rgba(255, 95, 116, .22), rgba(255, 95, 116, .08)); border-color: rgba(255, 95, 116, .4); }
.btn-ghost { background: transparent; }
.select {
  font-family: inherit; font-size: 13px; background: #0a1120; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 9px;
}
.timectl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.time-label {
  font-family: inherit; font-size: 13.5px; font-weight: 650; color: var(--text);
  background: #0a1120; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; min-width: 210px; text-align: center; cursor: pointer;
}
.time-label:hover { border-color: #2a3c60; }

/* ---------------- layout ---------------- */

main { padding: 0 26px 40px; display: flex; flex-direction: column; gap: 16px; }
.columns { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.headline {
  margin-top: 12px; padding: 10px 13px; border-radius: 11px; font-size: 14.5px;
  background: rgba(124, 140, 255, .07); border: 1px solid rgba(124, 140, 255, .2);
}
.headline b { font-weight: 700; }

/* ---------------- map ---------------- */

.map-wrap { position: relative; margin-top: 4px; }
#map { width: 100%; height: auto; display: block; }
.empty-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 14px; background: rgba(7, 11, 22, .55); border-radius: 12px;
}

.map-legend {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border-soft);
  font-size: 12px; color: var(--muted);
}
.map-legend-note { flex: 1 1 380px; color: var(--muted-2); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-in { background: var(--green); box-shadow: 0 0 8px rgba(46, 230, 168, .6); }
.dot-out { background: var(--red); box-shadow: 0 0 8px rgba(255, 95, 116, .6); }
.dot-rot { background: var(--amber); }
.dot-rot2 { background: var(--blue); }
.dot-buy { background: var(--green-dim); }
.dot-sell { background: var(--red-dim); }
.dot-net { background: #d9e4ff; }
.dot-empty { background: rgba(148, 163, 184, .18); border: 1px solid rgba(148, 163, 184, .45); }
/* легенда карты: образцы лент (нейтральный цвет + пунктир для приблизительных данных) */
.line { display: inline-block; width: 26px; height: 0; margin-right: 7px; vertical-align: middle; }
.line-edge { border-top: 3px solid #a8bcd8; border-radius: 2px; }
.line-approx { border-top: 3px dashed #c9b6e8; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; max-width: 620px; justify-content: flex-end; }
.legend-chip {
  font-size: 11.5px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); white-space: nowrap;
}
.legend-chip b { color: var(--text); font-weight: 650; }

/* ---------------- timeline ---------------- */

.timeline-key { display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.timeline-wrap { position: relative; margin-top: 10px; }
#timeline { width: 100%; height: 168px; display: block; cursor: crosshair; }
#timeline .bar-in { fill: var(--green-dim); }
#timeline .bar-out { fill: var(--red-dim); }
#timeline .bar-in.hl, #timeline .bar-out.hl { opacity: .95; }
#timeline .bar-in { opacity: .62; }
#timeline .bar-out { opacity: .62; }
#timeline .net-line { fill: none; stroke: #d9e4ff; stroke-width: 1.6; opacity: .85; }
#timeline .sel-band { fill: rgba(124, 140, 255, .18); stroke: rgba(124, 140, 255, .5); }
#timeline .hover-band { fill: rgba(255, 255, 255, .05); }
#timeline .axis-line { stroke: var(--border-soft); stroke-width: 1; }
#timeline text { fill: var(--muted-2); font-size: 10.5px; }

/* ---------------- summary / help ---------------- */

.summary { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; }
.summary li::marker { color: var(--muted-2); }
.summary b { font-weight: 700; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.neu { color: var(--amber); }
.help { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: #cdd9ee; }
.help li::marker { color: var(--muted-2); }
.help b { color: #fff; }

/* ---------------- drawer ---------------- */

.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(430px, 92vw); z-index: 40;
  background: linear-gradient(180deg, #101a2d, #0a1120);
  border-left: 1px solid var(--border); box-shadow: -18px 0 50px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column;
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(22px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 18px 12px; border-bottom: 1px solid var(--border-soft); }
.drawer-body { padding: 14px 18px 30px; overflow-y: auto; }
.drawer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: #0c1424; border: 1px solid var(--border-soft); border-radius: 11px; padding: 10px 12px; }
.stat span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); }
.stat b { font-size: 16px; font-weight: 700; }
.drawer-sentence { margin-top: 12px; font-size: 13px; color: #cdd9ee; }
.pairs { display: flex; flex-direction: column; gap: 7px; }
.pair-row { background: #0c1424; border: 1px solid var(--border-soft); border-radius: 10px; padding: 9px 11px; }
.pair-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.pair-sym { font-weight: 650; }
.pair-bars { display: flex; gap: 3px; height: 5px; margin-top: 7px; }
.pair-bars i { display: block; border-radius: 3px; }
.pair-in { background: var(--green-dim); }
.pair-out { background: var(--red-dim); }
.pair-meta { font-size: 11px; color: var(--muted-2); margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; }

/* ---------------- tooltip ---------------- */

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: rgba(10, 17, 32, .97); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px; font-size: 12px; color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55); max-width: 320px;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.tooltip .tt-row b { color: var(--text); font-weight: 650; }

@media (max-width: 900px) {
  .columns { grid-template-columns: 1fr; }
  .topbar { padding: 14px 14px 10px; }
  .controls, .banner { margin-left: 14px; margin-right: 14px; }
  main { padding: 0 14px 30px; }
  .time-label { min-width: 150px; }
}
