*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:     #090c12;
  --panel:  #0f1218;
  --card:   #141920;
  --hover:  #1a2030;
  --b0:     #1c2232;
  --b1:     #263045;
  --text:   #dde2f0;
  --sub:    #7a849e;
  --muted:  #3d4760;
  --accent: #3d7eff;
  --aglow:  rgba(61,126,255,.15);
  --teal:   #00ddb4;
  --orange: #ff9640;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Golos Text', sans-serif;
}

html, body { height: 100%; overflow: hidden; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); display: flex; flex-direction: column; }
#app { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--b1); border-radius: 4px; }
body.resizing * { cursor: col-resize !important; user-select: none !important; }

/* HEADER */
.header {
  height: 50px; flex-shrink: 0;
  background: var(--panel); border-bottom: 1px solid var(--b0);
  display: flex; align-items: center; gap: 12px; padding: 0 16px; z-index: 20;
}
.logo { font-family: var(--mono); font-size: 15px; font-weight: 700; letter-spacing: .04em; color: var(--text); white-space: nowrap; }
.logo em { color: var(--teal); font-style: normal; }
.vline { width: 1px; height: 20px; background: var(--b1); flex-shrink: 0; }
.hfile { font-family: var(--mono); font-size: 11px; color: var(--sub); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hfile b { color: var(--text); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--b1);
  background: var(--card); color: var(--sub);
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .13s; white-space: nowrap; flex-shrink: 0;
  line-height: 1;
}
.btn:hover { border-color: var(--accent); color: var(--text); background: var(--hover); }
.btn.on    { border-color: var(--accent); color: var(--accent); background: var(--aglow); }
.btn-up    { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-up:hover { background: #5a92ff; color: #fff; border-color: #5a92ff; }
.btn-icon  { width: 30px; padding: 0; } /* square icon-only buttons */
.modebar { display:flex; gap:6px; align-items:center; flex-shrink:0; }

/* LAYOUT */
.layout { flex: 1; display: flex; overflow: hidden; min-height: 0; position: relative; }

/* SIDEBAR */
.sidebar {
  width: var(--sb-w, 262px);
  min-width: 160px; max-width: 420px;
  flex-shrink: 0;
  background: var(--panel); border-right: 1px solid var(--b0);
  display: flex; flex-direction: column;
  overflow: hidden; /* critical */
  position: relative;
  user-select: none;
}
.sb-head {
  padding: 10px 12px 8px; border-bottom: 1px solid var(--b0);
  flex-shrink: 0; display: flex; flex-direction: column; gap: 6px;
}
.sb-row  { display: flex; align-items: center; justify-content: space-between; }
.sb-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sb-count { font-family: var(--mono); font-size: 10px; color: var(--accent); }
.search {
  width: 100%; background: var(--card); border: 1px solid var(--b1);
  border-radius: 6px; padding: 6px 10px; color: var(--text);
  font-family: var(--sans); font-size: 12px; outline: none; transition: border-color .13s;
}
.search::placeholder { color: var(--muted); }
.search:focus { border-color: var(--accent); }
.sb-btns { display: flex; gap: 5px; }
.sb-btn {
  flex: 1; padding: 4px 0; font-size: 11px; font-weight: 600;
  border-radius: 5px; border: 1px solid var(--b1); background: transparent;
  color: var(--sub); cursor: pointer; font-family: var(--sans); transition: all .12s;
}
.sb-presets { padding: 0 0 6px; }
.sb-preset-row { display: flex; gap: 4px; align-items: center; }
/* Unified select style */
.app-select, .sb-preset-sel {
  flex: 1; min-width: 0;
  background: var(--card);
  border: 1px solid var(--b1);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  padding: 0 28px 0 10px;
  outline: none;
  height: 30px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7b99' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color .15s;
}
.app-select:focus, .sb-preset-sel:focus { border-color: var(--accent); }
.app-select option, .sb-preset-sel option {
  background: #1a2030;
  color: var(--text);
}
.sb-preset-btn {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 5px;
  border: 1px solid var(--b1); background: var(--card); color: var(--sub);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .12s;
}
.sb-preset-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); background: var(--hover); }
.sb-preset-btn:disabled { opacity: .35; cursor: default; }
.sb-preset-del:hover:not(:disabled) { border-color: #ff4d6d; color: #ff4d6d; background: rgba(255,77,109,.1); }

/* Channel list — must have flex:1 + overflow-y:auto */
.ch-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
  min-height: 0; /* critical for flex children scroll */
}
.ch-item { display: flex; align-items: center; gap: 7px; padding: 5px 12px; cursor: pointer; user-select: none; transition: background .1s; }
.ch-item:hover { background: var(--hover); }
.ch-item.on    { background: var(--hover); }
.ch-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; transition: opacity .15s; }
.ch-item:not(.on) .ch-dot { opacity: .22; }
.ch-name { font-size: 14px; color: var(--sub); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-item.on .ch-name { color: var(--text); }
.ch-val  { font-family: var(--mono); font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* Resize handle */
/* Sidebar collapsed state */
.sb-collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: visible !important;
  padding: 0 !important;
}
.sb-collapsed .sb-head,
.sb-collapsed .ch-list,
.sb-collapsed .sb-presets { display: none !important; }

/* Collapse toggle button */
.sb-collapse-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 48px;
  background: var(--panel);
  border: 1px solid var(--b1);
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: color .15s, background .15s, left .2s;
}
.sb-collapse-btn:hover { color: var(--text); background: var(--card); }
@media (max-width: 768px) { .sb-collapse-btn { display: none; } }

