/* ── Online user avatars ──────────────────────────────────────────────────── */
.online-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
  font: bold 10px Arial, sans-serif; color: #fff;
  cursor: default; position: relative;
}
.online-avatar::before {
  content: ''; position: absolute; bottom: 0; right: 0;
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e; border: 1.5px solid #1e3a5f;
}
.online-avatar[title]:hover::after {
  content: attr(title);
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff; font: 11px Arial,sans-serif;
  padding: 3px 7px; border-radius: 4px; white-space: nowrap; z-index: 999;
  pointer-events: none;
}

/* ── Truck moving pulse ───────────────────────────────────────────────────── */
@keyframes truck-pulse {
  0%   { box-shadow: 0 0 0 2px rgba(34,197,94,0.9), 0 0 8px 3px rgba(34,197,94,0.5); }
  50%  { box-shadow: 0 0 0 5px rgba(34,197,94,0.4), 0 0 16px 8px rgba(34,197,94,0.2); }
  100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.9), 0 0 8px 3px rgba(34,197,94,0.5); }
}
.truck-moving { animation: truck-pulse 1.4s ease-in-out infinite; }

/* ── Overdue pin pulse ───────────────────────────────────────────────────── */
@keyframes overdue-pulse {
  0%   { box-shadow: 0 0 0 2px rgba(239,68,68,0.9), 0 0 6px 2px rgba(239,68,68,0.6); }
  50%  { box-shadow: 0 0 0 6px rgba(239,68,68,0.3), 0 0 18px 8px rgba(239,68,68,0.2); }
  100% { box-shadow: 0 0 0 2px rgba(239,68,68,0.9), 0 0 6px 2px rgba(239,68,68,0.6); }
}
.overdue-pin { box-shadow: 0 0 0 2px rgba(239,68,68,0.9), 0 0 6px 2px rgba(239,68,68,0.6); }

@keyframes overdue-label-pulse {
  0%   { box-shadow: 0 0 4px 1px rgba(239,68,68,0.7); }
  50%  { box-shadow: 0 0 12px 5px rgba(239,68,68,0.3); }
  100% { box-shadow: 0 0 4px 1px rgba(239,68,68,0.7); }
}
.overdue-label { box-shadow: 0 0 4px 1px rgba(239,68,68,0.7); }

/* ── Overdue with Keys pin/label pulse (purple) ──────────────────────────── */
@keyframes overdue-keys-pulse {
  0%   { box-shadow: 0 0 0 2px rgba(168,85,247,0.9), 0 0 6px 2px rgba(168,85,247,0.6); }
  50%  { box-shadow: 0 0 0 6px rgba(168,85,247,0.3), 0 0 18px 8px rgba(168,85,247,0.2); }
  100% { box-shadow: 0 0 0 2px rgba(168,85,247,0.9), 0 0 6px 2px rgba(168,85,247,0.6); }
}
.overdue-with-keys-pin { box-shadow: 0 0 0 2px rgba(168,85,247,0.9), 0 0 6px 2px rgba(168,85,247,0.6); }

@keyframes overdue-keys-label-pulse {
  0%   { box-shadow: 0 0 4px 1px rgba(168,85,247,0.7); }
  50%  { box-shadow: 0 0 12px 5px rgba(168,85,247,0.3); }
  100% { box-shadow: 0 0 4px 1px rgba(168,85,247,0.7); }
}
.overdue-with-keys-label { box-shadow: 0 0 4px 1px rgba(168,85,247,0.7); }

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 360px;
  --header-h: 52px;
  --accent: #3B82F6;
  --accent-dark: #2563EB;
  --danger: #EF4444;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  height: var(--header-h);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  z-index: 100;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

