/* ================================================================
   RouteOpt Dashboard Design System — UI-3 Production Visual Redesign
   ================================================================ */

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
  /* Primary */
  --color-primary: #2563EB;
  --color-primary-hover: #1D4ED8;
  --color-primary-light: #EFF6FF;
  --color-primary-bg: #DBEAFE;

  /* Semantic */
  --color-success: #16A34A;
  --color-success-light: #DCFCE7;
  --color-success-bg: #F0FDF4;
  --color-danger: #DC2626;
  --color-danger-light: #FEE2E2;
  --color-danger-bg: #FEF2F2;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-warning-bg: #FFFBEB;
  --color-info: #0EA5E9;
  --color-info-light: #E0F2FE;

  /* Neutrals */
  --color-bg-page: #F1F5F9;
  --color-bg-card: #FFFFFF;
  --color-bg-header: #FFFFFF;
  --color-border: #E2E8F0;
  --color-border-light: #F1F5F9;
  --color-text-primary: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-muted: #94A3B8;
  --color-text-inverse: #FFFFFF;

  /* Sidebar — dark navy */
  --sidebar-bg: #1E293B;
  --sidebar-bg-hover: #334155;
  --sidebar-bg-active: rgba(37, 99, 235, 0.15);
  --sidebar-text: #CBD5E1;
  --sidebar-text-active: #FFFFFF;
  --sidebar-section-label: #64748B;
  --sidebar-border: #334155;
  --sidebar-width: 250px;

  /* Layout */
  --header-height: 60px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  background: var(--color-bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }

/* ── App Layout Shell ──────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Sidebar (Dark Navy) ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
}

.sidebar__logo {
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-height);
  border-bottom: 1px solid var(--sidebar-border);
  color: #FFFFFF;
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sidebar__logo svg {
  color: var(--color-primary);
  flex-shrink: 0;
}

.sidebar__section {
  margin-bottom: var(--space-1);
}
.sidebar__section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-section-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-5) var(--space-1);
}

.sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-5);
  font-size: var(--font-size-base);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
  user-select: none;
  margin: 1px 0;
}
.sidebar__nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
}
.sidebar__nav-item--active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
  border-left-color: var(--color-primary);
}
.sidebar__nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.8;
}
.sidebar__nav-item--active svg { opacity: 1; }

.sidebar__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
  color: var(--sidebar-section-label);
}

.sidebar--collapsed { display: none; }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }

/* ── Main Content Area ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Top Header ────────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--color-bg-header);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
}
.top-header__left {
  display: flex; align-items: center; gap: var(--space-3);
}
.top-header__right {
  display: flex; align-items: center; gap: var(--space-3);
}

.page-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
}
.page-subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: -2px;
}

.sidebar-toggle {
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle:hover { background: var(--color-bg-page); color: var(--color-text-primary); }

/* ── Project Selector ──────────────────────────────────────────── */
.project-selector {
  display: flex; align-items: center; gap: var(--space-2);
}
.project-selector select {
  padding: 7px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-bg-card);
  min-width: 220px;
  cursor: pointer;
}
.project-selector select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

/* ── Page Content ──────────────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-6);
}

.tab-page { animation: fadeIn 0.2s ease; }
.tab-page.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Cards ─────────────────────────────────────────────────────── */
.dash-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}
.dash-card:last-child { margin-bottom: 0; }
.dash-card--no-mb { margin-bottom: 0; }

.dash-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.dash-card__title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

/* ── KPI Cards (with icon circles) ───────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (max-width: 1400px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-card__icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.kpi-card__icon--blue { background: var(--color-primary-bg); color: var(--color-primary); }
.kpi-card__icon--green { background: var(--color-success-light); color: var(--color-success); }
.kpi-card__icon--orange { background: var(--color-warning-light); color: #D97706; }
.kpi-card__icon--red { background: var(--color-danger-light); color: var(--color-danger); }
.kpi-card__icon--purple { background: #EDE9FE; color: #7C3AED; }

.kpi-card__body { flex: 1; min-width: 0; }
.kpi-card__label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}
.kpi-card__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}
.kpi-card__detail {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.kpi-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  font-size: var(--font-size-xs);
}
.kpi-card__trend--up { color: var(--color-success); }
.kpi-card__trend--down { color: var(--color-danger); }

/* Feasibility badge in KPI */
.kpi-feasibility-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: 0.03em;
}
.kpi-feasibility-badge--red { background: var(--color-danger); color: white; }
.kpi-feasibility-badge--yellow { background: var(--color-warning); color: white; }
.kpi-feasibility-badge--green { background: var(--color-success); color: white; }

