/* ===========================================================================
   Waste Management System — design system
   Style: Linear / shadcn minimal — quiet slate palette, single emerald accent,
   logical properties so a Hebrew RTL toggle (dir="rtl") works without rewrites.
   =========================================================================== */

:root {
  /* Surfaces & lines */
  --bg:           #f7f8fa;
  --bg-subtle:    #f1f3f7;
  --surface:      #ffffff;
  --surface-2:    #fafbfc;
  --surface-3:    #f4f5f8;
  --border:       #e6e8ee;
  --border-light: #eef0f4;
  --border-strong:#d4d8e0;

  /* Text */
  --text:         #0b1220;
  --text-2:       #3f4858;
  --text-muted:   #6b7280;
  --text-faint:   #9aa3b2;

  /* Single accent — restrained emerald */
  --brand:        #059669;
  --brand-2:      #047857;
  --brand-3:      #065f46;
  --brand-light:  #ecfdf5;
  --brand-soft:   #d1fae5;

  /* Semantic */
  --danger:       #dc2626;
  --warn:         #d97706;
  --info:         #2563eb;

  /* Elevation — almost flat */
  --shadow-xs:    0 1px 0 rgba(15,23,42,0.03);
  --shadow-sm:    0 1px 2px rgba(15,23,42,0.04);
  --shadow:       0 1px 2px rgba(15,23,42,0.05);
  --shadow-md:    0 4px 12px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg:    0 12px 28px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.05);
  --shadow-xl:    0 24px 48px rgba(15,23,42,0.14), 0 6px 14px rgba(15,23,42,0.06);

  /* Radii — tight, square-ish */
  --radius-sm:    6px;
  --radius:       8px;
  --radius-md:    10px;
  --radius-lg:    12px;

  /* Sidebar metrics */
  --sidebar-w:    240px;
  --header-h:     56px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-feature-settings: "tnum" 1, "cv11" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
}

/* Content area gets a very subtle background — no dotted texture this time, the
   shadcn aesthetic prefers calm, flat surfaces. */
main > div:not(.app-header) {
  background: var(--bg);
}