.sb-resize {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 5px; cursor: col-resize; z-index: 10;
  background: transparent; transition: background .15s;
}
.sb-resize:hover, .sb-resize.dragging { background: var(--accent); opacity: .5; }

/* CONTENT */
.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

/* DROP */
.drop-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.13;
  pointer-events: none;
  border-radius: inherit;
}

.drop {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 18px; cursor: pointer;
  border: 2px dashed var(--b1); border-radius: 14px; margin: 28px;
  position: relative; transition: border-color .2s;
}
.drop::before { content:''; position:absolute; inset:0; border-radius:12px; background:radial-gradient(ellipse at 50% 60%, var(--aglow) 0%, transparent 65%); opacity:0; transition:opacity .3s; pointer-events:none; }
.drop:hover, .drop.drag { border-color: var(--accent); }
.drop:hover::before, .drop.drag::before { opacity: 1; }
.drop-icon { font-size: 42px; opacity: .32; }
.drop-text { text-align: center; }
.drop-text h2 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.drop-text p  { font-size: 13px; color: var(--sub); }
.drop-text small { font-family: var(--mono); font-size: 10px; color: var(--muted); display: block; margin-top: 4px; }

/* STATS */
.stats { display:flex; flex-shrink:0; background:var(--panel); border-bottom:1px solid var(--b0); overflow-x:auto; }
.stat  { padding:7px 16px; border-right:1px solid var(--b0); flex-shrink:0; }
.stat-l { font-size:9px; font-weight:700; text-transform:uppercase; letter-spacing:.09em; color:var(--muted); margin-bottom:2px; }
.stat-v { font-family:var(--mono); font-size:13px; font-weight:500; color:var(--text); }

/* CHART ZONE — flex:1 but min-height:0 so it won't push bottom bar out */
.chart-zone {
  flex: 1;
  min-height: 0;
  padding: 8px 12px 6px;
  display: flex; flex-direction: column; gap: 7px;
  overflow-y: auto;
  overflow-x: hidden;
}

.modebar-r { margin-left:auto; display:flex; gap:5px; align-items:center; }
.norm-hint { font-family:var(--mono); font-size:10px; color:var(--muted); }

