:root {
  --bg: #121412;
  --panel: #1a1d1a;
  --panel-2: #232623;
  --line: #2c302c;
  --text: #e9ede9;
  --text-dim: #99a099;
  --text-faint: #6c736c;
  --accent: #4caf50;
  --tile-radius: 4px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 10px 14px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
}

.brand-mark { width: 20px; height: 20px; border-radius: 4px; }

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: .2px;
  white-space: nowrap;
}

.total {
  color: var(--text-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.seg {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  padding: 4px 11px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.seg button:hover { color: var(--text); }

.seg button.on {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.check input { accent-color: var(--accent); margin: 0; }

.legend {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.legend-bar {
  width: 110px;
  height: 10px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.08);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 8px;
  font-size: 13px;
}

.crumbs .back {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.crumbs .back:hover { background: var(--panel-2); }

.crumbs-path { color: var(--text-dim); }
.crumbs-path b { color: var(--text); font-weight: 600; }

.pm-link {
  color: #7ec5ff;
  text-decoration: none;
  font-size: 12.5px;
  white-space: nowrap;
}

.pm-link:hover { text-decoration: underline; }

#heatmap {
  position: relative;
  flex: 1;
  margin: 0 8px;
  min-height: 320px;
  overflow: hidden;
}

.boot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-dim);
}

.empty-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.boot.error { color: #e08a8a; }

.boot .retry {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.cat {
  position: absolute;
  border-radius: 6px;
  background: var(--panel);
  transition: left .45s ease, top .45s ease, width .45s ease, height .45s ease, opacity .3s ease;
  overflow: hidden;
}

.cat-h {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}

.cat-h:hover { color: var(--text); }
.cat-h .cat-vol { font-weight: 400; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.cat.no-h .cat-h { display: none; }

.cat-body { position: absolute; left: 0; right: 0; bottom: 0; top: 22px; }
.cat.no-h .cat-body { top: 0; }

.tile {
  position: absolute;
  border-radius: var(--tile-radius);
  overflow: hidden;
  cursor: pointer;
  transition: left .45s ease, top .45s ease, width .45s ease, height .45s ease,
              background-color .45s ease, opacity .3s ease, filter .3s ease;
}

.tile:hover {
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.55);
  z-index: 5;
}

.tile-in {
  position: absolute;
  inset: 0;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-in.center {
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.tile-title {
  font-weight: 600;
  font-size: 11.5px;
  line-height: 1.25;
  color: rgba(255,255,255,.96);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}

.tile.big .tile-title { font-size: 13px; }
.tile.huge .tile-title { font-size: 17px; }

.tile-price {
  font-size: 11px;
  color: rgba(255,255,255,.78);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}

.tile.big .tile-price { font-size: 12px; }
.tile.huge .tile-price { font-size: 13.5px; }

.tile-in.center .tile-price { font-size: 10.5px; color: rgba(255,255,255,.85); }

.tile-ico {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
  margin-bottom: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .25s ease;
}

.tile-ico.ld { opacity: 1; }

.tile.huge .tile-ico { width: 30px; height: 30px; }

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 14px 9px;
  font-size: 11.5px;
  color: var(--text-faint);
}

#statusRight { text-align: right; }

.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 320px;
  background: rgba(16, 18, 16, .96);
  border: 1px solid #383d38;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
}

.tooltip .tt-title { font-weight: 650; margin-bottom: 2px; }
.tooltip .tt-sub { color: var(--text-dim); margin-bottom: 6px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 18px; font-variant-numeric: tabular-nums; }
.tooltip .tt-row span:first-child { color: var(--text-dim); }
.tooltip .pos { color: #6fce77; }
.tooltip .neg { color: #e88588; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.card {
  width: min(440px, 100%);
  background: #191c19;
  border: 1px solid #333833;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  position: relative;
}

.card .x {
  position: absolute;
  top: 10px; right: 12px;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.card .x:hover { color: var(--text); }

.card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding-right: 22px;
}

.card-head img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
}

.card-head h2 { margin: 0; font-size: 15.5px; line-height: 1.3; }
.card-head .sub { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; }

.card-big {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.card-big .price { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-big .chg { font-size: 14px; font-weight: 600; }
.card-big .chg.pos { color: #6fce77; }
.card-big .chg.neg { color: #e88588; }
.card-big .chg.flat { color: var(--text-dim); }

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 9px;
  margin-bottom: 16px;
}

.card-grid .cell {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 7px 10px;
}

.card-grid .k { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .4px; }
.card-grid .v { font-size: 13px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card-grid .v.pos { color: #6fce77; }
.card-grid .v.neg { color: #e88588; }

.card-actions { display: flex; gap: 10px; }

.card-actions a, .card-actions button {
  flex: 1;
  text-align: center;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
}

.card-actions a.primary {
  background: #2d5e91;
  border-color: #3a76b5;
}

.card-actions a:hover, .card-actions button:hover { filter: brightness(1.15); }

.toast {
  position: fixed;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #3a2326;
  border: 1px solid #5c3236;
  color: #f0c9cb;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

@media (max-width: 720px) {
  .topbar { padding: 8px 10px 6px; }
  .legend { display: none; }
  #heatmap { margin: 0 4px; }
  .statusbar { font-size: 10.5px; }
}
