@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-subtle: #eef0f4;
  --surface: #ffffff;
  --surface-hover: #fafbfc;
  --text: #0f1419;
  --text-secondary: #5c6578;
  --text-tertiary: #8b93a7;
  --accent: #5b5ef7;
  --accent-hover: #4f52e8;
  --accent-soft: rgba(91, 94, 247, 0.1);
  --accent-glow: rgba(91, 94, 247, 0.25);
  --success: #0d9f6e;
  --success-soft: rgba(13, 159, 110, 0.12);
  --warning: #e08b0c;
  --warning-soft: rgba(224, 139, 12, 0.12);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.12);
  --border: rgba(15, 20, 25, 0.08);
  --border-strong: rgba(15, 20, 25, 0.14);
  --ring: rgba(91, 94, 247, 0.35);
  --nav-h: 72px;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgba(15, 20, 25, 0.04);
  --shadow-sm: 0 2px 8px rgba(15, 20, 25, 0.06), 0 1px 2px rgba(15, 20, 25, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 20, 25, 0.08), 0 2px 6px rgba(15, 20, 25, 0.04);
  --shadow-lg: 0 20px 48px rgba(15, 20, 25, 0.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

/* ─── App shell ─── */
.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 80;
  padding: 20px 12px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 20px;
  margin-bottom: 8px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5b5ef7 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.03em;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: left;
}

.sidebar-nav button:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.sidebar-nav button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav button .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  display: flex;
  gap: 6px;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding-top: var(--safe-t);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

main.app-content {
  flex: 1;
  padding: 16px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel { display: none; animation: fadeIn 0.22s ease; }
.tab-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-header {
  margin-bottom: 16px;
}

.page-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  height: 36px;
  min-height: 44px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { transform: scale(0.98); }

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-xs {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 6px;
}

.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 14px;
  border-radius: var(--radius);
}

.btn-primary {
  background: linear-gradient(135deg, #5b5ef7 0%, #6d5ef7 50%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px var(--accent-glow);
  filter: brightness(1.03);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: rgba(15, 20, 25, 0.18);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13, 159, 110, 0.25);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(229, 72, 77, 0.2);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--border);
}

.btn-block { width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ─── Stats ─── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.stat-card--click {
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.stat-card--click:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.stat-card--click:active {
  transform: translateY(0);
}

.stat-card--click.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91, 94, 247, 0.18), var(--shadow-sm);
}

.stat-card--click.stat-overdue.active {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.18), var(--shadow-sm);
}

.stat-card--click.stat-urgent.active {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.22), var(--shadow-sm);
}

.stat-card--click.stat-photos.active {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.18), var(--shadow-sm);
}

.stat-card:hover { box-shadow: var(--shadow-sm); }

.stat-card .num {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #5b5ef7, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .lbl {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card.stat-urgent .num {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Forms ─── */
.input, .search-box,
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=password], input[type=search], select, textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus, .search-box:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filters-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

@media (min-width: 520px) {
  .filters-bar {
    grid-template-columns: 1.4fr 1fr 1fr;
  }
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 6px 0 0;
  line-height: 1.4;
}

/* ─── Cards ─── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-head .panel-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
}

.chart-box h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.chart-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ─── Tickets ─── */
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.ticket-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  border-radius: 3px 0 0 3px;
  transition: background var(--transition);
}

.ticket-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.ticket-card.overdue::before { background: var(--danger); }
.ticket-card.overdue { border-left-color: transparent; }
.ticket-card.done { opacity: 0.55; }
.ticket-card.done:hover { opacity: 0.72; }