/* ── Stat Bar (legacy inline mini stats) ─────────────────────── */
.summary-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-4); }
.stat {
  background: var(--color-bg-page);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--color-primary);
  min-width: 100px;
}
.stat .num { font-size: var(--font-size-lg); font-weight: 700; color: var(--color-text-primary); }
.stat .lbl { font-size: var(--font-size-xs); color: var(--color-text-secondary); margin-top: 2px; }

/* ── Grid Layouts ──────────────────────────────────────────────── */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.grid-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-5); }
.grid-4col { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.grid-60-40 { display: grid; grid-template-columns: 3fr 2fr; gap: var(--space-5); }
.grid-map-detail { display: grid; grid-template-columns: 1fr 360px; gap: var(--space-5); }

@media (max-width: 1200px) {
  .grid-2col, .grid-3col, .grid-60-40, .grid-map-detail { grid-template-columns: 1fr; }
  .grid-4col { grid-template-columns: 1fr 1fr; }
}

/* ── Tables ────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
}
.data-table thead th {
  background: var(--color-bg-page);
  padding: 10px var(--space-3);
  text-align: left;
  font-weight: 600;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 9px var(--space-3);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}
.data-table tbody tr:hover {
  background: #F8FAFC;
}
.data-table tbody tr.row--warning { background: var(--color-warning-light); }
.data-table tbody tr.row--danger { background: var(--color-danger-light); }
.data-table tbody tr.row--success { background: var(--color-success-light); }
.data-table tbody tr.row--highlight { background: var(--color-primary-light); }

/* ── Sortable Table Headers ────────────────────────────────────── */
.data-table th.th--sortable {
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}
.data-table th.th--sortable:hover {
  background: var(--color-border-light);
}
.data-table th .sort-arrow {
  display: inline-block;
  margin-left: 3px;
  font-size: 10px;
  opacity: 0.25;
  vertical-align: middle;
}
.data-table th.th--sort-asc .sort-arrow,
.data-table th.th--sort-desc .sort-arrow {
  opacity: 1;
  color: var(--color-primary);
}

/* ── Badges ────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-badge--success { background: var(--color-success-light); color: #15803D; }
.status-badge--danger { background: var(--color-danger-light); color: #B91C1C; }
.status-badge--warning { background: var(--color-warning-light); color: #B45309; }
.status-badge--info { background: var(--color-info-light); color: #0369A1; }
.status-badge--neutral { background: #F1F5F9; color: var(--color-text-secondary); }
.status-badge--red-solid,
.status-badge--danger-solid { background: var(--color-danger); color: white; }
.status-badge--green-solid,
.status-badge--success-solid { background: var(--color-success); color: white; }
.status-badge--yellow-solid,
.status-badge--warning-solid { background: var(--color-warning); color: white; }
.status-badge--primary { background: var(--color-primary-bg); color: var(--color-primary); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }

.btn--success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn--success:hover:not(:disabled) { background: #15803D; }

.btn--danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn--danger:hover:not(:disabled) { background: #B91C1C; }

.btn--warning { background: var(--color-warning); color: white; border-color: var(--color-warning); }

.btn--outline {
  background: white;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.btn--outline:hover:not(:disabled) {
  background: var(--color-bg-page);
  color: var(--color-text-primary);
  border-color: var(--color-text-muted);
}

.btn--ghost { background: transparent; color: var(--color-primary); border: none; padding: 6px 12px; }
.btn--ghost:hover:not(:disabled) { background: var(--color-primary-light); }

.btn--sm { padding: 5px 12px; font-size: var(--font-size-xs); }
.btn--lg { padding: 10px 24px; font-size: var(--font-size-md); }
.btn--block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Legacy btn-sm/btn-outline for existing code */
.btn-sm {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: var(--radius-md);
  font-size: var(--font-size-xs); font-weight: 600;
  font-family: var(--font-family); cursor: pointer;
  border: 1px solid var(--color-border); background: white;
  color: var(--color-text-secondary); transition: all var(--transition-fast);
}
.btn-sm:hover { background: var(--color-bg-page); }
.btn-outline { background: white; border-color: var(--color-border); color: var(--color-text-secondary); }

/* ── Forms ──────────────────────────────────────────────────────── */
.input-group { margin-bottom: var(--space-3); }
.input-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}
.input-group input,
.input-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-bg-card);
  transition: border-color var(--transition-fast);
}
.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.form-row {
  display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: flex-end;
}