/* ===========================================================================
   Cards
   =========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 1rem 1.125rem;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}
.card h3 {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
}

.card:has(.cursor-pointer):hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }

.card-divider {
  height: 1px;
  background: var(--border-light);
  margin: 0.75rem -1.125rem;
}

/* Section heading helper — sits inside a .card row */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}
.section-head h3 {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
}
.section-head .meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* ===========================================================================
   Badges  (quieter palette — same class names so JS keeps working)
   =========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  line-height: 1.5;
  white-space: nowrap;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge-green  { background:#ecfdf5; color:#047857; border-color:#a7f3d088; }
.badge-yellow { background:#fffbeb; color:#b45309; border-color:#fcd34d88; }
.badge-red    { background:#fef2f2; color:#b91c1c; border-color:#fca5a588; }
.badge-gray   { background:#f3f4f6; color:#4b5563; border-color:#d1d5db88; }
.badge-blue   { background:#eff6ff; color:#1d4ed8; border-color:#93c5fd88; }
.badge-orange { background:#fff7ed; color:#c2410c; border-color:#fdba7488; }
.badge-purple { background:#f5f3ff; color:#6d28d9; border-color:#c4b5fd88; }
.badge-pink   { background:#fdf2f8; color:#be185d; border-color:#f9a8d488; }

/* ===========================================================================
   Tables
   =========================================================================== */
table.dt {
  width: 100%;
  font-size: 0.8125rem;
  border-collapse: separate;
  border-spacing: 0;
}
table.dt thead th {
  text-align: start;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.dt thead th:first-child { border-start-start-radius: var(--radius-sm); }
table.dt thead th:last-child  { border-start-end-radius: var(--radius-sm); }
table.dt tbody td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text);
}
table.dt tbody tr:last-child td { border-bottom: none; }
table.dt tbody tr { transition: background-color 0.12s ease; }
table.dt tbody tr:hover { background: var(--surface-3); }
table.dt tbody tr.cursor-pointer:hover { background: var(--brand-light); }

/* ===========================================================================
   Progress / fill bar
   =========================================================================== */
.fill-bar {
  height: 5px;
  background: #eceef2;
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
  min-width: 60px;
}
.fill-bar-inner {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease-out;
}

/* ===========================================================================
   Map
   =========================================================================== */
#map { height: calc(100vh - 220px); min-height: 480px; border-radius: var(--radius); overflow: hidden; }

/* Leaflet polish — quieter chrome */
.leaflet-control-zoom a,
.leaflet-bar a {
  background: rgba(255,255,255,0.96);
  color: var(--text-2);
  border-color: rgba(15,23,42,0.08);
  backdrop-filter: blur(8px);
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.leaflet-control-zoom a:hover,
.leaflet-bar a:hover {
  background: #fff;
  color: var(--brand-2);
}
.leaflet-control-zoom,
.leaflet-control-layers {
  border-radius: 8px !important;
  overflow: hidden;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border) !important;
}
.leaflet-control-layers {
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(10px);
  padding: 4px;
}
.leaflet-control-layers-expanded {
  padding: 8px 12px !important;
  font-size: 12px;
  color: var(--text);
}
.leaflet-control-attribution {
  background: rgba(255,255,255,0.82) !important;
  backdrop-filter: blur(6px);
  font-size: 10px !important;
  color: var(--text-muted) !important;
  border-radius: 4px 0 0 0;
}
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.leaflet-popup-content { margin: 0; }

/* "Show all sensors" custom control — sits under the +/- zoom buttons with
   matching dimensions and the SVG icon centered. */
.wm-fit-control {
  margin-top: 10px !important;
  background: transparent;
}
.wm-fit-control a {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-2);
  border-radius: 8px !important;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border) !important;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.wm-fit-control a:hover {
  background: white;
  color: var(--brand);
  border-color: var(--brand) !important;
}
.wm-fit-control a svg {
  display: block;
}

.scrollx { overflow-x: auto; }

/* ===========================================================================
   Form controls
   =========================================================================== */
select, input[type=text], input[type=search], input[type=number],
input[type=date], input[type=file], input:not([type]), textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.6875rem;
  font-size: 0.8125rem;
  background: white;
  color: var(--text);
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
select { padding-inline-end: 1.75rem; }
select:hover, input:hover, textarea:hover {
  border-color: #b0b6c2;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

/* Search input — small leading icon */
input[type=search] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.5rem center;
  background-size: 14px 14px;
  padding-inline-start: 1.875rem;
}
[dir="rtl"] input[type=search] {
  background-position: calc(100% - 0.5rem) center;
}

label { font-size: 0.6875rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.01em; }

/* ===========================================================================
   Buttons
   =========================================================================== */
button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  user-select: none;
  white-space: nowrap;
}
button.btn:active, a.btn:active { transform: translateY(0.5px); }
button.btn:disabled, a.btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* Primary — flat emerald, not a gradient. Subtle inset highlight. */
button.btn-primary, a.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
button.btn-primary:hover, a.btn-primary:hover {
  background: var(--brand-2);
}

button.btn-secondary, a.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
button.btn-secondary:hover, a.btn-secondary:hover {
  background: var(--surface-3);
  border-color: #b0b6c2;
}

/* Ghost — even quieter, used for icon-only buttons */
button.btn-ghost, a.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
button.btn-ghost:hover, a.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

button.btn-danger, a.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: #fecaca;
}
button.btn-danger:hover, a.btn-danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

button.btn-sm, a.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.75rem; }
button.btn-icon, a.btn-icon { padding: 0.375rem; width: 2rem; height: 2rem; justify-content: center; }
button.btn-icon.btn-sm, a.btn-icon.btn-sm { width: 1.625rem; height: 1.625rem; }

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn.btn-sm svg { width: 12px; height: 12px; }

/* ===========================================================================
   KPI cards — refined: tiny accent dot at the start, no gradient header bar
   =========================================================================== */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.875rem 1rem 0.9375rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}
.kpi-card::before {
  /* Small leading accent stripe — coloured via currentColor on kpi-accent-* */
  content: '';
  position: absolute;
  inset-block: 0.875rem;
  inset-inline-start: 0;
  width: 2px;
  background: currentColor;
  opacity: 0.85;
  border-start-end-radius: 2px;
  border-end-end-radius: 2px;
}
.kpi-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.kpi-card .label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kpi-card .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
  margin-top: 0.375rem;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.kpi-card .sub {
  font-size: 0.6875rem;
  color: var(--text-faint);
  margin-top: 0.3125rem;
  font-weight: 500;
}

.kpi-accent-green  { color: #10b981; }
.kpi-accent-red    { color: #ef4444; }
.kpi-accent-yellow { color: #d97706; }
.kpi-accent-blue   { color: #2563eb; }
.kpi-accent-purple { color: #8b5cf6; }

/* ===========================================================================
   Live feed
   =========================================================================== */
.feed-row {
  display: flex;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  align-items: flex-start;
  font-size: 0.8125rem;
}
.feed-row:last-child { border-bottom: none; }
.feed-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  margin-block-start: 7px;
  flex-shrink: 0;
}

/* ===========================================================================
   Modal
   =========================================================================== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
  animation: modalFadeIn 0.18s ease-out;
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 10001;
  animation: modalSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ===========================================================================
   Sidebar — deep slate gradient with a luminous emerald accent rail.
   Creates contrast against the white content area while staying calm.
   =========================================================================== */
.sidebar {
  background:
    linear-gradient(180deg, #0f172a 0%, #111c34 55%, #0c1426 100%);
  color: #cbd5e1;
  position: relative;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04),
              4px 0 16px rgba(15, 23, 42, 0.05);
}
/* Hairline emerald glow up the leading edge — subtle but visible */
.sidebar::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 1px;
  background: linear-gradient(180deg,
    rgba(16, 185, 129, 0) 0%,
    rgba(16, 185, 129, 0.65) 18%,
    rgba(16, 185, 129, 0.65) 82%,
    rgba(16, 185, 129, 0) 100%);
  pointer-events: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3),
              0 0 0 1px rgba(16, 185, 129, 0.2),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
}
.sidebar-brand .logo img {
  /* The Rimonim "R" mark is white-on-transparent so it inherits the
     emerald square as its background. Tight 70% sizing leaves a small
     visual margin around the glyph. */
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
}
.sidebar-brand .brand-text {
  line-height: 1.2;
  min-width: 0;
}
.sidebar-brand .brand-text .top {
  font-size: 12.5px;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -0.005em;
  line-height: 1.25;
}
.sidebar-brand .brand-text .sub {
  font-size: 10px;
  color: #64748b;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Project picker — dark variant */
#project-picker {
  padding: 0.6875rem 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.18);
}
#project-picker .picker-label {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3125rem;
  padding-inline-start: 0.125rem;
  font-weight: 600;
}
#project-select {
  width: 100%;
  background: #1a2540;
  color: #f1f5f9;
  border: 1px solid #2a3654;
  border-radius: var(--radius-sm);
  padding: 0.4375rem 0.625rem;
  padding-inline-end: 1.75rem;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
#project-select:hover {
  background: #1f2c4a;
  border-color: #3a4870;
}
#project-select:focus {
  outline: none;
  background: #1f2c4a;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}
#project-select option {
  background: #15213d;
  color: #f1f5f9;
}
#project-current-label {
  font-size: 10px;
  color: #64748b;
  margin-top: 0.375rem;
  padding-inline-start: 0.125rem;
  letter-spacing: 0.01em;
}

