:root {
  --ink:        #1A2332;
  --ink2:       #46556B;
  --ink3:       #7B8AA0;
  --line:       #E2E6EC;
  --line2:      #EEF1F5;
  --surface:    #FFFFFF;
  --surface2:   #F7F9FC;
  --surface3:   #EEF2F8;
  --brand:      #1D4ED8;
  --brand-soft: #EAF1FE;
  --befriend:   #D97A1F;
  --befriend-bg:#FCF1E1;
  --high-risk:  #D63A3A;
  --high-risk-bg:#FCE9E9;
  --sgo:        #2F8F4E;
  --sgo-bg:     #E5F2E9;
  --ok:         #2F8F4E;
  --warn:       #D9931F;
  --map-bg:     #EFEAE0;
  --font: 'Inter Tight', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface2);
  font-feature-settings: "ss01" on;
  min-width: 1440px;
}
button { font-family: inherit; cursor: pointer; }

.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 18px;
}
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.brand .name { font-size: 14px; font-weight: 700; letter-spacing: -0.2px; }
.brand .role { font-size: 10px; color: var(--ink2); font-weight: 600; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
  font-size: 13px; font-weight: 500;
  color: var(--ink2);
  cursor: pointer;
}
.nav-item:hover { background: var(--surface2); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.active svg { stroke: var(--brand); }

.user-card {
  margin-top: auto;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface2);
  font-size: 11px;
  color: var(--ink2);
}
.user-card .name { font-weight: 700; color: var(--ink); font-size: 12px; }
.user-card .meta { margin-top: 2px; }