.chart-box {
  flex: 1; min-height: 320px;
  background: var(--card); border: 1px solid var(--b0);
  border-radius: 10px; padding: 8px 10px;
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
}
.chart-box canvas { display: block; width: 100% !important; height: 100% !important; }

.split-scroll {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 0;
  background: var(--card); border: 1px solid var(--b0); border-radius: 10px;
}
.split-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--b0);
  padding: 4px 8px 0;
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
.split-card:last-child { border-bottom: none; }
.split-resize {
  height: 5px; cursor: row-resize;
  background: transparent; transition: background .15s;
  margin: 0 -8px;
}
.split-resize:hover { background: var(--accent); opacity: .4; }

.split-crosshair {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(255,255,255,0.25);
  pointer-events: none; z-index: 10;
}
.split-head { display:flex; align-items:center; gap:6px; font-family:var(--mono); font-size:10px; color:var(--sub); margin-bottom:2px; }
.split-head .sdot { width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.split-head .sval { margin-left:auto; color:var(--text); font-size:11px; }

.empty { display:flex; align-items:center; justify-content:center; height:100%; flex-direction:column; gap:8px; color:var(--muted); font-size:13px; }
.empty-ic { font-size:26px; opacity:.28; }

/* BOTTOM CHANNEL BAR */
/* Bottom bar collapse button */
/* Help modal */
.help-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--b0);
}
.help-section:last-child { border-bottom: none; }
.help-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.help-section-hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
}
.help-kbd-grid { display: flex; flex-direction: column; gap: 8px; }
.help-kbd-row { display: flex; align-items: center; gap: 12px; }
.help-keys {
  display: flex; align-items: center; gap: 4px;
  min-width: 140px; flex-shrink: 0;
  font-size: 12px; color: var(--sub);
}
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 6px;
  background: var(--card); border: 1px solid var(--b1);
  border-bottom: 2px solid var(--b1);
  border-radius: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--text);
}
.help-kbd-desc { font-size: 12px; color: var(--sub); }

.bb-collapse-btn {
  width: 100%;
  height: 16px;
  background: var(--panel);
  border: none;
  border-top: 1px solid var(--b0);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.bb-collapse-btn:hover { color: var(--text); background: var(--card); }
@media (max-width: 768px) { .bb-collapse-btn { display: none; } }

.ch-bar-wrap {
  flex-shrink: 0;
  background: var(--panel); border-top: 1px solid var(--b0);
  display: flex; flex-direction: column;
}
.ch-bar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--b0);
}
.ch-bar-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--sans); font-size: 12px;
  padding: 2px 0;
}
.ch-bar-input::placeholder { color: var(--muted); }
.ch-bar {
  padding: 6px 12px;
  display: flex; align-items: center; gap: 5px;
  flex-wrap: wrap;
}
.ch-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; border: 1px solid transparent;
  background: var(--card); font-size: 13px; font-weight: 500; color: var(--sub);
  cursor: pointer; flex-shrink: 0; transition: all .12s;
}
.ch-tag:hover { background: var(--hover); color: var(--text); }
.ch-tag.on    { border-color: var(--b1); color: var(--text); }
.ch-tag .tdot { width: 6px; height: 6px; border-radius: 50%; }
.ch-tag .tval { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-left: 1px; }
.ch-tag .tx   { opacity: .35; font-size: 11px; margin-left: 1px; }
.ch-tag:hover .tx { opacity: 1; }

/* META */
.meta { padding:4px 12px; background:var(--panel); border-top:1px solid var(--b0); display:flex; gap:12px; font-family:var(--mono); font-size:9px; color:var(--muted); flex-shrink:0; flex-wrap:wrap; }
.meta span { color: var(--sub); }