/* Nav items */
.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding-block: 0.5rem;
}
.sidebar a.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1px 0.5rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  color: #94a3b8;
  line-height: 1.4;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
  position: relative;
}
.sidebar a.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}
.sidebar a.nav-item.active {
  background: linear-gradient(90deg,
    rgba(16, 185, 129, 0.18) 0%,
    rgba(16, 185, 129, 0.05) 100%);
  color: #ecfdf5;
  font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.18);
}
.sidebar a.nav-item.active::before {
  content: '';
  position: absolute;
  inset-block: 6px;
  inset-inline-start: -0.5rem;
  width: 3px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}
.sidebar a.nav-item.active .icon {
  color: #34d399;
}
.sidebar a.nav-item .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}
.sidebar a.nav-item:hover .icon { color: #cbd5e1; }
.sidebar a.nav-item .icon svg { width: 100%; height: 100%; }

.sidebar .nav-group-label {
  padding: 0.875rem 0.875rem 0.3125rem;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: #475569;
  text-transform: uppercase;
}
.sidebar .nav-group-label:first-child { padding-top: 0.5rem; }

.sidebar-footer {
  padding: 0.625rem 0.875rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 10px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}
.live-pulse {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: #cbd5e1;
}
.live-pulse .dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6), 0 0 0 0 rgba(16, 185, 129, 0.35); }
  50%      { opacity: 0.7; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6), 0 0 0 5px rgba(16, 185, 129, 0); }
}