.ticket-card .row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ticket-card .num {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.ticket-card .client {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.ticket-card .addr {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}

.ticket-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  font-weight: 500;
}

.ticket-card .meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ticket-card .meta-item.meta-urgent {
  color: #b45309;
  font-weight: 700;
}

/* ─── Card grids ─── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card-grid--tickets {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid--stock,
.card-grid--dense {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 520px) {
  .card-grid--tickets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-grid--stock { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .card-grid--tickets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-grid--stock { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-grid--dense { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.card-grid .empty-state {
  grid-column: 1 / -1;
  padding: 32px 16px;
}

.ticket-card--grid {
  margin-bottom: 0;
  padding: 12px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.ticket-card--grid.overdue {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(229, 72, 77, 0.15), var(--shadow-sm);
}

.ticket-card--grid.urgent {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25), var(--shadow-sm);
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.95) 0%, var(--surface) 100%);
}

.ticket-card--grid.urgent::before {
  background: #f59e0b;
  width: 4px;
}

.ticket-card--grid.in-plan {
  outline: 2px dashed rgba(91, 94, 247, 0.35);
  outline-offset: -4px;
}

.ticket-card--grid.overdue.urgent {
  border-color: var(--danger);
  background: var(--surface);
}

.ticket-card--grid.done {
  border-color: var(--border);
  opacity: 0.55;
}

.ticket-card--grid .addr {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  margin-top: 4px;
}

.ticket-card--grid .client { display: none; }

.ticket-card--grid .row-top { margin-bottom: 2px; }

.ticket-card--grid .meta {
  margin-top: auto;
  padding-top: 8px;
}

.ticket-card--grid .badge {
  font-size: 9px;
  padding: 2px 6px;
}

/* Stock / warehouse cards */
.stock-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 96px;
  display: flex;
  flex-direction: column;
}

.stock-card-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.stock-card-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.35;
  flex: 1;
}

.stock-card-qty {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.stock-card--pick {
  cursor: pointer;
  margin: 0;
}

.stock-card--pick input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.stock-card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  transition: all var(--transition);
}

.stock-card--pick:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stock-card--pick:has(input:checked) .stock-card-check {
  background: var(--accent);
  border-color: var(--accent);
}

.stock-card--pick:has(input:checked) .stock-card-check::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.stock-card--item {
  padding-right: 36px;
}

.stock-card-dir {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
}

.stock-card-dir--give { background: var(--accent-soft); color: var(--accent); }
.stock-card-dir--take { background: var(--success-soft); color: var(--success); }

.stock-card-del {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.stock-card-del:hover { color: var(--danger); }

.wh-stock-pick.card-grid {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 2px;
}

.badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-assigned { background: var(--warning-soft); color: #b45309; }
.badge-progress { background: var(--accent-soft); color: var(--accent); }
.badge-done { background: var(--success-soft); color: var(--success); }

/* ─── Segmented control ─── */
.seg-control {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 2px;
  margin-bottom: 14px;
}

.seg-control button, .doc-mode-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.seg-control button.active, .doc-mode-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.doc-mode-bar {
  display: inline-flex;
  width: 100%;
  max-width: 280px;
  padding: 3px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 2px;
  margin-bottom: 14px;
}

/* ─── Map ─── */
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  align-items: center;
}

.map-toolbar .map-toolbar-note {
  flex: 1;
  min-width: 120px;
  font-size: 12px;
  color: var(--text-tertiary);
}

#map-container {
  width: 100%;
  height: calc(100vh - var(--nav-h) - 200px);
  min-height: 300px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

#map-host { flex: 1; min-height: 240px; width: 100%; }
#map-host .leaflet-container {
  width: 100%;
  height: 100%;
  min-height: 240px;
  z-index: 1 !important;
}

.map-note { font-size: 12px; color: var(--text-tertiary); margin: 0 0 8px; }
.map-placeholder { min-height: 120px; }

.map-labeled-wrap { background: none !important; border: none !important; }
.map-pin {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  margin: 0 auto 2px;
}
.map-labeled { text-align: center; pointer-events: none; }
.map-label {
  font-size: 10px; font-weight: 600; color: #0f1419;
  background: rgba(255,255,255,.95);
  padding: 2px 6px; border-radius: 4px;
  max-width: 140px; margin: 0 auto;
  white-space: normal; line-height: 1.2;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
}

.map-review-box { margin-top: 14px; }
.map-review-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 200px; overflow-y: auto;
}
.map-review-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-subtle); border: 1px solid var(--border);
}

#pin-map {
  width: 100%; height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
#pin-map .leaflet-container { width: 100%; height: 100%; }

body.modal-open #map-container .leaflet-container { pointer-events: none; }

/* ─── Route ─── */
.route-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow-xs);
}

.route-step .order {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #5b5ef7, #8b5cf6);
  color: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

.route-step.home .order { background: var(--bg-subtle); font-size: 16px; }

.slider-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; font-size: 13px; color: var(--text-secondary);
}

