/* Deputy Sniffer — app shell styles */

/* ───────────────────── Shell ───────────────────── */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; background: var(--bg-canvas); }
.app[data-nav="collapsed"] { grid-template-columns: var(--nav-w-collapsed) 1fr; }

/* Left nav */
.nav { background: var(--bg-nav); color: #C8C5BD; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden; }
.nav-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.logo { width: 26px; height: 26px; border-radius: 6px; background: var(--green); display: grid; place-items: center; flex: 0 0 auto; }
.logo svg { width: 16px; height: 16px; stroke: #F4FAF4; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 600; letter-spacing: -0.01em; font-size: 14px; color: #EDE9DF; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; color: #72706A; letter-spacing: 0.1em; text-transform: uppercase; margin-left: auto; }
.app[data-nav="collapsed"] .brand-name, .app[data-nav="collapsed"] .brand-sub, .app[data-nav="collapsed"] .nav-section-label, .app[data-nav="collapsed"] .nav-item-text, .app[data-nav="collapsed"] .nav-idx, .app[data-nav="collapsed"] .nav-foot-meta { display: none; }
.app[data-nav="collapsed"] .nav-item { justify-content: center; padding: 0; width: 36px; height: 36px; margin: 0 auto; }

.nav-search { margin: 6px 12px 14px; position: relative; }
.nav-search input { width: 100%; height: 30px; background: #1A1A1C; border: 1px solid #242428; color: #C8C5BD; border-radius: 6px; padding: 0 10px 0 30px; font-size: 12.5px; }
.nav-search input::placeholder { color: #5E5B54; }
.nav-search svg { position: absolute; left: 9px; top: 8px; width: 14px; height: 14px; stroke: #5E5B54; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.nav-search kbd { position: absolute; right: 7px; top: 5px; font-family: var(--font-mono); font-size: 10px; color: #5E5B54; border: 1px solid #2A2A2E; background: #141416; border-radius: 3px; padding: 1px 5px; }
.app[data-nav="collapsed"] .nav-search { display: none; }

.nav-sections { flex: 1; overflow: auto; padding: 0 8px 8px; }
.nav-section-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; color: #5E5B54; text-transform: uppercase; padding: 10px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 10px; border-radius: 6px; color: #C8C5BD; font-size: 13px; cursor: pointer; user-select: none; }
.nav-item:hover { background: var(--bg-nav-hover); color: #EDE9DF; }
.nav-item[data-active="true"] { background: #1F1F22; color: #EDE9DF; }
.nav-item[data-active="true"] .nav-idx { color: var(--green-hover); }
.nav-idx { font-family: var(--font-mono); font-size: 10.5px; color: #5E5B54; width: 18px; }
.nav-item-text { flex: 1; }
.nav-item-badge { font-family: var(--font-mono); font-size: 10px; color: #5E5B54; padding: 1px 5px; border: 1px solid #242428; border-radius: 3px; }
.nav-item-badge.alert { color: var(--amber); border-color: color-mix(in oklab, var(--amber) 30%, #242428); }

.nav-foot { padding: 10px 12px 14px; border-top: 1px solid #1A1A1C; display: flex; align-items: center; gap: 10px; }
.nav-foot .avatar { width: 28px; height: 28px; border-radius: 6px; background: #2E7D32; color: #F4FAF4; display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.nav-foot-meta { line-height: 1.2; min-width: 0; }
.nav-foot-name { color: #EDE9DF; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-foot-role { color: #72706A; font-size: 10.5px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }

/* Main */
.main { min-width: 0; display: flex; flex-direction: column; }

/* Top bar */
.topbar { height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--bg-canvas); position: sticky; top: 0; z-index: var(--z-sticky); }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); min-width: 0; }
.breadcrumb .sep { color: var(--ink-faint); font-family: var(--font-mono); font-size: 11px; }
.breadcrumb .cur { color: var(--ink); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-right .btn.icon { flex-shrink: 0; }
@media (max-width: 1280px) { .conn { max-width: 200px; overflow: hidden; text-overflow: ellipsis; } }

.conn { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--bg-paper); font-size: 11.5px; white-space: nowrap; flex-shrink: 0; font-family: var(--font-mono); color: var(--ink); cursor: pointer; }
.conn .dot-status { width: 7px; height: 7px; }
.conn[data-state="connected"] { color: var(--green-ink); border-color: color-mix(in oklab, var(--green) 30%, var(--line)); background: var(--green-faint); }
.conn[data-state="syncing"] { color: var(--amber-ink); border-color: color-mix(in oklab, var(--amber) 35%, var(--line)); background: var(--amber-faint); }
.conn[data-state="offline"] { color: var(--danger-ink); border-color: color-mix(in oklab, var(--danger) 30%, var(--line)); background: var(--danger-faint); }
@keyframes spin { to { transform: rotate(360deg); } }
.conn[data-state="syncing"] .spin { animation: spin 1.3s linear infinite; }

/* Page content */
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.page-head { padding: 20px 24px 14px; display: flex; align-items: flex-end; gap: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.page-head .eyebrow { order: 0; }
.page-head .page-title { order: 1; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.page-sub { color: var(--ink-muted); font-size: 13px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; }
.page-body { flex: 1; min-height: 0; overflow: auto; }

/* Toast */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: var(--z-toast); display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 280px; max-width: 360px; padding: 10px 12px; background: var(--bg-paper); border: 1px solid var(--line-strong); border-left: 3px solid var(--green); border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; animation: toastIn 260ms ease-out both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
.toast .toast-eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; color: var(--ink-muted); text-transform: uppercase; }
.toast .toast-msg { line-height: 1.4; }
.toast.amber { border-left-color: var(--amber); }
.toast.danger { border-left-color: var(--danger); }

/* ───────────────────── Dashboard ───────────────────── */
.dash { display: grid; grid-template-columns: var(--rail-w-left) 1fr; gap: 0; height: calc(100vh - var(--header-h)); min-height: 0; }
.dash-center { display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--line); }
.dash-rail { display: flex; flex-direction: column; min-width: 0; background: var(--bg-card); overflow: hidden; }
.dash-rail-section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dash-rail-section h4 { display: flex; align-items: center; gap: 8px; font-size: 11px; font-family: var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); font-weight: 500; margin: 0 0 12px; }
.dash-rail-scroll { flex: 1; min-height: 0; overflow: auto; }

/* Status banner — primary glanceable answer above the roster */
.dash-banner {
  display: flex; align-items: center; gap: 0;
  height: 44px; padding: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.dash-banner .seg {
  flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; cursor: pointer; background: transparent; border: none; color: var(--ink);
  font-family: inherit; font-size: inherit; padding: 0 4px;
  border-right: 1px solid var(--line-faint);
  transition: background 100ms;
}
.dash-banner .seg:last-child { border-right: none; }
.dash-banner .seg:hover { background: var(--bg-paper); }
.dash-banner .seg .seg-num {
  font-size: 16px; font-weight: 500; letter-spacing: -0.02em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dash-banner .seg .seg-lbl {
  font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted);
  margin-top: 3px;
}
.dash-banner .seg.online .seg-num { color: var(--green-ink); }
.dash-banner .seg.idle   .seg-num { color: var(--amber-ink); }
.dash-banner .seg.offline .seg-num { color: var(--ink-muted); }
.dash-banner .seg[data-active="true"] { background: var(--bg-paper); box-shadow: inset 0 -2px 0 var(--ink); }

/* Map filter */
.mapfilters { padding: 10px 16px; display: flex; gap: 8px; border-bottom: 1px solid var(--line); background: var(--bg-canvas); align-items: center; flex-wrap: wrap; }
.mapfilters .chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); background: var(--bg-paper); border-radius: var(--r-pill); font-size: 12px; color: var(--ink); cursor: pointer; }
.mapfilters .chip.active { background: var(--ink); color: var(--ink-invert); border-color: var(--ink); }
.mapfilters .chip .chev { opacity: 0.6; }
.mapfilters .divider { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.mapfilters .muted { font-size: 11.5px; font-family: var(--font-mono); color: var(--ink-muted); letter-spacing: 0.04em; }

/* Map */
.map-wrap { flex: 1; position: relative; background: #E8E3D6; overflow: hidden; }
.map-svg { width: 100%; height: 100%; display: block; }
.map-legend { position: absolute; bottom: 14px; left: 14px; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-md); font-size: 11.5px; font-family: var(--font-mono); box-shadow: var(--shadow-1); }
.map-legend .row { display: flex; align-items: center; gap: 8px; }
.map-ctl { position: absolute; bottom: 14px; right: 14px; display: flex; flex-direction: column; background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-1); }
.map-ctl button { width: 32px; height: 32px; background: transparent; border: none; border-bottom: 1px solid var(--line); display: grid; place-items: center; color: var(--ink); cursor: pointer; }
.map-ctl button:last-child { border-bottom: none; }
.map-ctl button:hover { background: var(--bg-card); }

.map-hud { position: absolute; top: 14px; left: 14px; display: flex; gap: 8px; }
.map-hud .tile { background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 12px; font-size: 10px; font-family: var(--font-mono); box-shadow: var(--shadow-1); color: var(--ink-muted); }
.map-hud .tile { white-space: nowrap; letter-spacing: 0.06em; color: var(--ink-muted); text-transform: uppercase; min-width: 72px; }
.map-hud .tile .big { display: block; font-size: 17px; color: var(--ink); letter-spacing: -0.02em; text-transform: none; margin-top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Map markers */
@keyframes pingPulse { 0% { transform: scale(1); opacity: 0.45; } 70% { transform: scale(2.8); opacity: 0; } 100% { opacity: 0; } }
.mk-ping { transform-origin: center; transform-box: fill-box; animation: pingPulse 2.2s ease-out infinite; }

/* Marker tooltip */
.mk-tip { position: absolute; transform: translate(-50%, calc(-100% - 14px)); background: var(--bg-paper); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 10px 12px; min-width: 220px; box-shadow: var(--shadow-2); font-size: 12px; z-index: 10; }
.mk-tip:after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%) rotate(45deg); width: 10px; height: 10px; background: var(--bg-paper); border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.mk-tip .mk-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.mk-tip .mk-meta { color: var(--ink-muted); font-family: var(--font-mono); font-size: 11px; }
.mk-tip .mk-actions { display: flex; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.kpi .k-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 6px; }
.kpi .k-value { font-family: var(--font-mono); font-size: 22px; font-weight: 500; letter-spacing: -0.02em; line-height: 1; color: var(--ink); display: flex; align-items: baseline; gap: 4px; }
.kpi .k-of { font-size: 12px; color: var(--ink-faint); font-weight: 400; letter-spacing: 0; }
.kpi .k-spark { height: 20px; margin-top: 8px; }
.kpi .k-delta { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); margin-top: 4px; }
.kpi .k-delta.up { color: var(--green-ink); }
.kpi .k-delta.dn { color: var(--danger-ink); }
.kpi.wide { grid-column: span 2; }

/* Progress bar */
.bar { width: 100%; height: 4px; background: var(--line-faint); border-radius: var(--r-pill); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--green); border-radius: var(--r-pill); }
.bar.amber > span { background: var(--amber); }

/* Salesman list rail */
.sm-list { display: flex; flex-direction: column; }
.sm-row { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line-faint); cursor: pointer; border-left: 3px solid transparent; }
.sm-row:hover { background: var(--bg-paper); }
.sm-row[data-selected="true"] { background: var(--bg-paper); }
.sm-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 600; font-size: 13px; flex: 0 0 auto; position: relative; border: 2px solid var(--bg-paper); box-shadow: 0 0 0 1px var(--line); }
.sm-avatar .health-badge {
  position: absolute; right: -2px; bottom: -2px;
  width: 14px; height: 14px;
  display: grid; place-items: center;
  background: var(--bg-paper);
  border: 1.5px solid var(--bg-paper);
  border-radius: 50%;
}
.sm-body { flex: 1; min-width: 0; }
.sm-name { font-weight: 500; font-size: 13px; letter-spacing: -0.005em; display: flex; align-items: center; gap: 6px; min-width: 0; }
.sm-name .nm-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-kpis { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); letter-spacing: 0.02em; display: flex; gap: 8px; margin-top: 3px; }
.sm-kpis .kpi-cell { display: inline-flex; gap: 3px; align-items: baseline; }
.sm-kpis .kpi-cell .v { color: var(--ink); }
.sm-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); letter-spacing: 0.02em; display: flex; gap: 8px; margin-top: 2px; }
.sm-progress { display: flex; align-items: center; gap: 4px; }
.sm-tick { width: 10px; height: 2px; background: var(--line); border-radius: 2px; }
.sm-tick.done { background: var(--green); }

/* Avatar background colors (cycle by name hash via avClass()) */
.av-0 { background: #FAEBD9; color: #8A5120; }
.av-1 { background: #DDE5EE; color: #2C4862; }
.av-2 { background: #E3EEDF; color: #1F5622; }
.av-3 { background: #F4D9DA; color: #7A2A2F; }
.av-4 { background: #F0E2EE; color: #5B2A52; }
.av-5 { background: #DDEAE6; color: #1D4F44; }
.av-6 { background: #F2E5C9; color: #6B4D14; }
.av-7 { background: #E0E2EE; color: #2E3A5C; }

.alert-row { padding: 12px 0; border-bottom: 1px solid var(--line-faint); display: flex; gap: 10px; align-items: flex-start; }
.alert-row:last-child { border-bottom: none; }
.alert-row .dot-status { margin-top: 5px; flex: 0 0 auto; }
.alert-row .al-body { flex: 1; font-size: 12.5px; line-height: 1.4; }
.alert-row .al-rule { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); }
.alert-row .al-actions { display: flex; gap: 6px; margin-top: 6px; }

/* ───────────────────── Tables ───────────────────── */
.tbl-shell { padding: 0 24px 24px; }
.tbl-filters { display: flex; gap: 8px; padding: 14px 0; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); }
.tbl-results { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-muted); letter-spacing: 0.04em; margin-left: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-top: 14px; }
.tbl thead th { position: sticky; top: 0; background: var(--bg-card); text-align: left; padding: 10px 12px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.1em; color: var(--ink-muted); text-transform: uppercase; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; white-space: nowrap; }
.tbl thead th .sort { opacity: 0.35; margin-left: 4px; }
.tbl thead th[data-sort="asc"] .sort, .tbl thead th[data-sort="desc"] .sort { opacity: 1; color: var(--ink); }
.tbl tbody td { padding: 12px 12px; border-bottom: 1px solid var(--line-faint); font-size: 13px; vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background 100ms; }
.tbl tbody tr:hover { background: var(--bg-card); }
.tbl tbody tr[data-selected="true"] { background: var(--green-faint); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { color: var(--ink); }
.tbl .muted { color: var(--ink-muted); font-size: 12px; }

.tbl-pagination { display: flex; gap: 6px; justify-content: space-between; padding: 14px 0; font-size: 12px; color: var(--ink-muted); }
.pgn { display: inline-flex; gap: 2px; }
.pgn button { width: 26px; height: 26px; border: 1px solid var(--line); background: var(--bg-paper); border-radius: var(--r-xs); font-size: 12px; font-family: var(--font-mono); }
.pgn button.active { background: var(--ink); color: var(--ink-invert); border-color: var(--ink); }

/* Drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(17,17,18,0.3); z-index: var(--z-drawer); animation: overlayIn 180ms ease-out; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 94vw; background: var(--bg-canvas); border-left: 1px solid var(--line); box-shadow: var(--shadow-drawer); z-index: calc(var(--z-drawer) + 1); display: flex; flex-direction: column; animation: drawerIn 240ms cubic-bezier(.2,.7,.2,1); }
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; background: var(--bg-card); }
.drawer-body { flex: 1; overflow: auto; padding: 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; background: var(--bg-card); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(17,17,18,0.35); backdrop-filter: blur(2px); z-index: var(--z-modal); display: grid; place-items: center; animation: overlayIn 180ms ease-out; }
.modal { width: 600px; max-width: 94vw; max-height: 88vh; background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-modal); display: flex; flex-direction: column; animation: modalIn 220ms cubic-bezier(.2,.7,.2,1); }
@keyframes modalIn { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 20px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-faint); }
.modal-body { flex: 1; overflow: auto; padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-faint); display: flex; gap: 8px; justify-content: flex-end; }

/* Label + help text */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.field .help { font-size: 11.5px; color: var(--ink-faint); }

/* ───────────────────── Session Replay ───────────────────── */
.replay-grid { display: grid; grid-template-columns: 1fr 380px; grid-template-rows: 1fr auto; flex: 1; min-height: 0; }
.replay-map { grid-row: 1/3; position: relative; background: #E8E3D6; border-right: 1px solid var(--line); min-height: 0; }
.replay-rail { background: var(--bg-card); overflow: auto; border-bottom: 1px solid var(--line); }
.replay-timeline { background: var(--bg-card); border-top: 1px solid var(--line); padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.rp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--bg-paper); }
.rp-stat .lab { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em; color: var(--ink-muted); text-transform: uppercase; }
.rp-stat .val { font-family: var(--font-mono); font-size: 18px; letter-spacing: -0.02em; }

/* Phase D — split replay layout (KPI strip + map left + timeline rail right) */
.replay-grid-v2 {
  display: grid;
  grid-template-columns: 1fr var(--rail-w-right-replay);
  grid-template-rows: auto 1fr auto;
  flex: 1;
  min-height: 0;
}
.replay-grid-v2 .rp-kpi-strip { grid-column: 1 / 3; grid-row: 1; }
.replay-grid-v2 .replay-map   { grid-column: 1; grid-row: 2; border-right: 1px solid var(--line); }
.replay-grid-v2 .rp-rail      { grid-column: 2; grid-row: 2; }
.replay-grid-v2 .replay-timeline { grid-column: 1 / 3; grid-row: 3; }

.rp-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--line);
}
.rp-kpi-cell {
  padding: 10px 14px;
  border-right: 1px solid var(--line-faint);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rp-kpi-cell:last-child { border-right: none; }
.rp-kpi-lab {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em;
  color: var(--ink-muted); text-transform: uppercase;
}
.rp-kpi-val {
  font-family: var(--font-mono); font-size: 22px; font-weight: 500;
  letter-spacing: -0.02em; line-height: 1.05;
  color: var(--ink);
  display: flex; align-items: baseline; gap: 3px;
  font-variant-numeric: tabular-nums;
}
.rp-kpi-sub { font-size: 12px; color: var(--ink-faint); font-weight: 400; letter-spacing: 0; }

.rp-rail {
  background: var(--bg-card);
  display: flex; flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
}
.rp-rail-chips {
  display: flex; gap: 6px; padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-paper);
}
.rp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--bg-paper);
  border-radius: var(--r-pill);
  font-size: 12px; color: var(--ink); cursor: pointer;
  font-family: inherit;
}
.rp-chip:hover { background: var(--bg-card); }
.rp-chip.active { background: var(--ink); color: var(--ink-invert); border-color: var(--ink); }
.rp-chip-count {
  font-family: var(--font-mono); font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}
.rp-rail-scroll { flex: 1; min-height: 0; overflow: auto; padding: 8px 0; }
.rp-rail-empty { padding: 30px 16px; color: var(--ink-muted); font-size: 13px; text-align: center; }

.rp-card {
  margin: 4px 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-paper);
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
}
.rp-card:hover { background: var(--bg-card); border-color: var(--ink-faint); }
.rp-card.stop  { border-left: 3px solid var(--green); }
.rp-card.drive { border-left: 3px solid var(--info); }
.rp-card.gap   { border-left: 3px solid var(--danger); background: color-mix(in oklab, var(--danger) 6%, var(--bg-paper)); }
.rp-card.hero  { border-left: 3px solid var(--ink); padding: 14px 16px; margin: 8px 10px; }
.rp-card.long-dwell { padding: 16px 16px; }
.rp-card[data-active="true"] { background: var(--green-faint); border-color: var(--green); }

.rp-card-row {
  display: flex; align-items: center; gap: 8px;
}
.rp-card-icon {
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-size: 12px; font-weight: 600;
  flex: 0 0 22px;
}
.rp-card.stop  .rp-card-icon { background: var(--green-faint); color: var(--green-ink); }
.rp-card.drive .rp-card-icon { background: var(--info-faint);  color: var(--info); }
.rp-card.gap   .rp-card-icon { background: var(--danger-faint); color: var(--danger-ink); }
.rp-card.hero  .rp-card-icon { background: var(--bg-card); color: var(--ink); }
.rp-card-time  { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-muted); letter-spacing: 0.02em; flex: 0 0 auto; }
.rp-card-label { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; }
.rp-card-dur   { font-family: var(--font-mono); font-size: 12px; color: var(--ink); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.rp-card-detail{ margin-top: 4px; padding-left: 30px; }
.rp-card-meta  { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); letter-spacing: 0.02em; }

/* Collapsed-to-tick state for filter chip */
.rp-card.collapsed {
  margin: 0 10px;
  padding: 0;
  height: 12px;
  cursor: pointer;
  background: transparent;
  border: none;
  border-left: 3px solid var(--line-strong);
  border-radius: 0;
  position: relative;
  display: flex; align-items: center;
}
.rp-card.collapsed:hover { background: var(--bg-paper); border-left-color: var(--ink-faint); }
.rp-card.collapsed .rp-card-row,
.rp-card.collapsed .rp-card-detail { display: none; }
.rp-card.collapsed::before {
  content: ""; display: block; height: 1px; flex: 1;
  background: var(--line-faint); margin-left: 4px; margin-right: 4px;
}

/* Theme toggle position in replay header */
.page-head-actions .ds-theme-toggle { margin-right: 4px; }

.visit-pin { padding: 12px 18px; display: flex; gap: 10px; border-bottom: 1px solid var(--line-faint); cursor: pointer; align-items: flex-start; }
.visit-pin:hover { background: var(--bg-paper); }
.visit-pin .v-idx { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--ink-invert); font-family: var(--font-mono); font-size: 10px; display: grid; place-items: center; flex: 0 0 auto; margin-top: 1px; }
.visit-pin .v-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); margin-bottom: 2px; letter-spacing: 0.02em; }
.visit-pin .v-name { font-weight: 500; font-size: 13px; margin-bottom: 2px; }
.visit-pin .v-outcome { font-size: 12px; color: var(--ink-muted); }