/* Sidebar's own scrollbar — quieter against the dark background */
.sidebar *::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  background-clip: padding-box;
}
.sidebar *::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.18);
  background-clip: padding-box;
}

/* ===========================================================================
   App header
   =========================================================================== */
.app-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  position: relative;
  z-index: 10;
  min-height: var(--header-h);
}
.app-header h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.25;
}
.app-header .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.header-search {
  position: relative;
  width: 240px;
}
.header-search input {
  width: 100%;
  font-size: 12.5px;
  padding-block: 0.3125rem;
}
.header-search .kbd {
  position: absolute;
  inset-block: 50%;
  transform: translateY(-50%);
  inset-inline-end: 0.5rem;
  font-size: 10px;
  color: var(--text-faint);
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  font-family: ui-monospace, monospace;
  pointer-events: none;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .badge-dot {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 2px white;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-inline-start: 0.625rem;
  margin-inline-start: 0.25rem;
  border-inline-start: 1px solid var(--border);
  height: 32px;
}
.user-chip .avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-3) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.user-chip .who {
  line-height: 1.2;
  min-width: 0;
}
.user-chip .who .name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}
.user-chip .who .role {
  font-size: 10px;
  color: var(--text-muted);
}

/* ===========================================================================
   Utilities
   =========================================================================== */
.grid-tight { gap: 0.625rem; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.75rem;
  letter-spacing: -0.005em;
}

/* Inline SVG sizing helper */
.icon-14 { width: 14px; height: 14px; flex-shrink: 0; }
.icon-16 { width: 16px; height: 16px; flex-shrink: 0; }
.icon-18 { width: 18px; height: 18px; flex-shrink: 0; }

/* ===========================================================================
   Custom scrollbar
   =========================================================================== */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(15, 23, 42, 0.22); background-clip: padding-box; }

/* ===========================================================================
   Animation utilities
   =========================================================================== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.is-loading {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--surface-2) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 4px;
}

/* ===========================================================================
   Map page — toolbar, toggles, legend, popup
   (preserved; tightened to match the new system)
   =========================================================================== */
.bin-dot {
  border-radius: 9999px;
  border: 1.5px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.map-toolbar { padding: 0.75rem 1rem; }
.map-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  align-items: center;
}
.map-toolbar-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.map-toolbar-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border-light);
}
.map-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem 0.25rem 0.4rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
}
.map-toggle:hover {
  background: white;
  border-color: var(--border-strong);
}
.map-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: white;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  margin: 0;
}
.map-toggle input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.map-toggle input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/10px no-repeat;
}
.map-toggle:has(input:checked) {
  background: var(--brand-light);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--brand-2);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border-light);
}
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem 0.125rem 0.375rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.6875rem;
  color: var(--text-2);
  border: 1px solid var(--border-light);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  box-shadow: 0 0 0 1.5px white, 0 0 0 2.5px rgba(15,23,42,0.08);
}
.legend-square {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  box-shadow: 0 0 0 1.5px white, 0 0 0 2.5px rgba(15,23,42,0.08);
}
.legend-icon { font-size: 12px; line-height: 1; }
.legend-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 0.25rem;
}