/* ── Main ───────────────────────────────────────────── */
.main { flex: 1; min-width: 0; overflow: auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 14px;
  border-bottom: 1px solid var(--line);
}
.topbar .label {
  font-size: 11px; font-weight: 700; color: var(--ink2);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.topbar h1 {
  font-size: 24px; font-weight: 700; letter-spacing: -0.5px;
  margin: 2px 0 0;
}
.topbar .actions { display: flex; gap: 10px; align-items: center; }

.search {
  width: 220px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px; color: var(--ink2);
  background: var(--surface);
}
.search input {
  border: 0; outline: 0;
  background: transparent;
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}
.search input::placeholder { color: var(--ink2); }

.btn-primary {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { background: #1939A8; }

.btn-secondary {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--surface2); }

/* ── KPI ────────────────────────────────────────────── */
.kpi-grid {
  padding: 18px 28px 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.kpi .label { font-size: 11px; color: var(--ink2); font-weight: 600; line-height: 1.3; }
.kpi .row { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.kpi .value {
  font-size: 28px; font-weight: 700;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.kpi .delta { font-size: 11px; font-weight: 700; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--warn); }
.kpi .sub { font-size: 11px; color: var(--ink2); font-weight: 500; }

/* ── Content grid ──────────────────────────────────── */
.body-grid {
  padding: 8px 28px 28px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 14px; font-weight: 700; letter-spacing: -0.2px; margin: 0; }
.card-head .sub { font-size: 11px; color: var(--ink2); margin-top: 2px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.staff-pill {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 9px;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.2px;
}

.tabs {
  display: flex; gap: 4px;
  padding: 3px;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
}
.tab {
  padding: 4px 10px;
  border-radius: 4px;
  color: var(--ink2);
  cursor: pointer;
}
.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* ── Live map ──────────────────────────────────────── */
.map-wrap {
  height: 380px;
  position: relative;
  background: var(--map-bg);
  z-index: 0;
}
.map-wrap svg { display: block; }

/* Leaflet pin overrides */
.ch-pin {
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.ch-pin .dot {
  width: 26px; height: 26px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  position: relative;
  z-index: 1;
}
.ch-pin .pulse {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  animation: ch-pulse 1.6s ease-out infinite;
  z-index: 0;
}
@keyframes ch-pulse {
  0%   { transform: scale(0.7); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0;   }
}

.ch-origin { display: flex; align-items: center; justify-content: center; }
.ch-origin .origin-square {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--brand);
  border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.ch-staff {
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.ch-staff .staff-dot {
  width: 14px; height: 14px;
  border-radius: 7px;
  background: var(--brand);
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 3px rgba(29,78,216,0.25);
}
.ch-staff .staff-label {
  background: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px; font-weight: 600;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.ch-tooltip {
  background: #fff !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  padding: 6px 9px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}
.ch-tooltip:before { display: none !important; }

.legend {
  display: flex; gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink2);
  flex-wrap: wrap;
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item .swatch {
  width: 9px; height: 9px;
  border-radius: 5px;
  display: inline-block;
}

/* ── Sessions ──────────────────────────────────────── */
.sessions { }
.session {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background 80ms ease;
}
.session:first-child { border-top: none; }
.session:hover { background: var(--surface2); }
.session.selected {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
.session-head { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px;
  border-radius: 15px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.session-meta { flex: 1; min-width: 0; }
.session-meta .name { font-size: 13px; font-weight: 600; color: var(--ink); letter-spacing: -0.1px; }
.session-meta .area { font-size: 11px; color: var(--ink2); margin-top: 1px; }
.session-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
}
.session-status .pip {
  width: 6px; height: 6px;
  border-radius: 3px;
}
.session-progress {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
}
.bar {
  flex: 1;
  height: 5px;
  border-radius: 2.5px;
  background: var(--line);
  overflow: hidden;
}
.bar > div { height: 100%; border-radius: 2.5px; }
.session-count {
  font-size: 11px; color: var(--ink2); font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 30px; text-align: right;
}

/* ── Heatmap card ──────────────────────────────────── */
.heatmap-card {
  margin: 0 28px 28px;
}
.heatmap-scale {
  display: flex; gap: 4px;
  font-size: 11px; color: var(--ink2);
  align-items: center;
}
.heatmap-scale .ramp {
  display: flex;
  height: 12px;
}
.heatmap-scale .ramp > div {
  width: 18px; height: 12px;
  background: var(--brand);
}
.heatmap-scale .ramp > div + div { border-left: 1px solid #fff; }

.heatmap-wrap {
  height: 360px;
  background: #FAF7F0;
  position: relative;
  z-index: 0;
}
.heatmap-tall { height: 540px; }
.heatmap-full { padding: 0 28px 28px; }

/* ── Page-shared ────────────────────────────────────── */
.page-body { padding: 0 28px 28px; }

.spacer { flex: 1; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--ink2);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.filter-bar label.grow { flex: 1; max-width: 320px; }
.filter-bar select,
.filter-bar input[type="text"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.filter-bar input[type="text"] { padding: 0 10px; }
.filter-bar select:focus,
.filter-bar input:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.filter-spacer { flex: 1; }
.filter-count {
  font-size: 11px;
  color: var(--ink2);
  font-weight: 600;
  align-self: flex-end;
  padding-bottom: 6px;
}

/* ── Data tables ────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line2);
  color: var(--ink);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .muted { color: var(--ink3); font-weight: 500; }

.avatar.avatar-sm {
  width: 22px; height: 22px;
  font-size: 9px;
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  margin-right: 4px;
  vertical-align: middle;
}

.lane-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.lane-chip svg { width: 11px; height: 11px; }

.rim-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rim-pill.rim-r1, .rim-pill.rim-r2 { background: var(--surface3); color: var(--ink2); }
.rim-pill.rim-r3 { background: var(--high-risk-bg); color: var(--high-risk); }
.rim-pill.rim-r4 { background: var(--high-risk); color: #fff; }

.lane-dots {
  display: inline-flex;
  gap: 3px;
}
.lane-dots .dot {
  width: 18px; height: 18px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}

.bar.mini { width: 80px; display: inline-flex; }

/* ── Reports ───────────────────────────────────────── */
.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.reports-grid .card.span-2 { grid-column: span 2; }

.trend-chart {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: end;
  padding: 18px 24px 12px;
  height: 280px;
}
.trend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}
.trend-stack {
  width: 64px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
}
.trend-stack .seg {
  width: 100%;
  border-bottom: 2px solid #fff;
}
.trend-stack .seg:first-child { border-bottom: none; }
.trend-label {
  font-size: 11px;
  color: var(--ink2);
  font-weight: 600;
}
.trend-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.trend-legend {
  display: flex;
  gap: 16px;
  padding: 10px 24px 18px;
  font-size: 11px;
  color: var(--ink2);
  font-weight: 500;
}
.trend-legend .swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 5px;
  margin-right: 4px;
}

.donut-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 24px 22px;
}
.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.donut-item {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 10px;
  align-items: center;
}
.donut-item .swatch {
  width: 10px; height: 10px; border-radius: 5px;
}
.donut-item .lbl { color: var(--ink); font-weight: 500; }
.donut-item .val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.donut-item .pct {
  font-size: 11px;
  color: var(--ink2);
  font-variant-numeric: tabular-nums;
}

.staff-mix {
  padding: 14px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mix-row {
  display: grid;
  grid-template-columns: 180px 1fr 36px;
  gap: 12px;
  align-items: center;
}
.mix-label {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.mix-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--line);
}
.mix-bar > div { height: 100%; }
.mix-total {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.blocks-list {
  padding: 14px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.block-row {
  display: grid;
  grid-template-columns: 1fr 80px 1fr 30px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.block-row .block-name b { color: var(--ink); }
.block-row .block-postal { font-size: 12px; }
.block-row .block-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.block-row .block-bar > div {
  height: 100%;
  background: var(--brand);
  border-radius: 4px;
}
.block-row .block-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
}

/* ── SVG strokes ───────────────────────────────────── */
.icon { width: 15px; height: 15px; flex-shrink: 0; }
.icon-sm { width: 13px; height: 13px; flex-shrink: 0; }
.icon-md { width: 14px; height: 14px; flex-shrink: 0; }
