:root {
  --g3-primary: #1a2744;
  --g3-navy: #1a2744;
  --g3-navy-dark: #111b2e;
  --g3-navy-light: #243554;
  --g3-accent: #2d5f9e;
  --g3-accent-hover: #1e4a7f;
  --g3-bg: #f4f6f9;
  --g3-surface: #ffffff;
  --g3-border: #dce1e8;
  --g3-border-light: #e8ecf1;
  --g3-text: #1a2744;
  --g3-text-muted: #6b7b93;
  --g3-text-light: #8a9bb5;
  --g3-success: #2e7d32;
  --g3-danger: #c62828;
  --g3-warning: #f9a825;
  --g3-info: #0277bd;
  --g3-surface-tint-accent: #e7eef7;
  --g3-surface-tint-success: #eaf4ec;
  --g3-surface-tint-danger: #fcebeb;
  --g3-surface-tint-navy: #e8ecf1;
  --g3-radius: 4px;
  --g3-radius-md: 6px;
  --g3-radius-lg: 8px;
}

[x-cloak] {
  display: none !important;
}

html {
  font-size: 14px;
}

body.g3-body {
  background: var(--g3-bg);
  color: var(--g3-text);
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

.page-shell {
  flex: 1;
  padding: 1.5rem;
}

.g3-ai-chat {
  bottom: 1.25rem;
  position: fixed;
  right: 1.25rem;
  z-index: 1080;
}

.g3-ai-chat__launcher {
  align-items: center;
  background: linear-gradient(135deg, var(--g3-primary), var(--g3-accent));
  border: 0;
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(26, 39, 68, 0.24);
  color: #fff;
  display: flex;
  font-size: 1.35rem;
  height: 56px;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  width: 56px;
}

.g3-ai-chat__launcher:hover,
.g3-ai-chat__launcher:focus {
  box-shadow: 0 14px 32px rgba(26, 39, 68, 0.32);
  transform: translateY(-1px);
}

.g3-ai-chat__panel {
  background: var(--g3-surface);
  border: 1px solid var(--g3-border);
  border-radius: var(--g3-radius-lg);
  bottom: 4.5rem;
  box-shadow: 0 18px 48px rgba(26, 39, 68, 0.22);
  display: flex;
  flex-direction: column;
  max-height: min(620px, calc(100vh - 7rem));
  overflow: hidden;
  position: absolute;
  right: 0;
  width: min(380px, calc(100vw - 2.5rem));
}

.g3-ai-chat__header {
  align-items: center;
  background: var(--g3-primary);
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 0.9rem 1rem;
}

.g3-ai-chat__header strong,
.g3-ai-chat__header span {
  display: block;
}

.g3-ai-chat__header span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.75rem;
}

.g3-ai-chat__body {
  background: #f8fafc;
  flex: 1;
  min-height: 260px;
  overflow-y: auto;
  padding: 1rem;
}

.g3-ai-chat__message {
  display: flex;
  margin-bottom: 0.7rem;
}

.g3-ai-chat__message.is-user {
  justify-content: flex-end;
}

.g3-ai-chat__bubble {
  background: #fff;
  border: 1px solid var(--g3-border-light);
  border-radius: 14px;
  color: var(--g3-text);
  font-size: 0.875rem;
  line-height: 1.45;
  max-width: 86%;
  padding: 0.65rem 0.75rem;
  white-space: normal;
}

.g3-ai-chat__message.is-user .g3-ai-chat__bubble {
  background: var(--g3-accent);
  border-color: var(--g3-accent);
  color: #fff;
}