/* Settings horizontal card row */
.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.settings-card {
  background: var(--color-bg-page);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
}
.settings-card__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}
.settings-card__value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text-primary);
}

/* ── Filter Bar ────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
}

/* Stat badges for filter bar (routing mode, cache hit, runtime) */
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  background: var(--color-bg-page);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}
.stat-badge svg { width: 14px; height: 14px; }
.stat-badge--success { background: var(--color-success-light); border-color: #BBF7D0; color: #15803D; }
.stat-badge--primary { background: var(--color-primary-bg); border-color: #93C5FD; color: var(--color-primary); }

/* ── Alert Boxes ───────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
}
.alert--success { background: var(--color-success-bg); color: #15803D; border-color: #BBF7D0; }
.alert--danger { background: var(--color-danger-bg); color: #B91C1C; border-color: #FECACA; }
.alert--warning { background: var(--color-warning-bg); color: #B45309; border-color: #FDE68A; }
.alert--info { background: var(--color-primary-light); color: var(--color-primary); border-color: var(--color-primary-bg); }
.alert.hidden { display: none; }

/* Tip bar (like reference blue bottom bar) */
.tip-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-bg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  margin-top: var(--space-4);
}
.tip-bar svg { flex-shrink: 0; width: 16px; height: 16px; }

/* ── Loading / Empty / Error States ────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
}
.loading-spinner::before {
  content: '';
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progress-shimmer {
  0%   { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

/* ── Progress Bar ───────────────────────────────────────────────── */
.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: var(--space-2) 0;
}
.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  transition: width var(--transition-normal, 0.2s ease);
}
.progress-bar-fill--indeterminate {
  width: 40% !important;
  background: linear-gradient(90deg, var(--color-primary) 25%, var(--color-primary-bg) 50%, var(--color-primary) 75%);
  background-size: 200px 100%;
  animation: progress-shimmer 1.4s linear infinite;
}
/* Shimmer that preserves the composed width (multi-step sequence bar) */
.progress-bar-fill--busy {
  min-width: 48px;
  background: linear-gradient(90deg, var(--color-primary) 25%, var(--color-primary-bg) 50%, var(--color-primary) 75%);
  background-size: 200px 100%;
  animation: progress-shimmer 1.4s linear infinite;
}
.progress-tracker { margin: var(--space-2) 0; }
.progress-tracker__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}
.progress-tracker__stage,
.progress-tracker__counter,
.progress-tracker__eta {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  min-height: 14px;
}

.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  color: var(--color-text-muted);
}
.empty-state__icon { font-size: 48px; margin-bottom: var(--space-3); opacity: 0.3; }
.empty-state__title { font-size: var(--font-size-lg); font-weight: 600; color: var(--color-text-secondary); margin-bottom: var(--space-2); }
.empty-state__desc { font-size: var(--font-size-sm); margin-bottom: var(--space-4); }

/* ── Chart Containers ──────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-container--sm { height: 200px; }
.chart-container--tall { height: 320px; }
.chart-container--lg { height: 350px; }

/* ── Map Containers ────────────────────────────────────────────── */
.map-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: #E8E8E8;
}

/* ── Route Detail Side Panel ─────────────────────────────────── */
.route-detail-panel {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  overflow-y: auto;
  max-height: 600px;
}
.route-detail-panel__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.route-detail-panel__body {
  padding: var(--space-4) var(--space-5);
}
.route-detail-panel__stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.route-detail-panel__stat {
  text-align: center;
  padding: var(--space-3);
  background: var(--color-bg-page);
  border-radius: var(--radius-md);
}
.route-detail-panel__stat-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}
.route-detail-panel__stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ── Stop Timeline ─────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline__item {
  position: relative;
  padding-bottom: var(--space-4);
  border-left: 2px solid var(--color-border);
  padding-left: var(--space-4);
  margin-left: -1px;
}
.timeline__item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline__dot {
  position: absolute;
  left: -10px; top: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-bg-card);
}
.timeline__dot--home { background: var(--color-info); }
.timeline__dot--overloaded { background: var(--color-danger); }
.timeline__dot--beyond-hours { background: #e67e22; }
.timeline__content { font-size: var(--font-size-sm); }
.timeline__title { font-weight: 600; color: var(--color-text-primary); }
.timeline__meta { color: var(--color-text-muted); font-size: var(--font-size-xs); }

/* ── Root Cause & Action Items ─────────────────────────────────── */
.root-cause-list { display: flex; flex-direction: column; gap: var(--space-3); }
.root-cause-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}
.root-cause-item--high { background: var(--color-danger-light); }
.root-cause-item--medium { background: var(--color-warning-light); }
.root-cause-item--low { background: var(--color-border-light); }
.root-cause-item__title { font-weight: 600; }
.root-cause-item__detail { color: var(--color-text-secondary); margin-top: 2px; }

