@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

:root {
  --bg: #ffffff;
  --bg2: #fafaf8;
  --bg3: #f4f2ef;
  --surface: #ede9e4;
  --surface2: #e6e0da;
  --accent: #F87554;
  --accent2: #e06040;
  --accent3: #F87554;
  --text: #1a1208;
  --text2: #6b5c50;
  --text3: #a8978c;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(248,117,84,0.3);
  --danger: #d63f3f;
  --warning: #e08c2a;
  --success: #2ea869;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(248,117,84,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  height: -webkit-fill-available;
}
body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: 'Poppins', sans-serif; font-weight: 700; }

/* ── Layout ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.page { display: none; padding: 2rem; max-width: 900px; width: 100%; }
.page.active { display: block; }

/* The 900px cap keeps forms/settings at a readable line length, but the
   itinerary calendar and the reports table are grids, not prose — capping
   them the same way just wastes the rest of a wide desktop screen and makes
   the calendar's day cells more cramped than they need to be. */
#page-itineraries, #page-reports { max-width: 1400px; }

/* ── Sidebar ── */
.sidebar-logo {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Poppins', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
}

.nav-section-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0.75rem 0.5rem 0.25rem;
  font-family: 'Poppins', sans-serif;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
  justify-content: flex-start;
}

.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item:active { background: var(--surface2); transform: scale(0.98); }
.nav-item.active { background: rgba(248,117,84,0.10); color: var(--accent); }
.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Lang toggle (and other segmented pill toggles, e.g. calendar view) ── */
.lang-toggle,
.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.lang-btn,
.view-toggle-btn {
  flex: 1;
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  transition: all 0.15s;
}

.lang-btn.active,
.view-toggle-btn.active { background: var(--surface2); color: var(--accent); }

/* Itineraries / Google Calendar source switch on the admin calendar —
   a larger rounded pill than .view-toggle, the active side raised. */
.itin-source-toggle {
  display: flex;
  align-self: center;
  width: 360px;
  max-width: 100%;
  background: var(--bg3);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 4px;
}
.itin-source-btn {
  flex: 1;
  padding: 9px 12px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text3);
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.itin-source-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

