/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e6e5e0;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-ink: #ffffff;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --good: #006300;
  --bad: #d03b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.16);
  /* categorical series (fixed order) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --s-other: #898781;
  /* sequential blue: near-zero recedes into the surface */
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #5598e7; --seq-4: #256abf; --seq-5: #104281;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422; --surface-3: #2e2e2b;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18);
    --accent: #3987e5; --accent-hover: #5598e7; --accent-wash: rgba(57, 135, 229, 0.16);
    --good: #0ca30c; --bad: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.3);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --seq-1: #133e78; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422; --surface-3: #2e2e2b;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #3987e5; --accent-hover: #5598e7; --accent-wash: rgba(57, 135, 229, 0.16);
  --good: #0ca30c; --bad: #e66767;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.3);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --seq-1: #133e78; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ic { display: block; flex: none; }
[data-icon] { display: inline-flex; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- app frame ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
.top {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.tabs button {
  display: flex; align-items: center; gap: 6px;
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px;
  color: var(--ink-2); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border); }
.tab-ic { display: inline-flex; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.range { display: flex; align-items: center; gap: 6px; }
.range select, .range input, .field, .select {
  height: 34px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); padding: 0 10px; outline: none;
}
.range select:focus, .range input:focus, .field:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.range-custom { display: flex; align-items: center; gap: 4px; }
.range-dash { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-icon { width: 34px; padding: 0; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { color: var(--bad); }

main { min-height: 0; position: relative; }

/* ---------- welcome ---------- */
.welcome { height: 100%; overflow: auto; display: flex; justify-content: center; padding: 48px 16px; }
.welcome-inner { width: 100%; max-width: 640px; }
.welcome h1 { font-size: 32px; letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.15; }
.lede { color: var(--ink-2); font-size: 16px; margin: 0 0 24px; }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 36px 16px; border: 2px dashed var(--border-strong); border-radius: 16px;
  background: var(--surface); cursor: pointer; text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-wash); }
.drop-ic { color: var(--accent); margin-bottom: 4px; }
.drop-title { font-weight: 600; font-size: 16px; }
.drop-sub { color: var(--muted); }
.howto { margin-top: 28px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.howto h2 { font-size: 15px; margin: 0 0 10px; }
.howto-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; }
.howto-head h2 { margin: 0; }
.howto ol { margin: 0 0 12px; padding-left: 20px; }
.howto li { margin-bottom: 8px; }
.privacy { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: 13px; margin-top: 18px; }

/* ---------- overview ---------- */
.overview { height: 100%; overflow: auto; }
.ov { max-width: 1320px; margin: 0 auto; padding: 24px 16px 48px; }
.ov-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.eyebrow { color: var(--ink-2); font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-num { font-size: 56px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; }
.hero-unit { font-size: 18px; color: var(--ink-2); font-weight: 500; }
.hero-sub { color: var(--ink-2); margin-top: 8px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile-label { color: var(--ink-2); font-size: 12.5px; }
.tile-value { font-size: 22px; font-weight: 620; letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta { font-size: 12px; font-weight: 600; margin-top: 4px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.delta .vs { color: var(--muted); font-weight: 400; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title { font-weight: 600; font-size: 14.5px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.card-actions { display: flex; gap: 4px; flex: none; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }
.chart-box canvas { position: absolute; inset: 0; }
.card > .viz { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.chart-box.fill { flex: 1 1 auto; height: auto; min-height: 260px; }
.card .tbl-wrap { display: none; max-height: 320px; overflow: auto; }
.card.show-table .tbl-wrap { display: block; }
.card.show-table .viz { display: none; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 3px 9px; border-radius: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--border); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--grid); position: sticky; top: 0; background: var(--surface); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }

.insights { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.insights li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.insights .ins-ic { flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-wash); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.insights b { font-weight: 600; }

.records { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.rec { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--grid); }
.rec:last-child { border-bottom: 0; }
.rec dt { color: var(--ink-2); }
.rec dd { margin: 0; text-align: right; font-weight: 600; }
.rec dd small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.rec dd a { cursor: pointer; color: var(--ink); text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 3px; }
.rec dd a:hover { text-decoration-color: var(--ink); }

.share { display: flex; gap: 2px; height: 28px; border-radius: 6px; overflow: hidden; background: var(--surface); }
.share-seg { min-width: 3px; }
.share-legend { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; }
.share-legend li { display: grid; grid-template-columns: 10px 1fr auto; column-gap: 8px; align-items: center; }
.share-legend .lg-l { color: var(--ink-2); }
.share-legend .lg-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.share-legend .lg-s { grid-column: 2 / -1; color: var(--muted); font-size: 12px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw-empty { box-shadow: inset 0 0 0 1px var(--axis); }
.line-key { display: inline-block; width: 16px; height: 3px; border-radius: 2px; flex: none; }

.cal-scroll { overflow-x: auto; padding-bottom: 4px; }
.cal { display: block; }
.cal-lbl { font-size: 10.5px; fill: var(--muted); font-family: var(--font); }
.cal-cell { cursor: pointer; }
.cal-cell:hover { stroke: var(--ink); stroke-width: 1.5; }
.cal-empty { stroke: var(--grid); stroke-width: 1; cursor: default; }
.seq-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.seq-legend .sw { width: 12px; height: 12px; }
.seq-legend .seq-less { margin-left: 12px; }
.seq-legend .sw + span:not(.sw) { margin-right: 6px; }

.mx { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; }
.mx-col { font-size: 10.5px; color: var(--muted); text-align: left; height: 14px; }
.mx-row { font-size: 11px; color: var(--muted); display: flex; align-items: center; }
.mx-cell { aspect-ratio: 1; border-radius: 3px; min-height: 10px; }
.mx-cell:hover { outline: 1.5px solid var(--ink); }

.bars-list { display: flex; flex-direction: column; gap: 10px; }
.bl-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.bl-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bl-label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.bl-val small { color: var(--muted); font-weight: 400; }
.bl-track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bl-fill { height: 100%; border-radius: 3px; }

.viz-tip {
  position: fixed; z-index: 5000; pointer-events: none; display: none;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); max-width: 280px;
}
.viz-tip b { color: var(--ink); display: block; margin-bottom: 2px; font-weight: 600; }
.tip-hint { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.empty-note { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- workspace (panel + map) ---------- */
.workspace { display: grid; grid-template-columns: 400px minmax(0, 1fr); height: 100%; }
.panel { overflow: auto; background: var(--surface); border-right: 1px solid var(--border); min-height: 0; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--surface-2); }
.p-sec { padding: 16px; border-bottom: 1px solid var(--border); }
.p-sec:last-child { border-bottom: 0; }
.p-head { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.p-title { font-weight: 600; font-size: 15px; margin: 0 0 2px; }
.p-sub { color: var(--muted); font-size: 12.5px; }
.p-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.p-row + .p-row { margin-top: 8px; }
.field { flex: 1; min-width: 0; }
.search { position: relative; flex: 1; min-width: 140px; }
.search .field { width: 100%; padding-left: 32px; }
.search [data-icon] { position: absolute; left: 9px; top: 8px; color: var(--muted); }
.select { padding-right: 6px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.mini-stats div { background: var(--surface-2); border-radius: 8px; padding: 8px; min-width: 0; }
.mini-stats b { display: block; font-size: 15px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-stats span { color: var(--muted); font-size: 11.5px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.check .cnt { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.legend-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.legend-list li { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.legend-list .cnt { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.heat-ramp { height: 8px; border-radius: 4px; margin-top: 8px; }
.sec-label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }

.list { list-style: none; margin: 0; padding: 0; }
.item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.item:hover { background: var(--surface-2); }
.item.sel { background: var(--accent-wash); }
.item.sel::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.item-sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-stats { display: flex; gap: 12px; color: var(--ink-2); font-size: 12.5px; margin-top: 4px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.item-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); cursor: default; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); vertical-align: 2px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-home, .badge-work { background: var(--accent-wash); color: var(--accent); }
.mode-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.more { padding: 12px 16px; text-align: center; }
.wd-bars { display: flex; gap: 3px; align-items: flex-end; height: 34px; }
.wd-bars div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); }
.wd-bars i { display: block; width: 100%; max-width: 14px; background: var(--s1); border-radius: 2px 2px 0 0; min-height: 1px; }
.rename { display: flex; gap: 6px; }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }

/* day timeline */
.day-nav { display: flex; align-items: center; gap: 6px; }
.day-nav input { flex: 1; }
.day-title { font-weight: 600; font-size: 16px; margin-top: 12px; }
.tl { list-style: none; margin: 0; padding: 8px 16px 24px; position: relative; }
.tl-item { display: grid; grid-template-columns: 52px 22px 1fr; gap: 0 8px; cursor: pointer; border-radius: 8px; }
.tl-item:hover .tl-body { background: var(--surface-2); }
.tl-item.sel .tl-body { background: var(--accent-wash); }
.tl-time { color: var(--muted); font-size: 12px; padding-top: 10px; text-align: right; font-variant-numeric: tabular-nums; }
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before { content: ''; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--grid); }
.tl-item:first-child .tl-rail::before { top: 14px; }
.tl-item:last-child .tl-rail::before { bottom: calc(100% - 14px); }
.tl-node { position: relative; margin-top: 9px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--surface); display: flex; align-items: center; justify-content: center; color: var(--surface); font-size: 8px; font-weight: 700; }
.tl-trip .tl-node { width: 10px; height: 10px; margin-top: 11px; background: var(--surface); box-shadow: 0 0 0 2px var(--mc, var(--muted)); }
.tl-trip .tl-rail::before { width: 3px; background: var(--mc, var(--muted)); opacity: 0.7; }
.tl-body { padding: 6px 8px 8px; border-radius: 8px; min-width: 0; margin-bottom: 2px; }
.tl-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-sub { color: var(--ink-2); font-size: 12.5px; }
.tl-nested .tl-body { padding-left: 18px; }
.tl-nested .tl-title { font-weight: 500; }

/* playback */
.playback {
  position: absolute; left: 12px; right: 12px; bottom: 24px; z-index: 800;
  max-width: 640px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
}
.pb-row { display: flex; align-items: center; gap: 10px; }
.pb-play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; }
.pb-play:hover { background: var(--accent-hover); }
.pb-time { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 48px; }
.pb-now { color: var(--ink-2); font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-slider { flex: 1; accent-color: var(--accent); }
.pb-speed { height: 28px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); padding: 0 4px; font-size: 12.5px; }

/* map markers & popups */
.pin { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ink); color: var(--surface); box-shadow: 0 0 0 2px var(--surface), 0 2px 6px rgba(0, 0, 0, 0.3); }
.pin-num { font-size: 11px; font-weight: 700; font-family: var(--font); }
.pin.sel { background: var(--accent); color: var(--accent-ink); }
.pb-marker { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface), 0 0 0 9px var(--accent-wash), 0 2px 8px rgba(0, 0, 0, 0.3); }
.leaflet-container { font: 13px/1.4 var(--font); background: var(--surface-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.pop-title { font-weight: 650; font-size: 14px; margin-bottom: 2px; padding-right: 12px; }
.pop-sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.pop .kv { font-size: 12.5px; }
.pop .actions { margin-top: 10px; }
.leaflet-bar a, .leaflet-control-zoom a { background: var(--surface); color: var(--ink); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-control-scale-line { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--ink-2); border-color: var(--ink-2); }
.map-btn { position: absolute; top: 12px; left: 12px; z-index: 800; box-shadow: var(--shadow); }

/* ---------- overlays ---------- */
.loading { position: fixed; inset: 0; z-index: 6000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: color-mix(in srgb, var(--page) 85%, transparent); backdrop-filter: blur(2px); color: var(--ink-2); font-weight: 500; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drop-overlay { position: fixed; inset: 0; z-index: 5500; display: flex; align-items: center; justify-content: center; background: var(--accent-wash); border: 3px dashed var(--accent); pointer-events: none; }
.drop-overlay div { background: var(--surface); padding: 16px 24px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-lg); }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 7000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: min(520px, calc(100vw - 32px)); font-size: 13.5px; pointer-events: auto; }
.toast.err { background: var(--bad); color: #fff; }
.geo-chip { position: fixed; left: 16px; bottom: 16px; z-index: 1200; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 4px 4px 14px; box-shadow: var(--shadow); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mini-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
.dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dlg-body { padding: 20px; }
.dlg-body h3 { margin: 0 0 6px; font-size: 17px; }
.dlg-body p { color: var(--ink-2); margin: 0 0 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.dlg-foot .spacer { flex: 1; }
.about h3 { font-size: 20px; margin: 2px 0; letter-spacing: -0.01em; }
.about p { color: var(--ink-2); margin: 12px 0 0; }
.about-head { display: flex; gap: 14px; align-items: center; }
.about-avatar { flex: none; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 19px; letter-spacing: 0.02em; }
.about-role { font-weight: 500; color: var(--ink); }
.about-head .muted { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.about-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.about-stats div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.about-stats b { display: block; font-size: 17px; font-weight: 650; }
.about-stats span { color: var(--muted); font-size: 11.5px; line-height: 1.3; display: block; }
.about-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.about-apps { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.about-apps li + li { border-top: 1px solid var(--border); }
.about-apps a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--ink); text-decoration: none; }
.about-apps a:hover { background: var(--surface-2); }
.about-apps a > span { display: flex; flex-direction: column; min-width: 0; }
.about-apps .ic { color: var(--muted); }
.made-by { color: var(--ink-2); font-size: 13px; margin: 24px 0 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 340px minmax(0, 1fr); }
  .tabs button span:last-child { display: none; }
  .tabs button { padding: 6px 10px; }
}
@media (max-width: 760px) {
  .app { grid-template-rows: auto 1fr auto; }
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .brand-name { font-size: 14px; }
  .top-actions { display: contents; }
  .btn-label { display: none; }
  #importBtn { width: 34px; padding: 0; margin-left: auto; }
  .range { order: 5; width: 100%; flex-wrap: wrap; }
  .range select { flex: 1; min-width: 0; }
  .range-custom { width: 100%; }
  .range-custom input { flex: 1; min-width: 0; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
    border-radius: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); justify-content: space-around;
  }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 2px; }
  .tabs button span:last-child { display: block; }
  .tabs button.active { box-shadow: none; background: var(--accent-wash); color: var(--accent); }
  main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .insights { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-3 { grid-column: auto; }
  .hero-num { font-size: 44px; }
  .ov { padding-top: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: 46% minmax(0, 1fr); }
  .map-wrap { order: -1; border-bottom: 1px solid var(--border); }
  .panel { border-right: 0; }
  .playback { left: 8px; right: 8px; bottom: 22px; padding: 6px 8px; gap: 4px; }
  .geo-chip { left: 8px; bottom: calc(68px + env(safe-area-inset-bottom)); }
  .pb-play { width: 32px; height: 32px; }
  .leaflet-control-scale { display: none; }
  .leaflet-control-attribution { max-width: calc(100vw - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
  .welcome { padding: 24px 16px; }
  .welcome h1 { font-size: 26px; }
  .about-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mx { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 1px; }
  .mx-col { font-size: 9px; }
}
@media (forced-colors: active) {
  .share-seg, .bl-fill, .mx-cell, .sw { forced-color-adjust: none; }
}