.slider-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

/* ─── Stats dashboard ─── */
.stats-dashboard { display: flex; flex-direction: column; gap: 0; }

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  opacity: 0.7;
}

.kpi-card.kpi-warn::after { background: var(--danger); }
.kpi-card.kpi-ok::after { background: var(--success); }
.kpi-card.kpi-photo::after { background: #8b5cf6; }
.kpi-card.kpi-time::after { background: #0ea5e9; }

.kpi-card .kpi-val {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.kpi-card .kpi-lbl {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-weight: 500;
}

.stats-status-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 14px;
  align-items: center;
}

.chart-wrap { position: relative; width: 100%; overflow: hidden; }
.chart-wrap--donut { height: 180px; max-height: 180px; }
.chart-wrap--bar { height: 200px; max-height: 200px; }
.chart-wrap--hbar { height: min(280px, 36px * var(--city-rows, 6)); min-height: 160px; max-height: 280px; }
.chart-wrap canvas { display: block; width: 100% !important; height: 100% !important; }

.stats-legend {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}

.stats-legend li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 12px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stats-legend .legend-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stats-legend .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stats-legend .legend-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-legend .legend-val { font-weight: 700; flex-shrink: 0; }
.stats-legend .legend-pct { font-size: 11px; color: var(--text-tertiary); min-width: 32px; text-align: right; }

/* ─── Warehouse / docs ─── */
.wh-hint { font-size: 12px; color: var(--text-secondary); margin: 0 0 14px; line-height: 1.5; }
.wh-count { font-size: 12px; font-weight: 500; color: var(--text-tertiary); }
.wh-actions { flex-wrap: wrap; }
.wh-preview { font-size: 12px; color: var(--text-secondary); margin-top: 10px; min-height: 20px; line-height: 1.5; }
.wh-items { display: flex; flex-direction: column; gap: 6px; }
.wh-history { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.wh-hist-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.wh-hist-meta { font-size: 11px; color: var(--text-tertiary); margin-bottom: 4px; font-weight: 500; }
.wh-hist-summary { font-size: 13px; word-break: break-word; }
.wh-hist-detail { font-size: 12px; color: var(--text-secondary); margin-top: 6px; white-space: pre-wrap; max-height: 80px; overflow: hidden; }

.wh-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  transition: border-color var(--transition);
}

.wh-item:hover { border-color: var(--border-strong); }
.wh-item-main { flex: 1; min-width: 0; }
.wh-item-main b { display: block; margin-bottom: 2px; word-break: break-word; font-weight: 600; }
.wh-item-meta { color: var(--text-tertiary); font-size: 11px; }
.wh-item-del {
  background: none; border: none;
  color: var(--text-tertiary);
  font-size: 18px; cursor: pointer; padding: 0 4px;
  line-height: 1;
  transition: color var(--transition);
}
.wh-item-del:hover { color: var(--danger); }

.wh-stock-pick .wh-item { cursor: pointer; }
.wh-stock-pick label { display: flex; gap: 10px; align-items: flex-start; width: 100%; cursor: pointer; }
.wh-stock-pick input[type=checkbox] { margin-top: 3px; flex-shrink: 0; accent-color: var(--accent); }

/* ─── Receipts ─── */
.receipt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}

.receipt-card:hover { box-shadow: var(--shadow-sm); }
.receipt-card .amount { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ─── Bottom nav (mobile) ─── */
nav.bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 4px calc(8px + var(--safe-b));
  z-index: 60;
  max-width: 100%;
}

nav.bottom button {
  flex: 1;
  max-width: 72px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 6px 2px;
  cursor: pointer;
  transition: color var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

nav.bottom button .ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border-radius: 8px;
  font-size: 18px;
  transition: background var(--transition);
}

nav.bottom button.active {
  color: var(--accent);
  font-weight: 600;
}

nav.bottom button.active .ico {
  background: var(--accent-soft);
}

/* ─── Overlays ─── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.45);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.overlay.open { display: flex; animation: overlayIn 0.2s ease; }

@keyframes overlayIn {
  from { background: rgba(15, 20, 25, 0); }
  to { background: rgba(15, 20, 25, 0.45); }
}

.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow-y: auto;
  padding: 8px 20px 24px;
  padding-bottom: calc(24px + var(--safe-b));
  box-shadow: var(--shadow-lg);
  animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.sheet-header {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 8px 0 16px;
  margin-bottom: 4px;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}

.close-bar {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 99px;
  margin: 0 auto 14px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.sheet-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sheet-actions .btn { flex: 1; }

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.detail-block {
  font-size: 13px;
  white-space: pre-wrap;
  background: var(--bg-subtle);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.45;
  color: var(--text-secondary);
}

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.photo-list a {
  display: block;
  padding: 8px 0;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.photo-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.photo-upload-btn {
  cursor: pointer;
  margin: 0;
}

.photo-input-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.photo-list a {
  padding: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1;
  background: var(--bg-subtle);
}

.photo-list a img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.photo-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.photo-thumb-link {
  display: block;
  width: 100%;
  height: 100%;
}

/* Ticket picker (docs) */
.ticket-picker { position: relative; }

.picker-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 120;
}