header button {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
header button:hover { background: rgba(255,255,255,0.3); }

#refresh-status {
  font-size: 12px;
  opacity: 0.75;
  min-width: 160px;
  text-align: right;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100%;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar.hidden {
  transform: translateX(100%);
  width: 0;
  border: none;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.sidebar-tabs::-webkit-scrollbar {
  height: 3px;
}
.sidebar-tabs::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.tab-btn {
  flex: 0 0 auto;
  padding: 12px 10px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-btn:hover:not(.active) { background: var(--bg); }

.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.tab-panel.active {
  display: flex;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* ── Shop List ────────────────────────────────────────────────────────────── */
.shop-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 2px 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg);
}

.shop-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  grid-row: 1 / 4;
}

.shop-name {
  font-weight: 600;
  grid-column: 2;
  grid-row: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-address {
  font-size: 12px;
  color: var(--text-muted);
  grid-column: 2;
  grid-row: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Third row of sidebar entry rows — start/due chips. Wraps so long datetimes fit. */
.shop-meta {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.shop-actions {
  grid-column: 3;
  grid-row: 1 / 4;
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ── Add Shop Form ────────────────────────────────────────────────────────── */
.panel-form {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.panel-form h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-row {
  margin-bottom: 8px;
}

.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.form-row input[type=text],
.form-row input[type=email] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.form-row input:focus { border-color: var(--accent); }

.form-row-inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

input[type=color] {
  width: 36px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  background: none;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-full { width: 100%; }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}
.btn-icon:hover { background: var(--bg); }
.btn-edit:hover { border-color: var(--accent); color: var(--accent); }
.btn-delete:hover { border-color: var(--danger); color: var(--danger); }

/* ── Truck List ───────────────────────────────────────────────────────────── */
.truck-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--bg);
}

.truck-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.truck-name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
  background: var(--surface);
  cursor: pointer;
  max-width: 130px;
}
.shop-select:focus { outline: none; border-color: var(--accent); }

/* ── Add / count trucks ───────────────────────────────────────────────────── */
.add-truck-bar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.add-truck-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 13px;
  background: var(--surface);
}
.add-truck-input:focus { outline: none; border-color: var(--accent); }
.add-truck-bar .btn-sm { white-space: nowrap; }

.trucks-count {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #6B7280);
}

/* ── Error / Empty ────────────────────────────────────────────────────────── */
.error-msg {
  display: none;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--danger);
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}

.empty-msg {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

/* ── Trucks panel action bar ──────────────────────────────────────────────── */
.panel-actions {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Edit Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 380px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── Import bar ───────────────────────────────────────────────────────────── */
.import-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.import-status {
  font-size: 12px;
  color: var(--text-muted);
}

.template-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.template-link:hover { color: var(--accent); text-decoration: underline; }
.import-ok     { color: #059669; }
.import-partial { color: #D97706; }
.import-error  { color: var(--danger); }

/* ── Scheduled panel ─────────────────────────────────────────────────────── */
.scheduled-status {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: none;
}
.scheduled-status.warming {
  display: block;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}
.scheduled-status.ok {
  display: block;
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}
.scheduled-unmatched-hdr {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 0 4px;
}
.scheduled-unmatched-item {
  padding: 5px 10px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.dash-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.dash-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.dash-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.dash-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-card.danger {
  border-color: #FCA5A5;
  background: #FEF2F2;
}
.dash-card.danger .dash-value {
  color: var(--danger);
}

.dash-card.warn {
  border-color: #FDE68A;
  background: #FFFBEB;
}
.dash-card.warn .dash-value {
  color: #D97706;
}

.dash-activity {
  margin-top: 8px;
}

.dash-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Audit Log ───────────────────────────────────────────────────────────── */
.audit-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.audit-entry:last-child {
  border-bottom: none;
}

.audit-user {
  font-weight: 600;
  font-size: 12px;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.audit-action {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Help Modal ──────────────────────────────────────────────────────────── */
.help-modal {
  width: 500px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}
.help-modal h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.help-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
}
.help-close:hover { background: var(--bg); color: var(--text); }
.help-accordion {}
.help-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.help-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}
.help-section-header:hover { background: var(--border); }
.help-section-header .help-chevron {
  transition: transform 0.2s;
  font-size: 12px;
  color: var(--text-muted);
}
.help-section.open .help-chevron { transform: rotate(180deg); }
.help-section-body {
  display: none;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.help-section.open .help-section-body { display: block; }
.help-section-body ol,
.help-section-body ul {
  padding-left: 18px;
  margin: 6px 0;
}
.help-section-body li { margin-bottom: 4px; }
.help-section-body strong { color: var(--accent); }

/* ── Toast Notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: toast-in 0.3s ease-out;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.toast-success { background: #059669; color: #fff; }
.toast.toast-error   { background: #EF4444; color: #fff; }
.toast.toast-info    { background: #3B82F6; color: #fff; }
.toast.toast-out { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ── Search filter bar ───────────────────────────────────────────────────── */
.search-bar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-bar input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' 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") 10px center no-repeat;
  transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--accent); }

/* ── Tab count badges ────────────────────────────────────────────────────── */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  margin-left: 4px;
  line-height: 1;
}
/* Trucks count is informational, not an alert — use the accent color. */
.tab-badge-trucks { background: var(--accent); }

/* ── Clickable dashboard cards ───────────────────────────────────────────── */
.dash-card.clickable {
  cursor: pointer;
}

/* ── Clickable list items ────────────────────────────────────────────────── */
.shop-item.clickable {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.shop-item.clickable:hover {
  background: #EFF6FF;
  border-color: var(--accent);
}

/* ── Help button in header ───────────────────────────────────────────────── */
#help-btn {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}

/* ── Loading spinner ─────────────────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Info windows ─────────────────────────────────────────────────────────── */
.info-window {
  font-size: 13px;
  line-height: 1.6;
  min-width: 160px;
}

/* ── Mobile Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --header-h: 46px;
    --sidebar-w: 100vw;
  }

  header {
    padding: 0 10px;
    gap: 8px;
  }
  header h1 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #refresh-status {
    display: none;
  }

  /* Sidebar becomes full-screen overlay on mobile */
  .app-body {
    position: relative;
  }
  .sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 500;
    border-left: none;
  }
  .sidebar.hidden {
    transform: translateX(100%);
    width: 100%;
  }

  /* Close button visible on mobile */
  .sidebar-close-btn {
    display: flex !important;
  }

  /* Tabs scroll horizontally */
  .sidebar-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }
  .tab-btn {
    padding: 10px 10px;
    font-size: 12px;
    white-space: nowrap;
    flex: 0 0 auto;
  }

  /* Import bar wraps on small screens */
  .import-bar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
  }

  /* Larger touch targets */
  .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .btn-sm {
    padding: 7px 12px;
    font-size: 12px;
  }
  .btn {
    padding: 10px 16px;
  }

  /* Form inputs bigger for touch */
  .form-row input[type=text],
  .form-row input[type=email],
  .form-row input[type=password] {
    padding: 10px 12px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .form-row select {
    padding: 10px 12px;
    font-size: 16px;
  }

  /* Shop / Job items stacked on mobile */
  .shop-item {
    grid-template-columns: 18px 1fr;
    grid-template-rows: auto auto auto;
    padding: 12px 10px;
  }
  .shop-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
  }

  /* Truck items stack on small screens */
  .truck-item {
    flex-wrap: wrap;
  }
  .truck-item .shop-select {
    max-width: 100%;
    flex: 1 1 100%;
  }

  /* Modal full width on mobile */
  .modal {
    width: 95vw;
    padding: 18px;
  }

  /* Panel form more spacious */
  .panel-form {
    padding: 12px 10px;
  }

  /* Leaflet controls smaller on mobile */
  .leaflet-control-layers {
    font-size: 12px;
  }

  /* Scheduled unmatched items */
  .scheduled-unmatched-item {
    font-size: 13px;
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 13px;
  }
  #online-users {
    display: none !important;
  }
  #current-user {
    display: none !important;
  }

  /* Even more compact tabs */
  .tab-btn {
    padding: 10px 8px;
    font-size: 11px;
  }

  /* Stack form rows that are inline */
  .form-row-inline {
    flex-direction: column;
    gap: 8px;
  }

  /* Full-width buttons on very small screens */
  .import-bar .btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