/* Timeline scrubber */
.scrubber { position: relative; height: 36px; background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.scrubber .track { position: absolute; inset: 12px 10px; background: var(--line-faint); border-radius: var(--r-pill); }
.scrubber .filled { position: absolute; top: 12px; bottom: 12px; left: 10px; background: var(--green); border-radius: var(--r-pill); }
.scrubber .pin { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--bg-paper); border: 2px solid var(--green); transform: translate(-50%, -50%); box-shadow: 0 0 0 3px color-mix(in oklab, var(--green) 20%, transparent); }
.scrubber .vtick { position: absolute; top: 6px; width: 2px; height: 8px; background: var(--ink); border-radius: 2px; }
.scrubber .label-l, .scrubber .label-r { position: absolute; top: 100%; font-family: var(--font-mono); font-size: 10px; color: var(--ink-muted); margin-top: 4px; }
.scrubber .label-l { left: 0; }
.scrubber .label-r { right: 0; }
.playbar { display: flex; align-items: center; gap: 10px; }
.playbar .spd { margin-left: auto; display: flex; gap: 4px; }
.playbar .spd button { font-family: var(--font-mono); font-size: 10.5px; padding: 3px 8px; border: 1px solid var(--line); background: var(--bg-paper); border-radius: var(--r-xs); color: var(--ink-muted); }
.playbar .spd button.active { background: var(--ink); color: var(--ink-invert); border-color: var(--ink); }