/* Admin calendar nav: ‹ [source toggle / Month-Week / label] › Today */
.itin-nav-row { display: flex; align-items: flex-end; gap: 12px; }
.itin-nav-center { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.itin-view-toggle { width: 200px; max-width: 100%; }
/* Phones: the middle column is too narrow for the source toggle, so the
   column dissolves (display: contents) and both toggles take full-width
   rows of their own above the ‹ label › Today row — still centered on
   each other. */
@media (max-width: 640px) {
  .itin-nav-row { flex-wrap: wrap; align-items: center; row-gap: 8px; }
  .itin-nav-center { display: contents; }
  .itin-nav-row .itin-source-toggle { order: -2; flex: 0 0 100%; width: auto; margin-bottom: 0; }
  .itin-nav-row .itin-view-toggle { order: -1; flex: 0 0 100%; width: auto; }
  .itin-nav-row #itin-week-label { flex: 1; min-width: 0; }
}

/* Google Calendar items (see renderGoogleCalendar() in app.js) */
.gcal-item {
  display: block;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid var(--gc, #4285f4);
  background: color-mix(in srgb, var(--gc, #4285f4) 14%, transparent);
}
/* Week view has room to show whole titles */
.gcal-week .gcal-item { white-space: normal; }
.gcal-item.allday { background: var(--gc, #4285f4); color: #fff; border-left-color: transparent; }
.gcal-item.task { border-left-style: dotted; }
.gcal-item.done { opacity: 0.5; text-decoration: line-through; }
.gcal-more { background: none; border: none; padding: 0 4px; font-size: 10px; font-weight: 600; color: var(--text3); cursor: pointer; text-align: left; font-family: inherit; }
.gcal-card { display: block; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; text-decoration: none; color: var(--text); border-left: 4px solid var(--gc, #4285f4); background: color-mix(in srgb, var(--gc, #4285f4) 12%, transparent); }
.gcal-card.done { opacity: 0.55; }
.gcal-card-title { font-size: 14px; font-weight: 700; }
.gcal-card.done .gcal-card-title { text-decoration: line-through; }
.gcal-card-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.gcal-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; font-size: 12px; color: var(--text3); }
.gcal-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; flex: 1; min-width: 0; }
.gcal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.gcal-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--gc); display: inline-block; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 26px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Cards ── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-family: 'Poppins', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #0a1628;
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface2); }

.btn-danger {
  background: rgba(255,77,109,0.15);
  color: var(--danger);
  border: 1px solid rgba(255,77,109,0.25);
}
.btn-danger:hover { background: rgba(255,77,109,0.25); }

.btn-ghost {
  background: none;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--surface); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 13px; }

/* "Mark all as done" on today's or an overdue itinerary. Grey while the
   day isn't over yet (today, not yet late — just a shortcut); red once
   it's a past day still not done (same red as the calendar's overdue
   highlight — this needs attention). Color is set via these state classes
   (toggled in openItineraryView) rather than inline, so each state gets
   its own hover/press feedback instead of reading as a static banner. */
.itin-markall-btn { transition: all 0.15s; }
.itin-markall-btn.state-overdue { background: #c0392b; box-shadow: 0 2px 10px rgba(192,57,43,0.35); }
.itin-markall-btn.state-overdue:hover { background: #a93226; box-shadow: 0 3px 14px rgba(192,57,43,0.45); }
.itin-markall-btn.state-today { background: #8a8a8a; box-shadow: 0 2px 10px rgba(0,0,0,0.15); }
.itin-markall-btn.state-today:hover { background: #757575; box-shadow: 0 3px 14px rgba(0,0,0,0.2); }
.itin-markall-btn:active { transform: scale(0.98); }

/* ── List page search box (Products/Venues/Users/Locations) ── */
.list-search-input {
  max-width: 320px;
  margin-bottom: 1.25rem;
}

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-family: 'Poppins', sans-serif;
}

input, select, textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: 'DM Sans', sans-serif;
  padding: 0.6rem 0.9rem;
  transition: border-color 0.15s;
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(248,117,84,0.12);
}

select option { background: var(--bg3); }

/* Report venue picker: dropdown of saved venues, with a discreet keyboard
   icon on the right to switch to a typed-in one-off site name. */
.venue-picker { position: relative; }
.venue-picker select, .venue-picker input { padding-right: 2.6rem; }
.venue-picker-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text3); opacity: 0.7; border-radius: var(--radius-sm);
}
.venue-picker-toggle:hover, .venue-picker-toggle:focus-visible { opacity: 1; color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

.radio-group {
  display: flex;
  gap: 8px;
}

.radio-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.85rem 1rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  color: var(--accent);
  background: rgba(248,117,84,0.04);
  box-shadow: 0 0 0 0 rgba(248,117,84,0.3);
}

.radio-pill:hover {
  background: rgba(248,117,84,0.10);
  box-shadow: 0 2px 12px rgba(248,117,84,0.2);
  transform: translateY(-1px);
}

.radio-pill input[type=radio] { display: none; }

.radio-pill.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(248,117,84,0.35);
  transform: translateY(-1px);
}

/* Pulse animation when form is locked (type not yet chosen) */
.form-body-locked ~ * .radio-pill,
.radio-group:has(.radio-pill:not(.selected):not(.selected)) .radio-pill:not(.selected) {
  animation: pill-pulse 2s ease-in-out infinite;
}

@keyframes pill-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,117,84,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(248,117,84,0); }
}