/* ── Sidebar close button (hidden on desktop, shown on mobile) ──────────── */
.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
}
.sidebar-close-btn:hover {
  color: var(--text);
  background: var(--bg);
  border-radius: 6px;
}

/* Safe area padding for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .panel-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .panel-scroll {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ── Map legend (bottom-right) ─────────────────────────────────────────── */
.legend-ctrl {
  background: #fff;
  padding: 8px 10px 6px;
  font: 12px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1f2937;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  min-width: 140px;
}
.legend-ctrl .legend-title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 4px;
}
.legend-ctrl .legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
}
.legend-ctrl .legend-pin {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  outline: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.legend-ctrl .legend-cluster {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #10B981;
  color: #fff;
  font: bold 10px Arial, sans-serif;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
.legend-ctrl .legend-label {
  display: inline-block;
  background: #3B82F6;
  color: #fff;
  font: bold 9px Arial, sans-serif;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-ctrl .legend-truck {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #888888;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

/* Work-order names that open the work order in Striven (new tab) */
a.striven-link { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
a.striven-link:hover { color: #2563EB; border-bottom-style: solid; }

/* Trucks panel: one heading per shop */
.truck-group-hdr { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; padding-bottom: 3px;
  border-bottom: 1px solid var(--border, #e5e7eb); font: bold 12px Arial, sans-serif; color: #374151; }
.truck-group-hdr .truck-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.truck-group-hdr .truck-group-count { font-weight: normal; color: #6B7280; }