/* ───────────────────── Form builder ───────────────────── */
.builder-grid { display: grid; grid-template-columns: 260px 1fr 340px; height: calc(100vh - var(--header-h)); }
.builder-pal { background: var(--bg-card); border-right: 1px solid var(--line); padding: 16px; overflow: auto; }
.builder-canvas { padding: 28px; background: var(--bg-sunken); overflow: auto; }
.builder-insp { background: var(--bg-card); border-left: 1px solid var(--line); padding: 18px; overflow: auto; }

.pal-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-md); cursor: grab; margin-bottom: 8px; transition: border-color 120ms; }
.pal-item:hover { border-color: var(--ink-faint); }
.pal-item .pi-ico { width: 26px; height: 26px; border-radius: 6px; background: var(--bg-card); display: grid; place-items: center; color: var(--ink-muted); }
.pal-item .pi-name { font-size: 13px; font-weight: 500; }
.pal-item .pi-desc { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint); letter-spacing: 0.02em; }

.canvas-frame { max-width: 640px; margin: 0 auto; background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow-1); }
.canvas-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line-faint); }
.fb-row { padding: 14px; border: 1px solid var(--line); background: var(--bg-paper); border-radius: var(--r-md); margin-bottom: 10px; cursor: pointer; position: relative; transition: border-color 120ms, box-shadow 120ms; }
.fb-row:hover { border-color: var(--ink-faint); }
.fb-row[data-active="true"] { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in oklab, var(--green) 15%, transparent); }
.fb-row .fb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fb-row .fb-idx { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); width: 18px; }
.fb-row .fb-grip { cursor: grab; color: var(--ink-faint); margin-left: auto; }
.fb-row .fb-label { font-weight: 500; font-size: 13px; }
.fb-row .fb-type { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); padding: 1px 6px; border: 1px solid var(--line); border-radius: 3px; }
.fb-row .fb-preview { padding: 8px 10px; border: 1px dashed var(--line); border-radius: var(--r-sm); background: var(--bg-card); color: var(--ink-faint); font-size: 12.5px; }
.fb-row .fb-nested { margin-top: 10px; padding-left: 14px; border-left: 2px solid var(--amber); }
.fb-row .fb-nested .fb-cond { font-family: var(--font-mono); font-size: 10.5px; color: var(--amber-ink); background: var(--amber-faint); padding: 3px 8px; border-radius: 3px; display: inline-block; margin-bottom: 8px; letter-spacing: 0.02em; }