/* ── Product rows in report ── */
.product-row {
  display: grid;
  grid-template-columns: 2fr 70px 80px 70px 80px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ── Product cards ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.product-card:hover { border-color: var(--border2); }

.product-card-img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.product-card-img img { width: 100%; height: 100%; object-fit: cover; }

.product-card-body { padding: 0.75rem; }
.product-card-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.product-card-desc { font-size: 12px; color: var(--text3); }
.product-card-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ── List items (agents, venues) ── */
.list-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.list-item:hover { border-color: var(--border2); }
.list-item-info { flex: 1; min-width: 0; overflow: hidden; }
.list-item-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 13px; color: var(--text3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Report list ── */
.report-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  cursor: pointer;
}

.report-item:hover { border-color: var(--border2); }
.report-num { font-family: 'Poppins', sans-serif; font-size: 13px; color: var(--text3); margin-bottom: 4px; text-align: left; }
.report-venue { font-weight: 600; font-size: 15px; }
.report-meta { font-size: 13px; color: var(--text3); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-dropoff { background: rgba(248,117,84,0.12); color: var(--accent2); }
.badge-pickup { background: rgba(212,90,62,0.08); color: var(--accent2); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,18,8,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
}

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

.modal-title {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

/* ── Toasts ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 768px) {
  .toast-container {
    bottom: calc(env(safe-area-inset-bottom) + 80px);
    right: 1rem;
    left: 1rem;
  }
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 220px;
  animation: slideIn 0.2s ease;
}

.toast.error { border-color: rgba(255,77,109,0.4); background: rgba(255,77,109,0.1); color: var(--danger); }
.toast.success { border-color: rgba(248,117,84,0.4); background: rgba(248,117,84,0.06); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Image upload ── */
.img-upload-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
  background: var(--bg3);
}

.img-upload-box:hover { border-color: var(--accent); }
.img-upload-box input { display: none; }
.img-preview { max-width: 100%; max-height: 150px; border-radius: var(--radius-sm); margin-top: 1rem; }

/* ── Top bar mobile ── */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.1rem;
  padding-top: calc(0.7rem + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  min-height: calc(56px + env(safe-area-inset-top));
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 26px;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}

/* Center logo absolutely within topbar */
.topbar { position: fixed; }
.topbar > img {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text3);
}

.empty-icon { font-size: 48px; margin-bottom: 1rem; }
.empty-text { font-size: 15px; }

/* ── Report form sections ── */
.section-title {
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border2);
}

/* ── Signature field ── */
.signature-field {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 0.5rem;
}

/* ── Settings page ── */
.settings-hint {
  font-size: 13px;
  color: var(--text3);
  margin-top: 6px;
  line-height: 1.5;
}

.settings-link {
  color: var(--accent2);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    top: 0 !important;
    height: 100dvh !important;
    overflow-y: auto;
    z-index: 150;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .topbar { display: flex; }

  .page { padding: 1.25rem; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .product-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .product-row > div:last-child { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }

  .sidebar-overlay.open { display: block; }
}

/* ── Accent line ── */
.accent-line {
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent3));
  border-radius: 2px;
  margin-bottom: 2rem;
}

/* ── Login page ── */
/* Logo screen: on top of everything (modals, toasts, bottom bar) while
   the app starts or reloads to the login page. */
#app-loading {
  position: fixed;
  inset: 0;
  z-index: 5000;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  padding: 1rem;
}

.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(248,117,84,0.10);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.login-title {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-sub {
  font-size: 13px;
  color: var(--text3);
  text-align: center;
  margin-bottom: 2rem;
}

.login-error {
  background: rgba(214,63,63,0.08);
  border: 1px solid rgba(214,63,63,0.2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  display: none;
}

.login-error.visible { display: block; }

/* ── Client portal ── */
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.portal-body {
  padding: 2rem;
  max-width: 960px;
  margin: 0 auto;
}

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  align-items: flex-end;
}

.filter-bar select, .filter-bar input {
  width: auto;
  flex: 1;
  min-width: 140px;
}

.report-detail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.product-tag {
  background: rgba(248,117,84,0.08);
  border: 1px solid rgba(248,117,84,0.2);
  border-radius: 20px;
  font-size: 12px;
  padding: 2px 10px;
  color: var(--accent2);
  font-weight: 500;
}

/* ── Users admin section ── */
.user-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  background: rgba(248,117,84,0.10);
  color: var(--accent);
}

/* ── Draft badges & styles (also used by other nav-item count badges, e.g. itineraries) ── */
.nav-draft-badge,
.nav-itin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  min-width: 18px;
  height: 18px;
  border-radius: 20px;
  padding: 0 5px;
  margin-left: auto;
  line-height: 1;
}

.draft-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  min-width: 20px;
  height: 20px;
  border-radius: 20px;
  padding: 0 6px;
  line-height: 1;
}