/* RESPONSIVE */
@media (max-width: 700px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 200; transform: translateX(-100%);
    transition: transform .25s ease;
    width: 280px !important;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.mob-open { transform: translateX(0); }
  .mob-overlay {
    display: block !important;
    position: fixed; inset: 0; z-index: 199;
    background: rgba(0,0,0,.5);
  }
  .sb-resize { display: none; }
  .modebar {
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .modebar::-webkit-scrollbar { display: none; }
  .modebar .btn { padding: 0 8px; font-size: 11px; flex-shrink: 0; }
  .modebar .btn-icon { padding: 0; width: 30px; flex-shrink: 0; }
  .btn-jpg { display: none; }
  .hfile { max-width: 80px; }
  .stats { overflow-x: auto; }
  .ch-bar-wrap { display: none !important; }

@media (orientation: landscape) and (max-height: 500px) {
  .chart-box { min-height: 160px !important; }
  .header { height: 40px; min-height: 40px; }
  .stats { display: none; }
}
}
.mob-overlay { display: none; }
.btn-mob-channels { display: none; }

@media (max-width: 700px) {
  .btn-mob-channels { display: inline-flex; }
}
/* STATS TABLE */
.st-table-wrap { overflow-x: auto; }
.st-table { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.st-th { position: sticky; top: 0; z-index: 2; background: #1a2030; color: var(--sub); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 8px 12px; border-bottom: 1px solid var(--b1); text-align: left; }
.st-th.st-sortable { cursor: pointer; user-select: none; }
.st-th.st-sortable:hover { color: var(--text); }
.st-th.st-num { text-align: right; }
.st-sort-arrow { color: var(--accent); margin-left: 3px; }
.st-td { padding: 7px 12px; border-bottom: 1px solid var(--b0); color: var(--text); }
.st-td.st-num { text-align: right; color: var(--sub); font-size: 11px; }
.st-row { cursor: pointer; transition: background .1s; }
.st-row:hover td { background: var(--hover); }

/* TOAST */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  pointer-events: none; z-index: 9999;
  animation: toast-in .2s ease, toast-out .3s ease 1.7s forwards;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.toast-success { background: #0f2a1a; border: 1px solid #00c860; color: #00e870; }
.toast-error   { background: #2a0f0f; border: 1px solid #ff4d6d; color: #ff6b85; }
@keyframes toast-in  { from { opacity:0; transform:translateX(-50%) translateY(10px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; } }
/* COMPARE */
.cmp-selectors {
  display: flex; gap: 6px; max-height: 120px; flex-shrink: 0;
}
.cmp-sel-col {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--b0);
  border-radius: 8px; display: flex; flex-direction: column; overflow: hidden;
}
.cmp-sel-head {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px;
  border-bottom: 1px solid var(--b0); font-size: 11px; color: var(--sub);
  flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmp-sel-list {
  overflow-y: auto; padding: 3px 0;
}
.cmp-ch-item {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px;
  cursor: pointer; font-family: var(--mono); font-size: 11px; color: var(--sub);
  transition: background .1s;
}
.cmp-ch-item:hover { background: var(--hover); }
.cmp-ch-item.on { color: var(--text); }
.cmp-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.cmp-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px; flex-shrink: 0;
}
.cmp-a { background: rgba(61,126,255,.2); color: #3d7eff; }
.cmp-b { background: rgba(255,150,64,.2); color: #ff9640; }

.an-list { display: flex; flex-direction: column; gap: 0; padding: 8px; }
.an-card {
  display: flex; align-items: stretch; gap: 0;
  background: var(--card); border: 1px solid var(--b0); border-radius: 8px;
  margin-bottom: 5px; cursor: pointer; overflow: hidden; transition: border-color .13s;
}
.an-card:hover { border-color: var(--accent); }
.an-badge { width: 4px; flex-shrink: 0; }
.an-body { flex: 1; padding: 10px 12px; min-width: 0; }
.an-head { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.an-col { font-family: var(--mono); font-size: 12px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-sev { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; flex-shrink: 0; }
.an-sev-high { background: rgba(255,60,60,.15); color: #ff4040; }
.an-sev-medium { background: rgba(255,150,60,.12); color: #ff9640; }
.an-detail { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--mono); font-size: 10px; color: var(--sub); }
.an-val b { color: var(--text); }
.an-dev { color: var(--orange); }
.an-arrow { display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-size: 14px; flex-shrink: 0; }
.mini-preview {
  flex-shrink: 0; height: 44px;
  background: var(--card); border: 1px solid var(--b0); border-radius: 6px;
  position: relative; cursor: default; overflow: hidden; margin-top: 4px;
  user-select: none;
}
.mini-window {
  position: absolute; top: 0; bottom: 0;
  border: 1px solid var(--accent); border-radius: 2px;
  pointer-events: none;
}
.mini-dim {
  position: absolute; top: 0; bottom: 0;
  background: rgba(0,0,0,.45); pointer-events: none;
}
.mini-sel {
  position: absolute; top: 0; bottom: 0;
  background: var(--aglow); border: 1px solid var(--accent);
  pointer-events: none;
}
.hm-select {
  background: var(--card); border: 1px solid var(--b1); border-radius: 6px;
  color: var(--text); font-family: var(--sans); font-size: 11px;
  padding: 4px 8px; outline: none; cursor: pointer; height: 30px;
  max-width: 180px;
}
.hm-select:focus { border-color: var(--accent); }

.hm-container {
  flex: 1; min-height: 0;
  display: flex; align-items: stretch;
  padding: 4px 8px 6px;
  gap: 6px;
  overflow: hidden;
}
.hm-yaxis {
  display: flex; flex-direction: column; justify-content: space-between;
  align-items: flex-end; padding-right: 4px;
  flex-shrink: 0; width: 44px;
  padding-bottom: 42px; /* leave space for x-axis and legend */
}
.hm-ylabel { font-family: var(--mono); font-size: 9px; color: var(--sub); white-space: nowrap; }

.hm-grid-wrap {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
.hm-grid {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
.hm-row { flex: 1; min-height: 0; display: flex; }
.hm-cell {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: default; border: 1px solid rgba(0,0,0,.15);
  transition: opacity .1s;
}
.hm-cell:hover { opacity: .8; outline: 1px solid rgba(255,255,255,.3); }
.hm-val { font-family: var(--mono); font-size: 8px; color: rgba(255,255,255,.75); line-height: 1; }

.hm-xaxis {
  display: flex; flex-shrink: 0; margin-top: 3px; height: 14px;
}
.hm-xlabel {
  flex: 1; font-family: var(--mono); font-size: 9px; color: var(--sub);
  text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.hm-legend-wrap { flex-shrink:0; margin-top:12px; padding:0 4px; display:flex; justify-content:center; }
.hm-legend-inner { display:flex; align-items:flex-start; gap:10px; width:20%; min-width:100px; }
.hm-legend-bar-wrap { flex:1; position:relative; padding-bottom:18px; }
.hm-legend-bar { height:10px; border-radius:5px; position:relative; overflow:visible; }
.hm-legend-ticks { position:relative; height:18px; margin-top:2px; }
.hm-legend-tick { position:absolute; transform:translateX(-50%); display:flex; flex-direction:column; align-items:center; }
.hm-legend-tick-line { width:1px; height:4px; background:var(--muted); }
.hm-legend-tick-label { font-family:var(--mono); font-size:9px; color:var(--sub); white-space:nowrap; margin-top:1px; }
.hm-legend-arrow { position:absolute; top:-13px; transform:translateX(-50%); pointer-events:none; transition:left .1s; line-height:0; }
.hm-legend-arrow svg { display:block; }
.hm-legend-name { font-family:var(--mono); font-size:9px; color:var(--sub); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:120px; padding-top:2px; align-self:center; }
.hm-label { font-size: 11px; color: var(--sub); flex-shrink: 0; }
.hm-drop .f-dropdown-btn { min-width: 130px; }
.hm-drop-sm .f-dropdown-btn { min-width: 90px; }
.hm-drop-btn { height: 30px; }
.hm-theme-btn { gap: 6px; }

.hm-tooltip {
  position: fixed;
  transform: translateY(-50%);
  background: rgba(14,17,24,.97); border: 1px solid var(--b1);
  border-radius: 8px; padding: 10px 14px; min-width: 200px;
  pointer-events: none; z-index: 9999;
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
}
.hm-tt-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 2px 0; }
.hm-tt-label { font-family: var(--mono); font-size: 10px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.hm-tt-val   { font-family: var(--mono); font-size: 11px; color: var(--sub); white-space: nowrap; }
.hm-tt-divider { border-top: 1px solid var(--b0); margin: 6px 0; }

.tbl { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.tbl th { position: sticky; top: 0; z-index: 2; background: #1a2030; color: var(--sub); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 8px 12px; border-bottom: 1px solid var(--b1); text-align: left; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td { padding: 5px 12px; color: var(--text); border-bottom: 1px solid var(--b0); }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tbody tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.tbl tbody tr:nth-child(even):hover td { background: var(--hover); }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #181d28; border: 1px solid var(--b1);
  border-radius: 12px; width: 560px; max-width: 95vw; max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.7);
}
.modal-head {
  display: flex; align-items: center;
  padding: 16px 18px 0; flex-shrink: 0;
}
.modal-title { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; }
.modal-close {
  margin-left: auto; background: none; border: none; color: var(--sub);
  font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 4px; transition: color .13s;
}
.modal-close:hover { color: var(--text); }
.modal-hint { padding: 6px 18px 12px; font-size: 12px; color: var(--sub); border-bottom: 1px solid var(--b0); flex-shrink: 0; }
.modal-body { padding: 14px 18px; overflow-y: visible; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--b0); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* FILTER ROW */
.filter-row { display: flex; align-items: center; gap: 10px; }

/* CUSTOM DROPDOWN */
.f-dropdown { position: relative; flex-shrink: 0; z-index: 10; }
.f-dropdown-btn {
  display: flex; align-items: center; gap: 7px;
  min-width: 190px; padding: 7px 10px;
  background: var(--card); border: 1px solid var(--b1);
  border-radius: 7px; cursor: pointer; font-size: 12px; color: var(--text);
  transition: border-color .13s;
}
.f-dropdown-btn:hover, .f-dropdown.open .f-dropdown-btn { border-color: var(--accent); }
.f-dropdown-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-dropdown-list {
  position: fixed;
  background: #1e2535; border: 1px solid var(--b1);
  border-radius: 8px; padding: 4px 0;
  max-height: 280px; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  z-index: 9999;
  min-width: 220px;
}
.f-dropdown-item {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; font-size: 12px; color: var(--sub);
  cursor: pointer; transition: background .1s;
}
.f-dropdown-item:hover { background: var(--hover); color: var(--text); }
.f-dropdown-item.selected { color: var(--text); background: var(--hover); }
.f-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* RANGE SLIDER */
.f-range-wrap { flex: 1; min-width: 0; }
.f-dual-range { position: relative; height: 24px; display: flex; align-items: center; }
.f-range-track { position: absolute; left: 0; right: 0; height: 3px; background: var(--b1); border-radius: 2px; }
.f-range-fill  { position: absolute; height: 3px; background: var(--accent); border-radius: 2px; }
.f-range {
  position: absolute; width: 100%; height: 3px;
  -webkit-appearance: none; appearance: none;
  background: transparent; pointer-events: none; outline: none; margin: 0;
}
.f-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  pointer-events: all; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.f-range-vals {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; color: var(--sub);
  margin-top: 3px; padding: 0 1px;
}

.f-del {
  background: none; border: none; color: var(--muted); font-size: 13px;
  cursor: pointer; padding: 4px 6px; border-radius: 4px; flex-shrink: 0;
  transition: color .13s;
}
.f-del:hover { color: #ff4d6d; }
.f-empty { color: var(--muted); font-size: 12px; padding: 4px 0; }
.btn-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--b1);
  background: var(--card);
  color: var(--sub);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}
.btn-settings:hover {
  background: var(--panel);
  color: var(--text);
  border-color: var(--accent);
}

/* Map view */
#gonkalogs-map { background: #0d1117; }
#gonkalogs-map .leaflet-tile { filter: brightness(0.85) saturate(0.7); }
#gonkalogs-map .leaflet-control-attribution { font-size: 9px; opacity: 0.5; }

.view-switcher {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.view-switcher::-webkit-scrollbar { display: none; }

.mode-switcher {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.mode-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--sub);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
  line-height: 1.6;
}
.mode-tab:hover { background: var(--panel); color: var(--text); }
.mode-tab.active {
  background: var(--accent);
  color: #fff;
}

.thr-row { display:flex; flex-direction:column; gap:6px; padding:8px 0; border-bottom:1px solid var(--b0); }
.thr-row:last-of-type { border-bottom:none; }
.f-add-btn {
  margin-top: 4px; align-self: flex-start;
  background: none; border: 1px dashed var(--b1); border-radius: 7px;
  padding: 7px 14px; color: var(--sub); font-family: var(--sans);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .13s;
}
.f-add-btn:hover { border-color: var(--accent); color: var(--text); background: var(--aglow); }
.loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  transition: opacity .4s;
}
.loader.fade { opacity: 0; pointer-events: none; }
.loader-logo { font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: .2em; color: var(--accent); }
.loader-logo em { color: var(--teal); font-style: normal; }
.loader-bar { width: 160px; height: 2px; background: var(--b1); border-radius: 2px; overflow: hidden; }
.loader-bar::after {
  content: ''; display: block; height: 100%;
  width: 40%; background: var(--accent);
  animation: slide 1s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
/* Fullscreen chart overlay */
.chart-box-fs {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000;
  border-radius: 0 !important;
  border: none !important;
  padding: 12px !important;
  background: #090c12 !important;
}

.zoom-sel {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(61,126,255,0.15);
  border-left: 1px solid rgba(61,126,255,0.6);
  border-right: 1px solid rgba(61,126,255,0.6);
  pointer-events: none;
  z-index: 10;
}
.hover-panel {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  background: rgba(14, 17, 24, 0.96);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 180px;
  max-width: 240px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.hp-time {
  font-family: var(--mono); font-size: 10px; color: var(--sub);
  margin-bottom: 7px; padding-bottom: 6px; border-bottom: 1px solid var(--b0);
}
.hp-row {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 0; font-family: var(--mono); font-size: 11px;
}
.hp-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.hp-name { color: var(--sub); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.hp-val  { color: var(--text); font-weight: 500; flex-shrink: 0; margin-left: 4px; }

/* ── COMPARE SPLIT CHARTS ─────────────────────────────── */
.cmp-split-card {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  border-bottom: 1px solid var(--b0);
  padding: 2px 0 0;
}
.cmp-split-card:last-child { border-bottom: none; }
.cmp-split-head {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; color: var(--sub);
  margin-bottom: 2px; flex-shrink: 0;
  padding: 0 10px;
  position: absolute; top: 4px; left: 0; right: 0; z-index: 5;
  pointer-events: none;
}
.cmp-split-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-legend-a {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  background: rgba(61,126,255,.2); color: #3d7eff;
}
.cmp-legend-b {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  background: rgba(255,150,64,.2); color: #ff9640;
}

/* ── WIZARD CROP HANDLES ──────────────────────────────── */
.cmp-crop-handle {
  position: absolute; top: 0; bottom: 0; width: 10px;
  cursor: col-resize; z-index: 10;
  display: flex; align-items: center; justify-content: center;
}
.cmp-crop-handle::after {
  content: '';
  width: 3px; height: 40px; border-radius: 3px;
  background: rgba(61,126,255,.7);
}
.cmp-crop-handle:hover::after { background: var(--accent); }
.cmp-crop-left  { left: 10px; }
.cmp-crop-right { right: 10px; }