.picker-dropdown.hidden { display: none; }

.picker-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.picker-item:last-child { border-bottom: none; }

.picker-item:hover, .picker-item:focus {
  background: var(--accent-soft);
  outline: none;
}

.picker-item b { display: block; color: var(--accent); font-size: 12px; margin-bottom: 2px; }

.picker-item span { color: var(--text-secondary); font-size: 12px; }

.picker-selected {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.picker-selected:empty { display: none; }

.offline-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--warning-soft);
  color: #b45309;
  padding: 4px 8px;
  border-radius: 999px;
  margin-right: 4px;
}

.offline-badge.hidden { display: none; }

.offline-queue-hint {
  color: var(--warning) !important;
  font-weight: 600;
}

/* ─── Plan bar (deadline planner) ─── */
.doc-common-actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.doc-common-actions .wh-hint {
  margin: 0 0 10px;
}

.plan-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-xs);
}

.plan-bar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.plan-bar-label {
  flex: 1;
  min-width: 140px;
}

.plan-bar-label strong {
  display: block;
  font-size: 13px;
}

.plan-bar-hint {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.plan-date-input {
  width: auto;
  min-width: 148px;
  flex: 0 0 auto;
}

.plan-summary {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.45;
}

.plan-summary b {
  font-size: 18px;
  color: var(--accent);
}

.plan-early-list {
  margin-top: 8px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.plan-early-head {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.ticket-card--grid.plan-early {
  outline: 2px dashed rgba(245, 158, 11, 0.45);
  outline-offset: -4px;
}

.plan-early-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.plan-early-item:last-child { border-bottom: none; }

.plan-early-item:hover { background: var(--surface-2); }

.plan-early-item .plan-num { font-weight: 700; white-space: nowrap; }

.plan-early-item .plan-addr {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-early-item .plan-due {
  color: #b45309;
  font-weight: 600;
  white-space: nowrap;
}

/* ─── QR scanner overlay ─── */
.qr-viewport { position: relative; }

.qr-scan-frame {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72vw, 280px);
  height: min(72vw, 280px);
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
}

.qr-scan-frame::before,
.qr-scan-frame::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
}

.qr-scan-frame::before {
  top: -2px;
  left: -2px;
  border-right: none;
  border-bottom: none;
  border-radius: 10px 0 0 0;
}

.qr-scan-frame::after {
  bottom: -2px;
  right: -2px;
  border-left: none;
  border-top: none;
  border-radius: 0 0 10px 0;
}

.qr-bottom {
  padding: 12px 14px calc(12px + var(--safe-b));
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
}

.qr-bottom .camera-hint {
  margin: 0 0 10px;
  font-size: 13px;
  opacity: 0.9;
}

@media (max-width: 520px) {
  .btn-sm { min-height: 44px; padding: 0 14px; }
  nav.bottom button { min-height: 48px; }
  .ticket-card--grid { min-height: 100px; }
}

.photo-list--links-only a {
  aspect-ratio: auto;
  padding: 8px 0;
  border: none;
  background: none;
}

/* ─── In-app camera (multi shot) ─── */
.overlay-camera {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: #000;
}

.overlay-camera.open {
  display: flex;
}

.camera-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  background: #0a0a0c;
  color: #fff;
}

.camera-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2;
}