.action-list { display: flex; flex-direction: column; gap: var(--space-3); }
.action-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}
.action-priority {
  width: 24px; height: 24px;
  background: var(--color-primary);
  color: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-xs); font-weight: 700; flex-shrink: 0;
}
.action-item__text { font-weight: 600; }
.action-item__rationale { color: var(--color-text-secondary); margin-top: 2px; }

/* ── Pill Buttons ──────────────────────────────────────────────── */
.pill-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  border: 2px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  transition: all var(--transition-fast);
  min-width: 48px;
}
.pill-btn:hover { background: var(--color-primary); color: white; }
.pill-btn--active { background: var(--color-primary); color: white; }

/* ── Feasibility Status ──────────────────────────────────────── */
.feasibility-red { background: var(--color-danger-light); color: #991B1B; }
.feasibility-yellow { background: var(--color-warning-light); color: #92400E; }
.feasibility-green { background: var(--color-success-light); color: #166534; }

/* Feasibility conclusion box */
.feasibility-conclusion-box {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  line-height: 1.6;
  margin-bottom: var(--space-4);
}
.feasibility-conclusion-box--red { background: var(--color-danger-bg); border-left: 4px solid var(--color-danger); }
.feasibility-conclusion-box--yellow { background: var(--color-warning-bg); border-left: 4px solid var(--color-warning); }
.feasibility-conclusion-box--green { background: var(--color-success-bg); border-left: 4px solid var(--color-success); }

/* ── Alerts Panel (for routes) ──────────────────────────────── */
.alerts-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.alert-card {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border-left: 4px solid transparent;
  font-size: var(--font-size-sm);
}
.alert-card--danger { background: var(--color-danger-bg); border-left-color: var(--color-danger); }
.alert-card--warning { background: var(--color-warning-bg); border-left-color: var(--color-warning); }
.alert-card--info { background: var(--color-primary-light); border-left-color: var(--color-primary); }
.alert-card__title { font-weight: 600; margin-bottom: 2px; }
.alert-card__text { color: var(--color-text-secondary); }

/* ── Scenario Table Enhancements ────────────────────────────── */
.scenario-recommended {
  background: var(--color-success-light) !important;
  outline: 2px solid var(--color-success);
  outline-offset: -2px;
}

/* ── Health Status Grid ────────────────────────────────────────── */
.health-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4);
}
.health-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  text-align: center;
  box-shadow: var(--shadow-card);
}
.health-card__icon { margin-bottom: var(--space-2); color: var(--color-text-secondary); }
.health-card__label { font-size: var(--font-size-xs); font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; }
.health-card__value { font-size: var(--font-size-md); font-weight: 600; margin-top: var(--space-2); color: var(--color-text-primary); }

/* ── Drop Zone ────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: var(--space-3);
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.04);
}
.drop-zone__icon { margin-bottom: var(--space-3); }
.drop-zone__text { font-size: var(--font-size-md); color: var(--color-text-primary); font-weight: 500; }
.drop-zone__hint { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: var(--space-2); }

/* ── Utility Classes ───────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ── Feasibility Cards (diagnostics) ─────────────────────────── */
.feasibility-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.feasibility-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  box-shadow: var(--shadow-card);
}
.feasibility-card .card-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-1);
}
.feasibility-card .card-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-1);
}
.feasibility-card .card-detail {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

/* ── Diagnostic Summary Items ────────────────────────────────── */
.summary-item {
  display: inline-flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  min-width: 80px;
}
.summary-item .label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}
.summary-item .value {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-text-primary);
}