.badge-draft {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  background: rgba(248,117,84,0.12);
  color: var(--accent);
  border: 1px solid rgba(248,117,84,0.25);
  margin-left: 6px;
  letter-spacing: 0.3px;
}

.draft-item {
  border-left: 3px solid var(--accent) !important;
  opacity: 0.92;
}

/* ── Dashboard new report button ── */
.new-report-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 1.1rem 1.5rem;
  font-size: 16px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  border-radius: var(--radius);
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(248,117,84,0.25);
  transition: all 0.2s;
}
.new-report-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(248,117,84,0.35);
}

/* ── Drag handle ── */
.drag-handle {
  cursor: grab;
  color: var(--text3);
  font-size: 16px;
  padding: 0 6px;
  user-select: none;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }
.list-item.dragging { opacity: 0.4; border: 2px dashed var(--accent); }
.list-item.drag-over { border-color: var(--accent); background: rgba(248,117,84,0.05); }
.product-card.dragging { opacity: 0.4; }
.product-card.drag-over { outline: 2px dashed var(--accent); }

/* ── Reports filter page ── */
.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.reports-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.reports-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.reports-table tr:last-child td { border-bottom: none; }
.reports-table tr:hover td { background: var(--bg2); }
.reports-table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Sidebar logo compact on short screens ── */
@media (max-height: 600px) {
  .sidebar-logo { padding: 0.5rem 1rem 0.5rem; }
  .sidebar-logo img { height: 28px !important; }
  .nav-item { padding: 0.4rem 0.75rem; font-size: 13px; }
  .nav-section-label { padding: 0.4rem 0.5rem 0.1rem; }
}

/* ── Simplified product row (black bins, counters) ── */
.product-row-simple {
  grid-template-columns: 1fr 120px auto !important;
}

/* ── Nav arrows ── */
.nav-arrow-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 20px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.15s;
  padding: 0;
}
.nav-arrow-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.nav-arrow-btn:disabled { opacity: 0.3; cursor: default; }

.desktop-nav-arrows {
  display: flex;
  gap: 6px;
  padding: 0.75rem 2rem 0;
}

@media (max-width: 768px) {
  /* Account for fixed topbar height + notch + extra breathing room */
  .main-content {
    padding-top: 0 !important;
    margin-top: calc(72px + env(safe-area-inset-top));
  }
  .desktop-nav-arrows { display: none; }
  /* Sidebar must start below topbar */
  .sidebar { top: calc(56px + env(safe-area-inset-top)); height: calc(100dvh - 56px - env(safe-area-inset-top)); }
}

/* ── Sidebar 7: force footer visible on all mobile heights ── */
@media (max-width: 768px) {
  .sidebar {
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
  }
  .sidebar-logo { overflow: hidden; flex-shrink: 0; }
  .sidebar-nav {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }
  .sidebar-footer {
    flex-shrink: 0;
    background: var(--bg);
    z-index: 1;
  }
}

/* ── Mobile bottom bar ── */
.mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  padding-bottom: calc(env(safe-area-inset-bottom) - 8px);
  min-height: calc(50px + env(safe-area-inset-bottom) - 8px);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.mobile-bottom-bar .lang-toggle {
  flex-shrink: 0;
}

.mobile-bottom-bar .lang-btn {
  padding: 4px 8px !important;
  font-size: 11px !important;
  min-height: 30px !important;
}

.mobile-bottom-bar-change-pw {
  flex: 1;
  font-size: 11px !important;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 30px !important;
}

.mobile-bottom-bar-logout {
  flex-shrink: 0;
  font-size: 12px;
  min-height: 30px !important;
}

@media (max-width: 768px) {
  .mobile-bottom-bar { display: flex !important; }
  .sidebar-footer-desktop { display: none !important; }
  .main-content { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .sidebar { grid-template-rows: auto 1fr; height: calc(100dvh - 56px - env(safe-area-inset-top)); }
}

@media (min-width: 769px) {
  .mobile-bottom-bar { display: none !important; }
  .sidebar-footer-desktop { display: flex !important; }
}

/* ── Locked form body (before report type selected) ── */
.form-body-locked {
  position: relative;
  pointer-events: none;
  user-select: none;
}
.form-body-locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.72);
  border-radius: var(--radius);
  z-index: 10;
}
.form-body-locked input,
.form-body-locked select,
.form-body-locked textarea,
.form-body-locked button {
  opacity: 0.45;
}