.camera-close {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  font-size: 22px;
  width: 40px;
  height: 40px;
}

.camera-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.9;
}

.camera-count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.camera-viewport {
  position: relative;
  flex: 1;
  min-height: 40vh;
  background: #111;
  overflow: hidden;
}

.camera-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  transition: opacity 0.08s;
}

.camera-flash--on { opacity: 0.85; }

.camera-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: #fca5a5;
  background: rgba(0, 0, 0, 0.7);
}

.camera-shots {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  min-height: 76px;
  background: rgba(0, 0, 0, 0.85);
  scrollbar-width: none;
}

.camera-shots::-webkit-scrollbar { display: none; }

.camera-shot {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.camera-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-shot-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px 20px calc(16px + var(--safe-b));
  background: rgba(0, 0, 0, 0.9);
}

.camera-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: transparent;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.35);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s;
}

.camera-shutter:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.25);
}

.camera-controls .btn-primary {
  min-width: 140px;
  flex-shrink: 0;
}

.camera-hint {
  margin: 0;
  padding: 0 16px 12px;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.9);
}

@media (min-width: 900px) {
  .overlay-camera {
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.92);
  }

  .camera-shell {
    max-width: 480px;
    max-height: 92vh;
    border-radius: var(--radius-xl);
    overflow: hidden;
    min-height: 0;
  }
}

.photo-list a:hover { text-decoration: underline; }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.loading, .empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
}

.empty-state .big {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p { margin: 0; font-size: 14px; }

/* ─── Progress ─── */
.import-progress {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.import-progress.hidden { display: none; }

.import-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.import-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #5b5ef7, #8b5cf6);
  border-radius: 99px;
  transition: width 0.25s;
}

.geo-progress-detail, #import-progress-detail {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  min-height: 18px;
}

.map-load-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}

.map-load-panel.hidden { display: none; }

.map-load-panel #map-load-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.map-load-panel.map-load-indeterminate .import-progress-fill {
  width: 35% !important;
  animation: map-load-slide 1.2s ease-in-out infinite;
}

@keyframes map-load-slide {
  0% { margin-left: 0; }
  50% { margin-left: 65%; }
  100% { margin-left: 0; }
}

.server-stats {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 14px;
  font-size: 13px;
}

.server-stats h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.server-stats dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
}
.server-stats dt { color: var(--text-tertiary); font-size: 12px; }
.server-stats dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.field input[type=range] { width: 100%; accent-color: var(--accent); }

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border);
}

.leaflet-popup-content { margin: 12px 14px !important; font-family: var(--font) !important; font-size: 13px !important; }
.leaflet-popup-content .btn { margin-top: 8px; }

.map-popup-open, .map-popup-pin { width: 100%; }

/* ─── Login ─── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(91, 94, 247, 0.15), transparent),
    var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-box .brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-box h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-box .login-tagline {
  margin: 0 0 28px;
  color: var(--text-secondary);
  font-size: 14px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin-top: 12px;
  font-weight: 500;
}

.hidden { display: none !important; }

/* ─── Desktop ─── */
@media (min-width: 900px) {
  .sidebar { display: flex; }

  .app-main {
    margin-left: var(--sidebar-w);
    padding-bottom: 0;
  }

  nav.bottom { display: none; }

  .mobile-brand .topbar-title { display: none; }

  .mobile-brand { display: none; }

  .topbar::before {
    content: attr(data-page);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.025em;
  }

  main.app-content {
    padding: 24px 32px 32px;
    max-width: none;
  }

  .overlay {
    align-items: center;
    padding: 32px;
  }

  .sheet {
    max-width: 560px;
    border-radius: var(--radius-xl);
    max-height: 88vh;
    animation: sheetCenter 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }

  @keyframes sheetCenter {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: none; }
  }

  .toast {
    bottom: 32px;
  }

  #map-container {
    height: calc(100vh - var(--topbar-h) - 180px);
    min-height: 420px;
  }

  .stats-kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 360px) {
  .stats-status-layout { grid-template-columns: 1fr; }
  .chart-wrap--donut { height: 160px; max-height: 160px; }
  nav.bottom button { font-size: 9px; }
}