/* ── Routes Action Bar ──────────────────────────────────────────── */
.routes-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
  gap: var(--space-3);
}
.routes-action-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.routes-action-bar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Routes KPI Grid (4 cards) ───────────────────────────────── */
.routes-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
@media (max-width: 1200px) { .routes-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .routes-kpi-grid { grid-template-columns: 1fr; } }

/* ── Alerts Panel ────────────────────────────────────────────── */
.alerts-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
  max-height: 300px;
  overflow-y: auto;
}

/* ── Routes Map Always-Visible ───────────────────────────────── */
#tab-routes .grid-map-detail {
  display: grid;
  margin-bottom: var(--space-4);
}
#route-map-empty {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--color-bg-page);
  border-radius: var(--radius-md);
}

/* ── Scrollbar Styling ─────────────────────────────────────────── */
.page-content::-webkit-scrollbar { width: 6px; }
.page-content::-webkit-scrollbar-track { background: transparent; }
.page-content::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
.page-content::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ── View More / Collapse for Tables ──────────────────────────── */
.table-view-more {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) 0;
  margin-top: var(--space-2);
}
.table-view-more__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}
.table-view-more__btn:hover {
  background: var(--color-bg-page);
  color: var(--color-text-primary);
  border-color: var(--color-text-muted);
}
.table-view-more__btn svg { width: 14px; height: 14px; transition: transform var(--transition-fast); }
.table-view-more__btn--expanded svg { transform: rotate(180deg); }

/* ── Scrollable Table Wrappers ───────────────────────────────── */
.table-scroll-wrap { overflow-x: auto; }
.table-scroll-wrap--sm { max-height: 350px; overflow-y: auto; }
.table-scroll-wrap--md { max-height: 400px; overflow-y: auto; }
.table-scroll-wrap--lg { max-height: 600px; overflow-y: auto; }

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ── Group Map Modal ─────────────────────────────────────────── */
.group-modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.group-modal-overlay.hidden { display: none !important; }

.group-modal {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90vw;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.group-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.group-modal__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}
.group-modal__close {
  background: none; border: none;
  font-size: 24px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  line-height: 1;
}
.group-modal__close:hover {
  background: var(--color-bg-page);
  color: var(--color-text-primary);
}
.group-modal__body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}
.group-modal__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.group-modal__stat {
  text-align: center;
  padding: var(--space-3);
  background: var(--color-bg-page);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
}
.group-modal__stat-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text-primary);
}
.group-modal__stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.group-link {
  cursor: pointer;
  color: var(--color-primary);
  font-weight: 600;
  transition: color var(--transition-fast);
  text-decoration: none;
}
.group-link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ── Chatbot Widget ────────────────────────────────────────────── */

.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 9998;
  transition: transform .15s, box-shadow .15s;
  user-select: none;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }

.chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 400px;
  height: 520px;
  background: var(--color-bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
}
.chat-panel--open { display: flex; }

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-primary);
  color: #fff;
  flex-shrink: 0;
}
.chat-panel__title { font-weight: 600; font-size: 14px; }
.chat-panel__actions { display: flex; gap: 4px; }
.chat-panel__btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
.chat-panel__btn:hover { background: rgba(255,255,255,.15); color: #fff; }

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg { display: flex; }
.chat-msg--user { justify-content: flex-end; }
.chat-msg--assistant { justify-content: flex-start; }
.chat-msg--system { justify-content: center; }

.chat-msg__content {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg--user .chat-msg__content {
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg--assistant .chat-msg__content {
  background: var(--color-bg-page);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}
.chat-msg--system .chat-msg__content {
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  font-style: italic;
}

.chat-panel__input-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--color-border);
  gap: 8px;
  flex-shrink: 0;
}
.chat-panel__input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  background: var(--color-bg-page);
  color: var(--color-text-primary);
}
.chat-panel__input:focus { border-color: var(--color-primary); }