/* ── Condition button pulse error animation ── */
@keyframes pulse-error {
  0% { transform: scale(1); }
  30% { transform: scale(1.04); }
  60% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ── Mobile First Enhancements ── */
@media (max-width: 768px) {
  /* Larger touch targets */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .nav-item { min-height: 48px; font-size: 15px; }

  /* Bigger form elements */
  input, select, textarea {
    font-size: 16px !important; /* prevents iOS zoom on focus */
    min-height: 44px;
  }

  /* Cards take full width */
  .card { border-radius: 10px; }

  /* Report items easier to tap */
  .report-item { padding: 1rem; }

  /* Product rows stack better */
  .product-row { flex-wrap: wrap; }

  /* Modal takes more screen */
  .modal { max-height: 95vh; }

  /* Page padding tighter on mobile */
  .page { padding: 1rem; }
}

/* ── Stop venue custom dropdown ── */
.stop-dropdown-item {
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.stop-dropdown-item:last-child { border-bottom: none; }
.stop-dropdown-item:hover { background: var(--surface); }

/* ── Itinerary stop drag ── */
.stop-row.stop-drag-over {
  border: 2px dashed var(--accent) !important;
  background: rgba(248,117,84,0.04);
}
.stop-drag-handle:hover { color: var(--accent); }

/* + between two itinerary stops: centred on the 8px gap above its row */
.stop-row { position: relative; }
.stop-insert-btn {
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
/* The plus itself — drawn, so it's dead centre whatever the font */
.stop-insert-btn::before {
  content: '';
  position: absolute;
  inset: 5px;
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat;
}
/* Larger tap area than the visible circle */
.stop-insert-btn::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; }
.stop-row:first-child > .stop-insert-btn { display: none; }
/* While a stop is dragged: no + anywhere, so the dragged copy is just the stop */
.stop-list-dragging .stop-insert-btn { display: none; }
.stop-insert-btn:active { background: var(--accent); color: #fff; }
@media (hover: hover) {
  .stop-insert-btn:hover { background: var(--accent); color: #fff; }
}

.stop-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.stop-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.stop-header-name { flex: 1; }
.stop-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.stop-header-actions .stop-type { flex-shrink: 0; max-width: 90px; }
.stop-header-actions .stop-expand-btn,
.stop-header-actions .btn-danger { flex-shrink: 0; }
.stop-line-break { display: none; }

/* On narrow screens the collapsed stop header no longer fits drag handle,
   number, venue name, type pill, expand arrow and cancel on one line.
   Line 1: number/handle, venue search box, expand arrow.
   Line 2: type pill (stretched) next to the cancel button. */
@media (max-width: 480px) {
  .stop-header-name {
    order: 1;
    /* basis 0 (not auto) — the global `input{width:100%}` rule makes an
       auto basis blow up to fill the whole line, since flex-basis:auto
       defers to the child input's own width when one is set. */
    flex: 1 1 0%;
    min-width: 0;
  }
  /* row-gap is zeroed because the invisible break spacer below counts as
     its own flex line — with the default gap it'd add its own row-gap on
     both sides on top of its height, tripling the visible space. */
  .stop-header { row-gap: 0; }
  .stop-header-actions { display: contents; }
  .stop-header-actions .stop-expand-btn { order: 2; }
  .stop-line-break {
    display: block;
    flex-basis: 100%;
    height: 6px;
    order: 3;
  }
  .stop-header-actions .stop-type {
    order: 4;
    flex: 1 1 0%;
    max-width: none;
    min-width: 0;
  }
  .stop-header-actions .btn-danger { order: 5; }
}

/* ── Itinerary weekly calendar ── */
#itin-calendar-nav {
  background: var(--bg);
  padding: 8px 0;
  margin-bottom: 12px;
}

/* Weekend columns (Sun first, Sat last) narrower than weekdays so all 7
   fit on screen without Saturday getting pushed off the right edge. */
.itin-cal-header,
.itin-cal-grid {
  display: grid;
  grid-template-columns: 0.6fr repeat(5, 1fr) 0.6fr;
}
.itin-cal-header { gap: 2px; margin-bottom: 4px; }
.itin-cal-grid { gap: 4px; }
/* Grid items default to min-width:auto, so a long agent-name pill (nowrap)
   forces its whole column wider than its fr share — pushing Saturday off
   the edge regardless of the ratio above. min-width:0 lets the existing
   overflow:hidden/text-overflow:ellipsis on the pill actually truncate it. */
.itin-cal-grid > div { min-width: 0; }

/* Mobile-only swipeable week view — see renderItinCalendarGrid() in
   app.js. Hidden by default (desktop shows the .itin-week-grid-wrap grid
   instead — the @media block below flips which one is visible); scroll-snap
   gives native swipe-between-days behavior with no custom touch/gesture JS
   needed. Declared before the @media block so its mobile override (same
   specificity) actually wins by source order at matching widths. */
.itin-week-mobile-swiper {
  display: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.itin-week-mobile-swiper::-webkit-scrollbar { display: none; }
.itin-week-mobile-day {
  flex: 0 0 100%;
  width: 100%;
  box-sizing: border-box;
  scroll-snap-align: start;
  padding: 0 4px;
}

@media (max-width: 768px) {
  .itin-cal-grid { gap: 3px; }
  .itin-cal-grid > div {
    min-height: 70px;
    padding: 4px;
  }
  /* Week view's 7-column grid is unusable at phone widths, so it's swapped
     for one full day at a time, swipeable via native scroll-snap. Month
     view is untouched — it has no .itin-week-grid-wrap, so this rule
     never hides it. */
  .itin-week-grid-wrap { display: none; }
  .itin-week-mobile-swiper { display: flex; }
}

/* Drag/drop feedback (desktop admin calendar). Uses opacity/outline rather
   than border/background so it doesn't fight the pill/cell's own inline
   background+border, which are set dynamically per status/today/weekend. */
.itin-pill.dragging { opacity: 0.4 !important; }
.itin-cal-day.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* Hover preview popover (desktop calendar only), styled like the app's
   other floating panels (e.g. the stop-venue search dropdown): a plain
   bg card, subtle border, soft shadow. Positioned via JS (left/top). */
.itin-pill-preview {
  display: none;
  position: fixed;
  z-index: 1000;
  width: 240px;
  max-width: calc(100vw - 24px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 12px 14px;
  font-family: 'DM Sans', sans-serif;
  pointer-events: none;
}
.itin-pill-preview.open { display: block; }
.itin-pill-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.itin-pill-preview-agent { font-weight: 700; font-size: 13px; color: var(--text); }
.itin-pill-preview-date { font-size: 11px; color: var(--text3); }
.itin-pill-preview-stop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
}
.itin-pill-preview-stop-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.itin-pill-preview-more { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* Itinerary view: ‹ › day switcher around the date title (swipe does the same) */
.itin-view-header { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 1.25rem; }
.itin-day-nav { display: flex; align-items: center; gap: 6px; min-width: 0; width: 100%; }
.itin-day-title { flex: 1; min-width: 0; text-align: center; }
.itin-view-empty { min-height: 55vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.itin-view-empty .empty-icon { margin-bottom: 0.5rem; }
.itin-view-create-btn { color: #fff; margin-bottom: 1.5rem; padding: 0.7rem 1.6rem; font-size: 15px; }
.itin-day-arrow {
  background: none; border: 1.5px solid var(--border); border-radius: 50%;
  width: 34px; height: 34px; flex-shrink: 0; cursor: pointer;
  color: var(--text3); font-size: 22px; line-height: 1; padding: 0 0 3px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.itin-day-arrow:hover { color: var(--accent); border-color: var(--accent); }
.itin-day-arrow:active { transform: scale(0.92); }
#page-itinerary-view.itin-slide-next #itin-view-body,
#page-itinerary-view.itin-slide-next .itin-day-nav > div { animation: itinSlideNext 0.22s ease-out; }
#page-itinerary-view.itin-slide-prev #itin-view-body,
#page-itinerary-view.itin-slide-prev .itin-day-nav > div { animation: itinSlidePrev 0.22s ease-out; }
@keyframes itinSlideNext { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes itinSlidePrev { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