/* Map popup — slightly refreshed */
.bp {
  min-width: 220px;
  max-width: 240px;
  padding: 10px 12px;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
}
.bp-header {
  padding-bottom: 6px;
  padding-inline-end: 22px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.bp-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  row-gap: 4px;
}

.leaflet-popup-close-button {
  top: 6px !important;
  inset-inline-end: 6px !important;
  width: 22px !important;
  height: 22px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.92) !important;
  color: var(--text-muted) !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  line-height: 20px !important;
  text-align: center !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  z-index: 10;
}
.leaflet-popup-close-button:hover {
  background: white !important;
  color: var(--danger) !important;
  border-color: #fca5a5 !important;
  text-decoration: none !important;
  transform: scale(1.05);
}
.bp-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.bp-address {
  font-size: 10.5px;
  color: var(--text-2);
  margin-top: 4px;
  line-height: 1.35;
}

.bp-section { margin-bottom: 6px; }
.bp-section:last-child { margin-bottom: 0; }
.bp-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.bp-section-label { display: block; margin-bottom: 4px; }

.bp-status-pill {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  line-height: 1.5;
  white-space: nowrap;
  flex-shrink: 0;
}

.bp-fill-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bp-fill-pct {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  min-width: 36px;
  line-height: 1;
}
.bp-fill-bar {
  flex: 1;
  height: 5px;
  background: #eceef2;
  border-radius: 999px;
  overflow: hidden;
}
.bp-fill-bar > div {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease-out;
}
.bp-fill-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
}

.bp-callout {
  padding: 5px 8px;
  border-radius: 5px;
  border-inline-start: 2.5px solid;
}
.bp-callout-blue   { background: #eff6ff; border-color: #3b82f6; }
.bp-callout-amber  { background: #fffbeb; border-color: #f59e0b; }
.bp-callout-green  { background: #ecfdf5; border-color: #10b981; }
.bp-callout-label {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}
.bp-callout-value {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.bp-callout-meta {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.bp-details {
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.bp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding: 1.5px 0;
}
.bp-row > span:first-child { color: var(--text-muted); }
.bp-row > span:last-child  { color: var(--text); font-weight: 500; text-align: end; }

.bp-pattern {
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.bp-pattern-loading {
  font-size: 10px;
  color: var(--text-faint);
  padding: 2px 0;
}
.bp-pattern-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.bp-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 5px;
}
.bp-stat-label {
  font-size: 8.5px;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.2;
}
.bp-stat-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.bp-stat-unit {
  font-size: 9px;
  color: var(--text-faint);
  font-weight: 500;
  margin-inline-start: 1px;
}

.bp-footer {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 6px;
}
.bp-link {
  font-size: 11px;
  font-weight: 500;
  color: var(--brand);
  text-decoration: none;
}
.bp-link:hover { text-decoration: underline; }

/* ---- Truck popup ("tp") ----------------------------------------------- */
.tp {
  min-width: 240px;
  max-width: 280px;
  padding: 14px 16px;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
}
.tp-header {
  /* Right padding reserves space so the Leaflet close (×) doesn't overlap */
  padding-bottom: 10px;
  padding-inline-end: 24px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.tp-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tp-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.tp-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.35;
}
.tp-live {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1.5px 8px;
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--brand-3);
  border: 1px solid var(--brand-soft);
  letter-spacing: 0.02em;
}
.tp-rows {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.tp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}
.tp-row > span:first-child {
  color: var(--text-muted);
  font-weight: 500;
}
.tp-row > span:last-child {
  color: var(--text);
  font-weight: 500;
  text-align: end;
}
.tp-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}