.fb-add { padding: 14px; border: 1px dashed var(--line-strong); background: transparent; border-radius: var(--r-md); color: var(--ink-muted); cursor: pointer; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12.5px; }
.fb-add:hover { border-color: var(--ink-faint); color: var(--ink); background: var(--bg-paper); }

.insp-section { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line-faint); }
.insp-section:last-child { border-bottom: none; }
.insp-section h5 { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); margin: 0 0 10px; font-weight: 500; }

/* Phone preview */
.phone-frame { width: 300px; background: #111112; border-radius: 26px; padding: 8px; box-shadow: var(--shadow-2); }
.phone-screen { background: var(--bg-paper); border-radius: 20px; padding: 16px; min-height: 540px; }

/* ───────────────────── Pipeline / Kanban ───────────────────── */
.kanban { padding: 16px 24px 24px; display: flex; gap: 12px; overflow-x: auto; }
.kcol { flex: 0 0 280px; display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-md); max-height: calc(100vh - var(--header-h) - 110px); }
.kcol-head { padding: 12px; border-bottom: 1px solid var(--line-faint); display: flex; align-items: center; gap: 8px; }
.kcol-title { font-weight: 600; font-size: 13px; }
.kcol-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); padding: 1px 6px; border: 1px solid var(--line); border-radius: 3px; }
.kcol-amt { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
.kcol-body { padding: 10px; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: var(--bg-paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; cursor: grab; transition: border-color 120ms, box-shadow 120ms; }
.kcard:hover { border-color: var(--ink-faint); box-shadow: var(--shadow-1); }
.kcard.ghost { opacity: 0.5; }
.kcard .k-name { font-weight: 500; font-size: 13px; letter-spacing: -0.005em; margin-bottom: 2px; }
.kcard .k-acct { font-size: 11.5px; color: var(--ink-muted); margin-bottom: 10px; }
.kcard .k-amt { font-family: var(--font-mono); font-size: 16px; letter-spacing: -0.01em; }
.kcard .k-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-faint); }
.kcard .k-owner { display: flex; align-items: center; gap: 6px; }
.kcard .k-days { font-family: var(--font-mono); font-size: 10px; color: var(--ink-muted); letter-spacing: 0.04em; }