.chat-panel__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.chat-panel__send:hover { background: var(--color-primary-hover); }
.chat-panel__send--stop { background: var(--color-danger); }
.chat-panel__send--stop:hover { background: #c0392b; }

/* Chat tables */
.chat-table {
  border-collapse: collapse;
  font-size: 11px;
  margin: 6px 0;
  width: 100%;
}
.chat-table th, .chat-table td {
  border: 1px solid var(--color-border);
  padding: 3px 6px;
  text-align: left;
}
.chat-table th {
  background: var(--color-bg-page);
  font-weight: 600;
}

/* Chat map previews */
.chat-map-preview {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin: 6px 0;
  cursor: pointer;
  transition: box-shadow .15s;
}
.chat-map-preview:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.chat-map-preview__map {
  height: 180px;
  background: #eee;
}
.chat-map-preview__label {
  padding: 4px 8px;
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  background: var(--color-bg-page);
}

/* Chat map modal */
.chat-map-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-map-modal {
  background: var(--color-bg-card);
  border-radius: 12px;
  width: min(90vw, 700px);
  height: min(80vh, 550px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.chat-map-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.chat-map-modal__title { font-weight: 600; font-size: 14px; }
.chat-map-modal__close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0 4px;
}
.chat-map-modal__close:hover { color: var(--color-text-primary); }
.chat-map-modal__body { flex: 1; }

/* Transient tool-status line shown during SSE streaming */
.chat-status-line {
  font-size: 11px;
  font-style: italic;
  color: var(--color-text-secondary);
  padding: 2px 0 4px;
  line-height: 1.4;
  opacity: 0.85;
}

/* Typing indicator */
.chat-typing span {
  display: inline-block;
  animation: chatTyping 1.2s infinite;
  font-size: 18px;
  line-height: 1;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatTyping {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Mobile responsive */
@media (max-width: 500px) {
  .chat-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 120px);
    bottom: 80px;
    right: 8px;
    left: 8px;
  }
  .chat-msg__content { max-width: 92%; }
}

/* ── Planner cluster map fullscreen ────────────────────────────── */
/* Fullscreen targets the whole dash-card so the header (exit button)
   and the Group/Status/Bases filters stay usable while fullscreen. */
#planner-map-card.is-fullscreen,
#planner-map-card.planner-map-fake-fullscreen {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-card, #fff);
  padding: 16px;
}
#planner-map-card.planner-map-fake-fullscreen {
  position: fixed; inset: 0; z-index: 9999;
}
#planner-map-card.is-fullscreen #planner-map-wrap,
#planner-map-card.planner-map-fake-fullscreen #planner-map-wrap {
  flex: 1;
  min-height: 0;
}
#planner-map-card.is-fullscreen #planner-map,
#planner-map-card.planner-map-fake-fullscreen #planner-map {
  height: 100%;
  min-height: 0;
}
#planner-map-card.is-fullscreen #cluster-summary-panel,
#planner-map-card.planner-map-fake-fullscreen #cluster-summary-panel {
  max-height: none;
}

/* ── Print Styles ──────────────────────────────────────────────── */
@media print {
  .sidebar, .top-header { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0; overflow: visible; }
  .chat-fab, .chat-panel { display: none !important; }
}

/* ================================================================
   Before/After Compare Modal  (additive — compareModal.js)
   ================================================================ */

/* Overlay */
.cmp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 30, 40, 0.72);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cmp-modal-overlay.hidden { display: none !important; }

/* Modal shell */
.cmp-modal {
  background: #f4f8fa;
  border-radius: 12px;
  width: 95vw;
  height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  color: #16303f;
  font-family: "Segoe UI", system-ui, sans-serif;
}

/* Header */
.cmp-modal-header {
  background: #fff;
  border-bottom: 1px solid #dde8ee;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.cmp-modal-title {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  color: #16303f;
  margin: 0;
}
.cmp-modal-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* Toggle buttons */
.cmp-toggle {
  display: flex;
  border: 1px solid #dde8ee;
  border-radius: 22px;
  overflow: hidden;
}
.cmp-toggle button {
  border: none;
  background: #fff;
  color: #5b7180;
  padding: 6px 18px;
  font-size: .88rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}