.g3-ai-chat__suggestions {
  border-top: 1px solid var(--g3-border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.7rem 0.8rem 0;
}

.g3-ai-chat__suggestions button {
  background: var(--g3-surface-tint-accent);
  border: 1px solid rgba(45, 95, 158, 0.2);
  border-radius: 999px;
  color: var(--g3-accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
}

.g3-ai-chat__form {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem;
}

.g3-ai-chat__bubble p,
.g3-ai-chat__bubble ul,
.g3-ai-chat__bubble ol,
.g3-ai-chat__bubble li,
.g3-ai-chat__bubble h1,
.g3-ai-chat__bubble h2,
.g3-ai-chat__bubble h3,
.g3-ai-chat__bubble h4,
.g3-ai-chat__bubble hr {
  margin: 0;
}

.g3-ai-chat__bubble p + p,
.g3-ai-chat__bubble p + ul,
.g3-ai-chat__bubble p + ol,
.g3-ai-chat__bubble ul + p,
.g3-ai-chat__bubble ol + p {
  margin-top: 0.1rem;
}

.g3-ai-chat__bubble ul,
.g3-ai-chat__bubble ol {
  padding-left: 1.1rem;
}

.g3-ai-chat__bubble li {
  line-height: 1.45;
}

.g3-ai-chat__bubble li + li {
  margin-top: 0.1rem;
}

.g3-ai-chat__bubble code {
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
  font-size: 0.82em;
  padding: 0.05rem 0.35rem;
}

.g3-ai-chat__message.is-user .g3-ai-chat__bubble code {
  background: rgba(255,255,255,0.18);
}

.g3-ai-chat__bubble strong {
  font-weight: 700;
}

.navbar-g3 {
  background: var(--g3-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-block: 0.5rem;
}

.navbar-g3 .navbar-brand {
  align-items: center;
  color: #fff;
  display: flex;
  gap: 0.75rem;
}

.navbar-g3 .brand-logo {
  height: 40px;
  width: auto;
}

.navbar-g3 .brand-title {
  display: block;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.navbar-g3 .brand-subtitle {
  color: rgba(255, 255, 255, 0.72);
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-transform: uppercase;
}

.navbar-g3 .nav-link {
  border-radius: var(--g3-radius);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  padding-inline: 0.75rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.navbar-g3 .nav-link:hover,
.navbar-g3 .nav-link:focus {
  background: var(--g3-navy-light);
  color: #fff;
}

.navbar-g3 .nav-link.active {
  background: var(--g3-navy-dark);
  color: #fff;
}

.navbar-g3 .warehouse-selector {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--g3-radius);
  font-size: 0.8125rem;
  padding-inline: 0.625rem;
}

.navbar-g3 .warehouse-selector:hover,
.navbar-g3 .warehouse-selector:focus {
  border-color: rgba(255, 255, 255, 0.4);
}

.navbar-g3 .warehouse-selector + .dropdown-menu {
  min-width: 220px;
}

.navbar-g3 .warehouse-selector + .dropdown-menu .dropdown-item.active,
.navbar-g3 .warehouse-selector + .dropdown-menu .dropdown-item:active {
  background: var(--g3-accent);
  color: #fff;
}

.navbar-g3 .warehouse-selector + .dropdown-menu form {
  margin: 0;
}

.navbar-g3 .warehouse-selector + .dropdown-menu .dropdown-item {
  font-size: 0.8125rem;
}

.page-title {
  color: var(--g3-text);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--g3-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 0;
}

.card-g3 {
  background: var(--g3-surface);
  border: 1px solid var(--g3-border);
  border-radius: var(--g3-radius-md);
  box-shadow: none;
  overflow: hidden;
}

.card-g3 .card-header {
  background: var(--g3-surface);
  border-bottom: 1px solid var(--g3-border-light);
  color: var(--g3-text);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 1.25rem;
}

.card-g3 .card-body {
  padding: 1.25rem;
}

.stat-card {
  align-items: center;
  background: var(--g3-surface);
  border: 1px solid var(--g3-border);
  border-radius: var(--g3-radius-md);
  display: flex;
  gap: 1rem;
  min-height: 90px;
  padding: 1.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  border-color: rgba(45, 95, 158, 0.45);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-icon {
  align-items: center;
  background: rgba(45, 95, 158, 0.1);
  border-radius: var(--g3-radius-lg);
  color: var(--g3-accent);
  display: flex;
  flex: 0 0 48px;
  font-size: 1.25rem;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.stat-icon.success {
  background: var(--g3-surface-tint-success);
  color: var(--g3-success);
}

.stat-icon.warning {
  background: rgba(249, 168, 37, 0.16);
  color: var(--g3-warning);
}

.stat-icon.info {
  background: rgba(2, 119, 189, 0.12);
  color: var(--g3-info);
}

.stat-icon.secondary {
  background: var(--g3-surface-tint-navy);
  color: var(--g3-navy);
}

.stat-icon.danger {
  background: var(--g3-surface-tint-danger);
  color: var(--g3-danger);
}

.stat-value {
  color: var(--g3-text);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-label {
  color: var(--g3-text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
}

.table-g3 {
  color: var(--g3-text);
  font-size: 0.8125rem;
  margin-bottom: 0;
}

.table-g3 thead th {
  background: var(--g3-bg);
  color: var(--g3-navy);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.625rem 0.875rem;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  z-index: 1;
}

.table-g3 tbody td {
  border-color: var(--g3-border-light);
  padding: 0.625rem 0.875rem;
}

.table-g3 tbody tr:hover {
  background: rgba(45, 95, 158, 0.03);
}

.table-g3 th:not(:last-child),
.table-g3 td:not(:last-child) {
  border-right: 1px solid rgba(0, 0, 0, 0.22);
}

.delivery-header-row {
  border-bottom: 1px solid var(--g3-border-light);
}

.delivery-header-cell {
  background-color: color-mix(in srgb, var(--g3-bg) 92%, var(--g3-navy) 8%) !important;
  color: var(--g3-navy);
  font-weight: 600;
  padding: 0.75rem 0.875rem !important;
}

.delivery-seq-badge {
  background: var(--g3-navy);
  color: #ffffff;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  font-weight: bold;
}

.delivery-recipient-name {
  font-size: 0.875rem;
  font-weight: 700;
}

.delivery-zone-badge {
  background: rgba(0, 0, 0, 0.05);
  color: var(--g3-text);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  transition: background-color 0.15s ease-in-out;
}

.delivery-zone-badge.cursor-pointer:hover {
  background: rgba(0, 0, 0, 0.1);
}

.invoice-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.invoice-items-row > td {
  background: color-mix(in srgb, var(--g3-bg) 78%, #ffffff 22%) !important;
  border-bottom: 1px solid var(--g3-border-light);
  padding: 0.75rem 1.25rem !important;
}

.invoice-items-row .table-g3 thead th {
  position: static;
  background: transparent !important;
  color: var(--g3-text-muted);
  border-bottom: 2px solid var(--g3-border-light);
  font-size: 0.7rem;
}

.dashboard-filters .form-control,
.dashboard-filters .form-select {
  font-size: 0.8125rem;
  height: 36px;
}

.search-input {
  min-width: 220px;
}

.compact-filter {
  width: 120px;
}

/* ── Filter bar controls ─────────────────────────────────────────────── */
.filter-dropdown {
  max-width: 160px;
}

.filter-compact {
  width: 130px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--g3-border-light);
  color: var(--g3-text-muted);
  font-size: 0.8125rem;
}
.btn-ghost:hover {
  background: rgba(45, 95, 158, 0.06);
  color: var(--g3-navy);
}

.review-filter {
  align-items: center;
  color: var(--g3-text-muted);
  display: inline-flex;
  font-size: 0.8125rem;
  font-weight: 500;
  gap: 0.35rem;
  white-space: nowrap;
}

.route-link {
  color: var(--g3-accent);
  font-weight: 700;
  text-decoration: none;
}

.route-link:hover {
  color: var(--g3-accent-hover);
  text-decoration: underline;
}

.code-chip {
  color: var(--g3-text);
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8125rem;
}

.badge-g3 {
  border: 1px solid transparent;
  border-radius: var(--g3-radius);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.3;
  padding: 0.2rem 0.45rem;
  text-transform: uppercase;
}

.badge-g3.completed,
.badge-g3.success {
  background: var(--g3-surface-tint-success);
  border-color: rgba(46, 125, 50, 0.25);
  color: var(--g3-success);
}

.badge-g3.in-process {
  background: var(--g3-surface-tint-accent);
  border-color: rgba(45, 95, 158, 0.25);
  color: var(--g3-accent);
}

.badge-g3.danger {
  background: var(--g3-surface-tint-danger);
  border-color: rgba(198, 40, 40, 0.25);
  color: var(--g3-danger);
}

.badge-g3.warning {
  background: rgba(249, 168, 37, 0.12);
  border-color: rgba(249, 168, 37, 0.25);
  color: #b25e00;
}

.badge-g3.other,
.badge-g3.neutral {
  background: var(--g3-bg);
  border-color: var(--g3-border-light);
  color: var(--g3-text-muted);
}

.traffic-light {
  border-radius: 9999px;
  display: inline-block;
  height: 12px;
  width: 12px;
}

.traffic-light.green {
  background: var(--g3-success);
}

.traffic-light.yellow {
  background: var(--g3-warning);
}

.traffic-light.red {
  background: var(--g3-danger);
}

.dashboard-table-footer {
  background: var(--g3-surface);
  border-top: 1px solid var(--g3-border-light);
  color: var(--g3-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
}

.table-panel .table-responsive {
  max-height: 560px;
  overflow: auto;
}

.breadcrumb-g3 .breadcrumb-item,
.breadcrumb-g3 .breadcrumb-item a {
  color: var(--g3-accent);
  font-size: 0.8125rem;
  text-decoration: none;
}

.breadcrumb-g3 .breadcrumb-item.active {
  color: var(--g3-text-muted);
}

.footer-g3 {
  background: var(--g3-surface);
  border-top: 1px solid var(--g3-border-light);
  color: var(--g3-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding-block: 0.875rem;
}


.empty-state {
  color: var(--g3-text-muted);
  padding: 2rem 1rem;
  text-align: center;
}

.empty-state-icon {
  color: var(--g3-text-light);
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.form-label {
  color: var(--g3-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-control,
.form-select {
  border-color: var(--g3-border);
  border-radius: var(--g3-radius);
  color: var(--g3-text);
  min-height: 36px;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--g3-accent);
  box-shadow: 0 0 0 3px rgba(45, 95, 158, 0.1);
}

.form-check-input:checked {
  background-color: var(--g3-accent);
  border-color: var(--g3-accent);
}

.btn-primary {
  --bs-btn-bg: var(--g3-accent);
  --bs-btn-border-color: var(--g3-accent);
  --bs-btn-hover-bg: var(--g3-accent-hover);
  --bs-btn-hover-border-color: var(--g3-accent-hover);
  --bs-btn-border-radius: var(--g3-radius);
}

.htmx-indicator {
  opacity: 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.loader-bar {
  background: var(--g3-accent);
  height: 2px;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1080;
}

.progress-bar-g3 {
  background: var(--g3-accent);
  height: 2px;
  width: 100%;
}

/* Export button */
.btn-outline-g3 {
  border: 1px solid var(--g3-accent);
  color: var(--g3-accent);
  font-size: 0.8125rem;
  font-weight: 600;
}

.btn-outline-g3:hover {
  background: var(--g3-accent);
  color: #fff;
}

/* Pagination */
.pagination .page-link {
  border: 1px solid var(--g3-border-light);
  color: var(--g3-accent);
  font-size: 0.8125rem;
  font-weight: 500;
}

.pagination .page-item.active .page-link {
  background: var(--g3-accent);
  border-color: var(--g3-accent);
  color: #fff;
}

.pagination .page-item .page-link:hover {
  background: var(--g3-surface-tint-accent);
}

/* Route filters */
.route-filters .form-control,
.route-filters .form-select {
  font-size: 0.8125rem;
  height: 36px;
}

.route-filters input[type="date"] {
  width: 140px;
}

/* Timeline */
.timeline-g3 {
  list-style: none;
  padding: 1rem 0;
  position: relative;
}

.timeline-g3::before {
  background: var(--g3-border-light);
  content: "";
  height: 100%;
  left: 18px;
  position: absolute;
  top: 0;
  width: 2px;
}

.timeline-item {
  padding-left: 44px;
  padding-right: 12px;
  position: relative;
  margin-bottom: 1.25rem;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  border-radius: 50%;
  height: 12px;
  left: 13px;
  position: absolute;
  top: 4px;
  width: 12px;
}

.timeline-marker.timeline-event-import { background: var(--g3-info); }
.timeline-marker.timeline-event-assignment { background: var(--g3-accent); }
.timeline-marker.timeline-event-manual_management { background: var(--g3-success); }
.timeline-marker.timeline-event-bot_interaction { background: var(--g3-success); }
.timeline-marker.timeline-event-status_change { background: var(--g3-warning); }
.timeline-marker.timeline-event-alert { background: var(--g3-danger); }
.timeline-marker.timeline-event-system { background: var(--g3-text-muted); }
.timeline-marker.more { background: transparent; border: 2px dashed var(--g3-border); }

.timeline-marker.latest::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: inherit;
  border: 2px solid rgba(46, 125, 50, .35);
  animation: statusBlink 1.45s ease-out infinite;
}

@keyframes statusBlink {
  0% { transform: scale(.7); opacity: .9; }
  70%, 100% { transform: scale(1.65); opacity: 0; }
}

.timeline-more {
  padding: 0.25rem 0;
}

.timeline-content {
  background: var(--g3-surface);
  border: 1px solid var(--g3-border-light);
  border-radius: var(--g3-radius-md);
  padding: 0.75rem 0.85rem;
}

.timeline-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.timeline-title {
  color: var(--g3-text);
  font-size: 0.875rem;
  font-weight: 600;
}

.timeline-time {
  color: var(--g3-text-muted);
  font-size: 0.75rem;
}

.timeline-desc {
  color: var(--g3-text-muted);
  font-size: 0.8125rem;
  margin-bottom: 0.25rem;
}

.timeline-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.timeline-actor {
  color: var(--g3-accent);
  font-size: 0.75rem;
  font-weight: 500;
}

.timeline-source {
  color: var(--g3-text-light);
  font-size: 0.75rem;
}

/* ── G3 Toggle Switch ───────────────────────────────────────────────── */
.g3-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.g3-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.g3-toggle-track {
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: var(--g3-border);
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.g3-toggle input:checked ~ .g3-toggle-track {
  background: var(--g3-accent);
}
.g3-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.g3-toggle input:checked ~ .g3-toggle-track .g3-toggle-thumb {
  transform: translateX(14px);
}
.g3-toggle-label {
  font-size: 0.75rem;
  color: var(--g3-text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.date-presets-bar {
  font-size: 0.8125rem;
}

.date-preset-group .btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding-inline: 0.5rem;
}

.date-preset-sep {
  font-size: 0.75rem;
  white-space: nowrap;
}

/* =============================================================================
   Leaflet custom popup styling (global for all maps in G3)
   ============================================================================= */
.leaflet-popup-content-wrapper {
  border-radius: var(--g3-radius-md) !important;
  box-shadow: 0 10px 25px rgba(26, 39, 68, 0.15) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-family: inherit !important;
  font-size: 0.85rem !important;
  width: auto !important;
  min-width: 240px;
}

.leaflet-popup-card {
  padding: 12px;
}

.leaflet-popup-card .pop-header {
  border-bottom: 1px solid var(--g3-border-light);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.leaflet-popup-card .pop-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--g3-primary);
  margin-bottom: 4px;
  line-height: 1.25;
}

.leaflet-popup-card .pop-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leaflet-popup-card .pop-meta {
  font-size: 0.78rem;
  color: var(--g3-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.leaflet-popup-card .pop-meta-notes {
  font-size: 0.75rem;
  color: var(--g3-text-muted);
  background: var(--g3-bg);
  border-left: 3px solid var(--g3-accent);
  padding: 6px 8px;
  border-radius: 0 var(--g3-radius) var(--g3-radius) 0;
  margin-top: 6px;
  font-style: italic;
}

.leaflet-popup-card .contact-item {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: #f8fafc;
  border: 1px solid var(--g3-border-light);
  border-radius: var(--g3-radius);
  margin-top: 4px;
}

.leaflet-popup-card .contact-item a {
  color: var(--g3-accent);
  font-weight: 600;
}

.leaflet-popup-card .contact-item a:hover {
  color: var(--g3-accent-hover);
  text-decoration: underline;
}

.coordinate-link {
  color: var(--g3-success) !important;
  font-weight: 700;
  transition: color 0.15s ease-in-out, transform 0.15s ease-in-out;
  display: inline-flex;
  align-items: center;
}

.coordinate-link:hover {
  color: var(--g3-accent) !important;
  transform: translateY(-1px);
}

/* ── Dashboard view switcher & chart panels ─────────────────────────── */

.dashboard-view-switcher {
  align-items: center;
  background: var(--g3-bg);
  border: 1px solid var(--g3-border);
  border-radius: var(--g3-radius-md);
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
}

.switcher-tab {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--g3-radius);
  color: var(--g3-text-muted);
  display: inline-flex;
  font-size: 0.8125rem;
  font-weight: 600;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.switcher-tab:hover {
  color: var(--g3-text);
}

.switcher-tab.active {
  background: var(--g3-surface);
  box-shadow: 0 1px 2px rgba(26, 39, 68, 0.06);
  color: var(--g3-accent);
}

.switcher-arrow {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--g3-radius);
  color: var(--g3-text-muted);
  display: inline-flex;
  font-size: 0.75rem;
  justify-content: center;
  padding: 0.4rem 0.5rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.switcher-arrow:hover {
  background: rgba(45, 95, 158, 0.08);
  color: var(--g3-accent);
}

.dashboard-tab-pane {
  display: none;
}

.dashboard-tab-pane.active {
  display: block;
}

.chart-canvas-wrap {
  height: 320px !important;
  position: relative;
}

.dashboard-charts .card {
  height: 380px !important;
}

/* =============================================================================
   Workspace (client portal) — shared layout & components
   These classes are scoped to /workspace/* templates and intentionally avoid
   overriding any .tracking-* styles used by public_tracking.html.
   ============================================================================= */

.workspace-body {
  background: var(--g3-bg);
  color: var(--g3-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.workspace-shell {
  flex: 1;
  padding: 1.5rem;
  width: 100%;
}

@media (min-width: 992px) {
  .workspace-shell {
    padding: 2rem 2.5rem;
  }
}

/* Workspace navbar (extends .navbar-g3 with client-specific tweaks) */
.workspace-navbar {
  padding-block: 0.625rem;
}

.workspace-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
  margin-left: auto;
}

.workspace-action {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--g3-radius);
  color: rgba(255, 255, 255, 0.8);
  display: inline-flex;
  font-size: 0.8125rem;
  font-weight: 500;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.workspace-action:hover,
.workspace-action:focus {
  background: var(--g3-navy-light);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.workspace-action.active {
  background: var(--g3-navy-dark);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.workspace-action i {
  font-size: 1rem;
}

.workspace-navbar .workspace-client-selector {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--g3-radius);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8125rem;
  padding: 0.45rem 0.65rem;
}

.workspace-navbar .workspace-client-selector:hover,
.workspace-navbar .workspace-client-selector:focus {
  border-color: rgba(255, 255, 255, 0.42);
  color: #fff;
}

.workspace-navbar .workspace-logout {
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  padding: 0;
}

@media (max-width: 575.98px) {
  .workspace-navbar .container-fluid {
    flex-wrap: wrap;
  }

  .workspace-actions {
    justify-content: stretch;
    margin-left: 0;
    width: 100%;
  }

  .workspace-action {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
    padding: 0.5rem 0.35rem;
  }

  .workspace-action span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace-navbar .workspace-client-selector {
    flex: 0 0 auto;
    margin-right: auto;
  }
}

/* Hero */
.workspace-hero {
  background: linear-gradient(135deg, var(--g3-primary), var(--g3-navy-light) 62%, var(--g3-accent));
  border-radius: var(--g3-radius-lg);
  color: #fff;
  padding: clamp(28px, 5vw, 48px);
}

.workspace-eyebrow {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.84);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  gap: 8px;
  letter-spacing: 0.12em;
  padding: 6px 10px;
  text-transform: uppercase;
}

.workspace-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 18px 0 12px;
  max-width: 760px;
}

.workspace-subtitle {
  color: rgba(255, 255, 255, 0.76);
  font-size: 1.05rem;
  margin: 0;
  max-width: 620px;
}

.workspace-hero-compact {
  padding: clamp(22px, 4vw, 34px);
}

.workspace-hero-compact .workspace-title {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  margin: 12px 0 8px;
}

.workspace-hero-compact .workspace-subtitle {
  font-size: 0.95rem;
}

/* Filters */
.workspace-filters .form-label {
  margin-bottom: 0.25rem;
}

.workspace-filters .form-control,
.workspace-filters .form-select,
.workspace-filters .btn {
  font-size: 0.8125rem;
  min-height: 36px;
}

.workspace-filters .btn {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}

/* Client selector screen */
.workspace-client-selector-card {
  margin: 2rem auto 0;
  max-width: 920px;
}

.workspace-selector-logo {
  border-radius: var(--g3-radius-lg);
  height: 56px;
  width: auto;
}

.workspace-client-card {
  background-color: var(--g3-surface);
  border: 1px solid var(--g3-border);
  border-radius: var(--g3-radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.workspace-client-card:hover,
.workspace-client-card:focus {
  border-color: var(--g3-accent);
  box-shadow: 0 4px 12px rgba(45, 95, 158, 0.12);
  transform: translateY(-2px);
}

.workspace-client-card:focus {
  box-shadow: 0 0 0 0.25rem rgba(45, 95, 158, 0.15), 0 4px 12px rgba(45, 95, 158, 0.12);
  outline: 0;
}

.workspace-client-icon {
  color: var(--g3-accent);
  flex-shrink: 0;
}

/* Search */
.workspace-search-main {
  max-width: 760px;
  margin: 0 auto;
  padding-top: clamp(24px, 4vw, 48px);
  padding-bottom: clamp(24px, 4vw, 48px);
}

.workspace-search-card {
  padding: clamp(24px, 4vw, 40px);
}

.workspace-card-title {
  color: var(--g3-primary);
}

.workspace-search-form {
  align-items: center;
  background: var(--g3-surface);
  border: 1px solid var(--g3-border);
  border-radius: var(--g3-radius-lg);
  display: flex;
  gap: 10px;
  padding: 8px;
}

.workspace-search-form .form-control {
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 1.1rem;
  min-height: 46px;
}

.workspace-search-form .btn {
  white-space: nowrap;
}

.workspace-search-hint {
  color: var(--g3-text-muted);
  font-size: 0.875rem;
  margin-top: 1rem;
}

.workspace-search-notice {
  align-items: flex-start;
  background: var(--g3-surface-tint-danger);
  border: 1px solid rgba(198, 40, 40, 0.18);
  border-radius: var(--g3-radius-md);
  color: var(--g3-danger);
  display: flex;
  font-size: 0.9375rem;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.875rem 1rem;
}

.workspace-search-notice i {
  flex-shrink: 0;
  font-size: 1.15rem;
  margin-top: 1px;
}

@media (max-width: 576px) {
  .workspace-search-form {
    flex-direction: column;
    align-items: stretch;
  }
  .workspace-search-form .btn {
    width: 100%;
  }
}