/* ───────────────────── Misc ───────────────────── */
.tab-row { display: flex; gap: 0; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg-canvas); }
.tab { height: 36px; padding: 0 14px; display: flex; align-items: center; font-size: 13px; color: var(--ink-muted); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab[data-active="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.tab-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint); margin-left: 6px; }

/* Avatar colors (deterministic palette) */
.av-0 { background: #C9D6C4; color: #2E5130; }
.av-1 { background: #E9D5B8; color: #7A4F1E; }
.av-2 { background: #D4C1B5; color: #59392A; }
.av-3 { background: #BCC8D0; color: #2F4958; }
.av-4 { background: #E2C7C5; color: #7A3741; }
.av-5 { background: #C7C3D6; color: #413E6E; }
.av-6 { background: #D3DCC7; color: #435A2B; }
.av-7 { background: #D9D2CA; color: #554A40; }

/* Section eyebrows inside wide content */
.section-eyebrow { padding: 20px 24px 10px; display: flex; align-items: baseline; gap: 10px; }
.section-eyebrow h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.section-eyebrow .num { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); letter-spacing: 0.1em; }

/* ───────────────────── Tweaks panel ───────────────────── */
.tw-panel { position: fixed; right: 16px; bottom: 16px; width: 280px; background: var(--bg-paper); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-modal); z-index: var(--z-toast); overflow: hidden; font-size: 13px; }
.tw-head { padding: 10px 12px; background: var(--bg-card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.tw-head h5 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); margin: 0; font-weight: 500; }
.tw-body { padding: 12px; display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow: auto; }
.tw-row label { display: block; font-size: 11px; color: var(--ink-muted); margin-bottom: 6px; font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.tw-seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.tw-seg button { flex: 1; height: 28px; border: none; background: var(--bg-paper); font-size: 12px; border-right: 1px solid var(--line); color: var(--ink); }
.tw-seg button:last-child { border-right: none; }
.tw-seg button.active { background: var(--ink); color: var(--ink-invert); }

/* Responsive */
@media (max-width: 1280px) {
  :root { --rail-w: 280px; }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: var(--nav-w-collapsed) 1fr; }
  .brand-name, .brand-sub, .nav-section-label, .nav-item-text, .nav-idx, .nav-foot-meta, .nav-search { display: none !important; }
  .nav-item { justify-content: center; padding: 0; width: 36px; height: 36px; margin: 0 auto; }
  .dash { grid-template-columns: 1fr; }
  .dash-rail { display: none; }
  .replay-grid { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
  .builder-pal, .builder-insp { display: none; }
}

/* Leaflet marker styling (Deputy Sniffer) */
.ds-leaf-mk { pointer-events: auto; }
.ds-leaf-mk .ds-leaf-label {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 600; font-size: 11px; color: var(--ink);
  padding: 1px 6px; background: #FFFDF9; border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.ds-leaf-mk .ds-leaf-avatar {
  position: absolute; top: -18px; left: -18px;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 12px;
  border: 2px solid #FFFDF9; box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  z-index: 1;
}
.ds-leaf-mk .ds-leaf-avatar .health-badge {
  position: absolute; right: -3px; bottom: -3px;
  width: 14px; height: 14px;
  display: grid; place-items: center;
  background: #FFFDF9;
  border: 1.5px solid #FFFDF9;
  border-radius: 50%;
}
/* Stale state — desaturate avatar */
.ds-leaf-mk[data-online="false"] .ds-leaf-avatar { opacity: 0.55; filter: grayscale(0.4); }
/* Backwards-compat: keep old .ds-leaf-dot for any legacy popup styling */
.ds-leaf-mk .ds-leaf-dot {
  position: absolute; top: -6px; left: -6px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #FFFDF9; box-shadow: 0 0 0 1px rgba(0,0,0,0.18);
  z-index: 1;
}
.ds-leaf-mk .ds-leaf-ping {
  position: absolute; inset: -4px; border-radius: 50%;
  opacity: 0.35; animation: ds-leaf-ping 1.6s ease-out infinite;
}
@keyframes ds-leaf-ping {
  0%   { transform: scale(0.6); opacity: 0.55; }
  100% { transform: scale(1.8); opacity: 0; }
}
.ds-leaf-mk .ds-leaf-ring {
  position: absolute; inset: -22px; border-radius: 50%;
  border: 2px solid var(--ink);
  pointer-events: none;
}
/* Popup styling to match tooltip look */
.ds-mk-popup { font-family: ui-sans-serif, system-ui, sans-serif; min-width: 220px; }
.ds-mk-popup .mk-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.ds-mk-popup .mk-meta { color: var(--ink-muted); font-family: var(--font-mono); font-size: 11px; }
.leaflet-popup-content-wrapper { border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.leaflet-container { background: #E8E3D6; font-family: ui-sans-serif, system-ui, sans-serif; }

/* Replay Leaflet map + route */
#ds-replay-map { position: absolute; inset: 0; background: #E8E3D6; }
.ds-replay-current {
  width: 14px; height: 14px; border-radius: 50%;
  background: #1a73e8; border: 2px solid #FFFDF9;
  box-shadow: 0 0 0 5px rgba(26,115,232,0.18);
}

/* Stay-zone tooltip labels — small pill that reads "12m" etc. We override
   Leaflet's built-in tooltip chrome (background, border, arrow) with our own
   pill styling. Bigger zones get progressively larger fonts. */
.leaflet-tooltip.zone-label {
  background: #FFFDF9;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 8px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  white-space: nowrap;
  pointer-events: none;
}
.leaflet-tooltip.zone-label.medium { font-size: 14px; padding: 3px 10px; }
.leaflet-tooltip.zone-label.large  { font-size: 17px; padding: 4px 12px; font-weight: 500; }
/* Hide the default arrow Leaflet renders alongside permanent tooltips. */
.leaflet-tooltip.zone-label::before { display: none; }

/* Replay legend — speed buckets in a stacked card. Inherits .map-legend. */
.replay-legend { z-index: 500; }
.replay-legend .speed-bucket .swatch {
  display: inline-block; width: 18px; height: 4px;
  border-radius: 2px;
}

/* Replay rail tweaks. */
.replay-rail { padding-bottom: 12px; }

/* Number input inside the replay sidebar. */
.replay-rail .input { font-family: var(--font-mono); }