.cmp-tbefore.cmp-ton { background: #c2740c; color: #fff; }
.cmp-tafter.cmp-ton  { background: #0a9d94; color: #fff; }

/* Summary bar in header */
.cmp-bar {
  display: flex;
  gap: 16px;
  font-size: .8rem;
}
.cmp-stat { text-align: center; }
.cmp-stat-v { font-weight: 700; font-size: .98rem; }
.cmp-stat-b { color: #c2740c; }
.cmp-stat-a { color: #087b74; }
.cmp-stat-d { color: #16a34a; font-weight: 700; font-size: .75rem; }
.cmp-stat-neutral { color: #5b7180; font-size: .75rem; }
.cmp-stat-l { color: #5b7180; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }

/* Close button */
.cmp-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #5b7180;
  padding: 2px 6px;
  border-radius: 6px;
}
.cmp-close:hover { background: #f0f4f8; color: #16303f; }

/* Body: map + aside */
.cmp-modal-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
#cmp-map {
  flex: 1;
  min-height: 0;
}
.cmp-aside {
  width: 340px;
  background: #fff;
  border-left: 1px solid #dde8ee;
  padding: 14px 16px;
  overflow-y: auto;
  flex-shrink: 0;
}
.cmp-aside-h2 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #087b74;
  margin-bottom: 4px;
}
.cmp-hint {
  font-size: .73rem;
  color: #5b7180;
  margin-bottom: 11px;
}

/* Rep cards */
.cmp-rep {
  border: 1px solid #dde8ee;
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 8px;
  cursor: pointer;
}
.cmp-rep:hover { border-color: #0a9d94; }
.cmp-rep-sel { border-color: #0a9d94; box-shadow: 0 0 0 2px rgba(10,157,148,.15); }
.cmp-rep-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cmp-sw { width: 11px; height: 11px; border-radius: 3px; flex: none; display: inline-block; }
.cmp-rep-code { font-weight: 700; font-size: .86rem; }
.cmp-rep-oc { margin-left: auto; font-size: .73rem; color: #5b7180; }

/* Dual util bars */
.cmp-duo { display: flex; gap: 6px; align-items: center; }
.cmp-duo-tag { font-size: .62rem; color: #5b7180; width: 34px; flex-shrink: 0; }
.cmp-bar-wrap { flex: 1; height: 15px; background: #eef2f5; border-radius: 4px; overflow: hidden; position: relative; }
.cmp-bar-fill { height: 100%; }
.cmp-bar-pct { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); font-size: .66rem; font-weight: 700; color: #16303f; }
.cmp-rep-delta { font-size: .7rem; color: #16a34a; font-weight: 700; margin-top: 4px; }

/* Day panel */
.cmp-daysel-hd { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cmp-daysel-meta { font-size: .74rem; color: #5b7180; margin-bottom: 10px; }
.cmp-back { font-size: .74rem; color: #087b74; cursor: pointer; border: 1px solid #dde8ee; border-radius: 6px; padding: 3px 9px; margin-left: auto; }
.cmp-back:hover { background: #eef7f6; }
.cmp-planbadge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: .7rem; font-weight: 700; }
.cmp-planbadge-before { background: #fdf0e0; color: #c2740c; }
.cmp-planbadge-after  { background: #e6f6f4; color: #087b74; }

/* Week×Weekday grid */
.cmp-wgrid { display: grid; grid-template-columns: 26px repeat(5, 1fr); gap: 4px; margin-bottom: 4px; }
.cmp-wgrid-wk { font-size: .68rem; color: #5b7180; display: flex; align-items: center; font-weight: 700; }
.cmp-wgrid-colh { font-size: .62rem; color: #5b7180; text-align: center; padding-bottom: 2px; }
.cmp-chip { border: 1px solid #dde8ee; border-radius: 6px; padding: 4px 0; font-size: .68rem; cursor: pointer; background: #fff; text-align: center; }
.cmp-chip:hover { border-color: #0a9d94; }
.cmp-chip-on { background: #0a9d94; border-color: #0a9d94; color: #fff; font-weight: 700; }
.cmp-chip-empty { opacity: .28; cursor: default; border-style: dashed; }
.cmp-chip-over { border-color: #dc2626; color: #dc2626; background: #fef2f2; font-weight: 700; }
.cmp-chip-on.cmp-chip-over { background: #dc2626; color: #fff; border-color: #dc2626; }
.cmp-overnote { font-size: .7rem; color: #dc2626; margin-top: 5px; }
.cmp-dayinfo { font-size: .74rem; color: #5b7180; background: #eef7f6; border-radius: 8px; padding: 7px 10px; margin-top: 7px; }
.cmp-dayinfo b { color: #16303f; }

/* Map marker icons (Leaflet) */
.cmp-stop-num {
  background: #16303f;
  color: #fff;
  border-radius: 50%;
  width: 20px !important;
  height: 20px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.cmp-home-tag {
  background: #7c3aed;
  color: #fff;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  border: 2px solid #fff;
  white-space: nowrap;
}
