@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #f0f6ff;
  --bg-strong: #e2edfc;
  --card: rgba(255, 255, 255, 0.90);
  --card-solid: #ffffff;
  --ink: #0d1e3a;
  --muted: #5a6e8c;
  --line: rgba(196, 210, 228, 0.8);
  --primary: #1b58e8;
  --primary-dark: #1038a0;
  --primary-soft: rgba(27, 88, 232, 0.12);
  --secondary: #0fa872;
  --secondary-soft: rgba(15, 168, 114, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.14);
  --shadow-xl: 0 32px 72px rgba(10, 20, 50, 0.16), 0 0 0 1px rgba(255,255,255,0.6) inset;
  --shadow-lg: 0 18px 44px rgba(10, 20, 50, 0.11), 0 0 0 1px rgba(255,255,255,0.5) inset;
  --shadow-sm: 0 8px 22px rgba(10, 20, 50, 0.08), 0 0 0 1px rgba(255,255,255,0.7) inset;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(27, 88, 232, 0.13), transparent),
    radial-gradient(ellipse 60% 50% at 90% 10%, rgba(15, 168, 114, 0.10), transparent),
    radial-gradient(ellipse 50% 80% at 50% 100%, rgba(27, 88, 232, 0.05), transparent),
    linear-gradient(180deg, #e8f0fe 0%, #f4f8ff 40%, #f0f5fb 100%);
}

button, input, select, textarea { font: inherit; }

button {
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .01em;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition), opacity var(--transition);
}

button:hover { transform: translateY(-2px); }
button:active { transform: translateY(0px) scale(0.98); }

input, select, textarea {
  width: 100%;
  padding: 13px 16px;
  color: var(--ink);
  background: rgba(248, 251, 255, 0.95);
  border: 1.5px solid rgba(196, 210, 228, 0.80);
  border-radius: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input, select { min-height: 48px; }
textarea { min-height: 128px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  background: #fff;
  border-color: rgba(27, 88, 232, 0.6);
  box-shadow: 0 0 0 4px rgba(27, 88, 232, 0.11);
}

.page-shell,
.public-shell {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

/* ─── HERO ─────────────────────────────────────────────── */
.hero,
.public-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  margin-bottom: 24px;
  padding: 32px 36px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.94) 0%, rgba(240,248,255,0.88) 100%);
  border: 1.5px solid rgba(255,255,255,0.85);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
}

.hero::before,
.public-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 80% at 100% 50%, rgba(27, 88, 232, 0.09), transparent),
    radial-gradient(ellipse 40% 60% at 0% 50%, rgba(15, 168, 114, 0.07), transparent);
  pointer-events: none;
  border-radius: inherit;
}

.hero::after,
.public-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -80px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(27, 88, 232, 0.13), transparent 68%);
  pointer-events: none;
}

.hero-logo,
.public-logo {
  width: min(240px, 26vw);
  max-width: 260px;
  object-fit: contain;
  filter: drop-shadow(0 16px 32px rgba(10, 20, 50, 0.18));
  animation: float 5s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}

.hero h1,
.public-hero h1,
h2,
h3 { margin: 0; }

.hero h1,
.public-hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.8rem);
  font-weight: 900;
  line-height: .97;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--ink) 30%, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-text,
.muted-text {
  max-width: 720px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .24em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow::before {
  content: none;
  display: none;
}

/* ─── CARDS / PANELS ──────────────────────────────────── */
.auth-card,
.panel,
.app-topbar {
  background: var(--card);
  border: 1.5px solid rgba(255, 255, 255, 0.88);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.auth-card,
.panel { padding: 26px; }

.panel {
  position: relative;
  overflow: visible;
}

.panel.dropdown-open {
  z-index: 140;
}

.auth-card {
  max-width: 820px;
  margin: 0 auto 26px;
}

.auth-card .form-grid { margin-top: 18px; }

/* ─── TOPBAR ──────────────────────────────────────────── */
.app-topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  margin-bottom: 18px;
  background: rgba(255,255,255,0.92);
  border-top: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--primary), var(--secondary)) 1;
  border-image-slice: 0 0 0 0;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hidden { display: none !important; }

/* ─── NAV TABS ────────────────────────────────────────── */
.nav-tabs,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-tabs { margin-bottom: 18px; }

.nav-tab,
.tab {
  min-height: 44px;
  padding: 10px 18px;
  color: var(--muted);
  background: rgba(255,255,255,0.8);
  border: 1.5px solid rgba(196, 210, 228, 0.7);
  border-radius: 999px;
  font-weight: 600;
  font-size: .88rem;
  letter-spacing: .01em;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(10,20,50,0.05);
}

.nav-tab:hover,
.tab:hover {
  background: rgba(27, 88, 232, 0.07);
  border-color: rgba(27, 88, 232, 0.25);
  color: var(--primary);
}

.nav-tab.active,
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #3a7bff);
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(27, 88, 232, 0.30);
}

.app-view { display: none; }
.app-view.active { display: block; }

/* ─── SUMMARY GRID ────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-grid article {
  position: relative;
  overflow: hidden;
  padding: 24px 22px;
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid rgba(255,255,255,0.80);
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(246,250,255,0.92));
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
}

.summary-grid article:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.summary-grid article:nth-child(1) {
  background: linear-gradient(145deg, rgba(27,88,232,0.14), rgba(255,255,255,0.96));
  border-color: rgba(27,88,232,0.15);
}

.summary-grid article:nth-child(2) {
  background: linear-gradient(145deg, rgba(15,168,114,0.13), rgba(255,255,255,0.96));
  border-color: rgba(15,168,114,0.15);
}

.summary-grid article:nth-child(3) {
  background: linear-gradient(145deg, rgba(245,158,11,0.14), rgba(255,255,255,0.96));
  border-color: rgba(245,158,11,0.15);
}

.summary-grid article:nth-child(4) {
  background: linear-gradient(145deg, rgba(220,38,38,0.12), rgba(255,255,255,0.96));
  border-color: rgba(220,38,38,0.12);
}

.summary-grid article::after {
  content: "";
  position: absolute;
  right: -36px;
  bottom: -44px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  pointer-events: none;
}

.summary-grid span {
  display: block;
  font-size: clamp(2rem, 3vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
}

.summary-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .01em;
}

/* ─── LAYOUT GRIDS ────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.two-columns { grid-template-columns: 1.08fr .92fr; }
.quality-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact { gap: 12px; }
.wide { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 7px;
  color: #2d3f5e;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .01em;
}

/* ─── BUTTONS ─────────────────────────────────────────── */
.primary,
.secondary,
.ghost,
.danger,
.reject {
  min-height: 46px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, #3a7bff 100%);
  box-shadow: 0 10px 28px rgba(27, 88, 232, 0.28), 0 1px 0 rgba(255,255,255,0.2) inset;
}

.primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 14px 36px rgba(27, 88, 232, 0.36);
}

.secondary {
  color: #fff;
  background: linear-gradient(135deg, #0b8056, var(--secondary));
  box-shadow: 0 10px 26px rgba(15, 168, 114, 0.24), 0 1px 0 rgba(255,255,255,0.2) inset;
}

.secondary:hover {
  box-shadow: 0 14px 34px rgba(15, 168, 114, 0.34);
}

.ghost {
  color: var(--primary);
  background: rgba(27, 88, 232, 0.08);
  border: 1.5px solid rgba(27,88,232,0.16);
}

.ghost:hover {
  background: rgba(27, 88, 232, 0.14);
  border-color: rgba(27,88,232,0.30);
}

.danger,
.reject {
  box-shadow: 0 8px 22px rgba(220, 38, 38, 0.14);
}

.danger {
  color: var(--danger);
  background: rgba(220,38,38,0.08);
  border: 1.5px solid rgba(220,38,38,0.18);
}

.reject {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #c81e1e);
}

.reject:hover {
  box-shadow: 0 12px 28px rgba(220, 38, 38, 0.30);
}

/* ─── TOOLBAR / SEARCH ────────────────────────────────── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.search { min-width: min(420px, 100%); }

.history-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  align-items: end;
  gap: 12px;
}

.named-table-tools {
  display: flex;
  justify-content: end;
  margin: 0 0 14px;
}

.wide-search {
  min-width: min(420px, 100%);
}

.multi-select {
  min-height: 140px;
}

/* ─── TABLE ───────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  border: 1.5px solid rgba(196, 210, 228, 0.65);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.95);
}

.named-table-panel .table-wrap {
  border-radius: 18px;
}

.named-table-panel table {
  min-width: 820px;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: var(--card-solid);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(220, 230, 242, 0.85);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover { background: rgba(27,88,232,0.04); }

tbody tr:nth-child(even) {
  background: rgba(240, 246, 255, 0.45);
}

tbody tr:nth-child(even):hover {
  background: rgba(27,88,232,0.06);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #3d5273;
  background: linear-gradient(180deg, #f0f6ff, #eaf2fd);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  border-bottom: 2px solid rgba(196, 210, 228, 0.7);
}

.named-table-panel th {
  padding: 4px 5px;
  font-size: 0.46rem;
  letter-spacing: 0.04em;
}

.named-table-panel td {
  padding: 3px 5px;
  font-size: 0.64rem;
  line-height: 0.98;
  vertical-align: middle;
}

.named-table-panel td .muted-text {
  font-size: 0.57rem;
  line-height: 0.96;
}

/* ─── TURN BADGE ──────────────────────────────────────── */
.turn {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  color: #fff;
  border-radius: 50%;
  font-weight: 900;
  font-size: .95rem;
  background: linear-gradient(135deg, var(--primary), #4989ff);
  box-shadow: 0 6px 18px rgba(27,88,232,0.28);
}

.named-table-panel .turn {
  min-width: 18px;
  height: 18px;
  font-size: 0.56rem;
  box-shadow: 0 2px 6px rgba(27,88,232,0.14);
}

/* ─── BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
  background: #e5eaf3;
  color: #3d5273;
}

.badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge.approved { background: #d1fae5; color: #065f46; }
.badge.pending  { background: #dbeafe; color: #1e40af; }
.badge.rework   { background: #fef3c7; color: #78350f; }
.badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.assigned { background: #d1fae5; color: #065f46; }
.badge.channel  { background: #ede9fe; color: #4c1d95; }
.badge.suitability { background: #e0ecff; color: #1d4ed8; }

.named-table-panel .badge {
  gap: 4px;
  padding: 1px 5px;
  font-size: 0.54rem;
}

.named-table-panel .badge::before {
  width: 4px;
  height: 4px;
}

/* ─── ACTIONS ─────────────────────────────────────────── */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions button {
  min-height: 36px;
  padding: 7px 13px;
  font-size: .84rem;
  border-radius: 10px;
}

.named-table-panel .actions {
  gap: 6px;
}

.named-table-panel .actions button {
  min-height: 20px;
  padding: 1px 6px;
  font-size: 0.56rem;
  border-radius: 999px;
}

.report-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.report-link:hover {
  text-decoration: underline;
}

.suitability-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─── STACK / VEHICLE CARDS ───────────────────────────── */
.stack-list {
  display: grid;
  gap: 12px;
}

.vehicle-card,
.ticket-card,
.qr-card,
.gps-banner,
.info-strip,
.bullet-cards article,
.panel.soft,
.capture-card {
  border: 1.5px solid rgba(196, 210, 228, 0.75);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(246,251,255,0.93));
  box-shadow: var(--shadow-sm);
}

.vehicle-card,
.ticket-card,
.gps-banner,
.panel.soft,
.capture-card {
  padding: 18px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.vehicle-card:hover,
.ticket-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.vehicle-card h4 { margin: 0 0 8px; font-size: 1.08rem; font-weight: 800; }

.vehicle-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 12px 0;
  color: #3a4f6a;
  font-size: .91rem;
}

.qr-card {
  padding: 22px;
  display: grid;
  gap: 12px;
  place-items: center;
  text-align: center;
}

.qr-card img {
  width: min(290px, 100%);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.ticket-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,250,255,0.94)),
    linear-gradient(135deg, rgba(27,88,232,0.05), transparent);
}

.gps-banner {
  display: grid;
  gap: 12px;
  background: linear-gradient(135deg, rgba(15,168,114,0.10), rgba(255,255,255,0.95));
  border-color: rgba(15,168,114,0.20);
}

.info-strip {
  margin-top: 14px;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
  color: #3a4f6a;
}

.support-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 15px;
  color: var(--primary);
  background: rgba(27, 88, 232, 0.08);
  border: 1.5px solid rgba(27,88,232,0.15);
  border-radius: 999px;
  font-weight: 700;
  font-size: .88rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.support-link.download {
  color: #0f766e;
  background: rgba(15, 168, 114, 0.09);
  border-color: rgba(15, 168, 114, 0.18);
}

.support-link:hover {
  background: rgba(27, 88, 232, 0.14);
  border-color: rgba(27,88,232,0.28);
  transform: translateY(-1px);
}

.support-link.download:hover {
  background: rgba(15, 168, 114, 0.14);
  border-color: rgba(15, 168, 114, 0.28);
}

.named-table-panel .support-links {
  gap: 6px;
  margin-top: 0;
}

.named-table-panel .support-link {
  min-height: 23px;
  padding: 3px 7px;
  font-size: 0.64rem;
  border-radius: 999px;
}

.bullet-cards {
  display: grid;
  gap: 12px;
}

.bullet-cards article { padding: 18px; }

/* ─── MODAL ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 16, 36, 0.52);
  backdrop-filter: blur(10px);
}

.modal.hidden { display: none !important; }

.modal-card {
  width: min(700px, 100%);
  background: rgba(255,255,255,0.97);
  border: 1.5px solid rgba(255,255,255,0.85);
  border-radius: 26px;
  box-shadow: var(--shadow-xl);
  padding: 28px;
  animation: modal-in .22s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.wide-modal {
  width: min(1060px, 100%);
  max-height: 92vh;
  overflow: auto;
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
  margin-top: 20px;
}

.inline-actions {
  justify-content: start;
  margin-top: 0;
}

/* ─── QUALITY FORM ────────────────────────────────────── */
.quality-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.quality-item {
  border: 1.5px solid rgba(196, 210, 228, 0.70);
  border-radius: 20px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(248,251,255,0.90), rgba(240,247,255,0.80));
  transition: border-color var(--transition), box-shadow var(--transition);
}

.quality-item:focus-within {
  border-color: rgba(27, 88, 232, 0.35);
  box-shadow: 0 0 0 4px rgba(27, 88, 232, 0.07);
}

.quality-item h4 {
  margin: 0 0 10px;
  font-size: .97rem;
  font-weight: 800;
}

.quality-item p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .88rem;
}

.item-grid { display: grid; gap: 10px; }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: .9rem;
}

.inline-check input {
  width: auto;
  min-height: auto;
  box-shadow: none;
  accent-color: var(--primary);
}

/* ─── EMPTY STATE ─────────────────────────────────────── */
.empty {
  padding: 36px 24px;
  color: var(--muted);
  text-align: center;
  border: 1.5px dashed rgba(148, 163, 184, 0.50);
  border-radius: 18px;
  background: rgba(255,255,255,0.68);
  font-size: .95rem;
}

/* ─── PUBLIC / DRIVER PAGE ────────────────────────────── */
.public-body {
  background:
    radial-gradient(ellipse 70% 50% at 5% -5%, rgba(27, 88, 232, 0.13), transparent),
    radial-gradient(ellipse 50% 40% at 95% 5%, rgba(15, 168, 114, 0.09), transparent),
    linear-gradient(180deg, #e8f0fe 0%, #f5f9ff 100%);
  overflow-x: hidden;
}

.public-shell {
  width: calc(100% - 16px);
  max-width: 760px;
  display: grid;
  gap: 18px;
}

.public-hero {
  text-align: center;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 20px;
}

.public-hero > * {
  max-width: 100%;
  min-width: 0;
}

.public-hero h1,
.public-hero .hero-text,
.public-hero .eyebrow {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.public-hero h1 {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  line-height: 1.04;
}

.public-hero .hero-text {
  margin-top: 0;
  max-width: 34rem;
}

.capture-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.capture-card {
  display: grid;
  gap: 12px;
}

.capture-card h4,
.capture-card p { margin: 0; }

.capture-card p { color: var(--muted); }

.selfie-preview {
  min-height: 190px;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1.5px dashed rgba(148, 163, 184, 0.50);
  border-radius: 18px;
  background: linear-gradient(180deg, #fbfdff, #f2f7fe);
  text-align: center;
  transition: border-color var(--transition);
}

.selfie-preview:hover {
  border-color: rgba(27, 88, 232, 0.30);
}

.selfie-preview img {
  max-width: 100%;
  max-height: 230px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.signature-wrap {
  display: grid;
  gap: 10px;
}

.signature-canvas {
  width: 100%;
  min-height: 200px;
  border: 1.5px dashed rgba(148, 163, 184, 0.50);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f6fbff);
  touch-action: none;
  cursor: crosshair;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.signature-canvas:focus {
  border-color: rgba(27, 88, 232, 0.40);
  outline: none;
}

.signature-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.signature-status {
  color: var(--muted);
  font-weight: 600;
  font-size: .88rem;
}

/* ─── TOAST ───────────────────────────────────────────── */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 440px;
  padding: 14px 18px;
  color: #fff;
  background: linear-gradient(135deg, rgba(13,20,42,0.96), rgba(22,35,65,0.94));
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 600;
  font-size: .92rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.56,.64,1);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 1120px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .page-shell,
  .public-shell {
    width: min(100% - 16px, 1440px);
    padding-top: 20px;
  }

  .hero,
  .public-hero,
  .app-topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .history-actions {
    justify-content: stretch;
  }

  .hero-logo,
  .public-logo {
    width: min(200px, 65vw);
    margin: 0 auto;
  }

  .layout,
  .quality-grid,
  .form-grid,
  .quality-form-grid,
  .checkbox-grid,
  .vehicle-meta,
  .capture-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .summary-grid { grid-template-columns: 1fr; }
  .auth-card,
  .panel,
  .modal-card { padding: 18px; }
  .hero { padding: 16px 14px; }
  .hero h1 { font-size: 2.1rem; }
  .nav-tab, .tab { padding: 9px 14px; font-size: .84rem; }

  /* ── Public/Driver page mobile ── */
  .public-shell {
    width: calc(100% - 10px);
    padding: 6px 0 24px;
    gap: 10px;
  }
  .public-hero {
    padding: 14px 14px 12px;
    gap: 6px;
    border-radius: 18px;
    margin-bottom: 0;
  }
  .public-hero h1 {
    font-size: 1.25rem;
    line-height: 1.2;
  }
  .public-hero .eyebrow {
    font-size: .65rem;
    letter-spacing: .16em;
  }
  .public-hero .hero-text {
    font-size: .82rem;
    line-height: 1.4;
    margin-top: 2px;
  }
  .public-logo { display: none; }
  .public-body input,
  .public-body select,
  .public-body textarea {
    font-size: 16px;
    padding: 11px 13px;
    min-height: 44px;
  }
  .public-body button { font-size: 15px; }
  .gps-banner {
    padding: 14px 14px;
    gap: 8px;
  }
  .gps-banner button,
  #publicSubmitButton { width: 100%; }
  .public-shell > .panel { padding: 14px; }
  .capture-grid { gap: 10px; }
  .signature-canvas { min-height: 150px; }
  .selfie-preview { min-height: 140px; }
}

@media (max-width: 400px) {
  .public-hero {
    padding: 10px 12px;
    gap: 4px;
    border-radius: 14px;
  }
  .public-hero h1 { font-size: 1.1rem; }
  .public-hero .hero-text { font-size: .78rem; }
  .public-shell > .panel { padding: 12px 10px; }
  .gps-banner { padding: 12px 10px; }
}

/* ── Public/Driver page: tablas responsivas en móvil ── */
.public-body table {
  min-width: 0;
  width: 100%;
}

.public-body .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.public-body td,
.public-body th {
  white-space: normal;
  word-break: break-word;
  padding: 10px 12px;
  font-size: .85rem;
}

/* Listas de cola en driver.html: tarjetas en vez de tabla */
.public-body .stack-list {
  display: grid;
  gap: 8px;
}

/* Evita que cualquier hijo desborde el ancho del shell */
.public-shell * {
  max-width: 100%;
  box-sizing: border-box;
}

/* ===== Driver QR stability fixes ===== */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.public-alert {
  border-color: rgba(239, 68, 68, 0.18);
  background: linear-gradient(180deg, rgba(255, 245, 245, 0.96), rgba(255, 255, 255, 0.94));
}

.public-status-banner {
  display: grid;
  gap: 10px;
}

.public-status-banner h3,
.public-status-banner p {
  margin: 0;
}

.public-status-banner.success {
  border-color: rgba(15, 168, 114, 0.18);
  background: linear-gradient(180deg, rgba(236, 253, 245, 0.96), rgba(255, 255, 255, 0.94));
}

.public-status-banner.error {
  border-color: rgba(239, 68, 68, 0.18);
  background: linear-gradient(180deg, rgba(255, 245, 245, 0.96), rgba(255, 255, 255, 0.94));
}

.status-banner-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 600;
}

.multi-select-dropdown {
  position: relative;
  display: grid;
  gap: 8px;
  z-index: 30;
}

#dashboardDestinationPicker {
  z-index: 160;
}

#dashboardDestinationMenu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 180;
  max-height: 280px;
  margin-top: 0;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.multi-select-toggle {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1.5px solid rgba(191, 209, 233, 0.95);
  background: linear-gradient(180deg, rgba(246, 250, 255, 0.98), rgba(255, 255, 255, 0.96));
  text-align: left;
  color: var(--ink);
  font: inherit;
}

.multi-select-toggle:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
  border-radius: 18px;
  border: 1.5px solid rgba(191, 209, 233, 0.95);
  background: rgba(255, 255, 255, 0.995);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.multi-select-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(191, 209, 233, 0.65);
  background: linear-gradient(180deg, rgba(249, 252, 255, 0.98), rgba(255, 255, 255, 0.96));
  cursor: pointer;
}

.multi-select-option:hover {
  background: rgba(27, 88, 232, 0.06);
  border-color: rgba(27, 88, 232, 0.22);
}

.multi-select-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.multi-select-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.multi-select-copy strong {
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.2;
}

.multi-select-copy small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.2;
}

.selected-city-turns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.selected-city-turns.compact {
  margin-top: 12px;
}

.city-turn-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(27, 88, 232, 0.08);
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 700;
}

.tracking-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}

.tracking-city-section {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.tracking-city-section h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
}

.tracking-city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.tracking-city-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.tracking-city-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(191, 209, 233, 0.8);
  background: linear-gradient(180deg, rgba(246, 250, 255, 0.96), rgba(255, 255, 255, 0.98));
}

.tracking-city-name {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tracking-city-card strong {
  color: var(--primary);
  font-size: 1.15rem;
}

.tracking-city-card small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.tracking-note {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(15, 168, 114, 0.08);
  border: 1px solid rgba(15, 168, 114, 0.14);
}

.driver-media-grid {
  display: grid;
  gap: 12px;
}

.capture-card.compact {
  padding: 14px;
}

.tracking-media-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(191, 209, 233, 0.85);
  background: #fff;
}

.media-preview-modal {
  max-width: 1100px;
}

.media-preview-body {
  max-height: 72vh;
  overflow: auto;
}

.media-preview-single img,
.media-preview-figure img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(191, 209, 233, 0.85);
  background: #fff;
}

.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.media-preview-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 4px;
}

.media-preview-figure {
  margin: 0;
  display: grid;
  gap: 8px;
}

.media-preview-figure figcaption {
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 768px) {
  .public-body {
    width: 100%;
    overflow-x: hidden;
  }

  .public-shell {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    padding: 8px 0 28px;
    gap: 12px;
  }

  .public-hero,
  .public-shell > .panel,
  .gps-banner,
  .public-alert {
    width: 100%;
    margin: 0;
    border-radius: 18px;
  }

  .public-hero {
    padding: 16px 14px;
    gap: 8px;
  }

  .public-hero h1 {
    font-size: clamp(1.35rem, 7vw, 1.85rem);
    line-height: 1.1;
    text-align: center;
  }

  .public-hero .hero-text {
    max-width: 100%;
    font-size: 0.92rem;
    line-height: 1.45;
    text-align: center;
  }

  .tracking-grid,
  .capture-grid {
    grid-template-columns: 1fr;
  }

  .tracking-city-grid {
    grid-template-columns: 1fr;
  }

  .multi-select-menu {
    position: static;
    max-height: 220px;
    box-shadow: none;
  }

  .multi-select-option {
    padding: 11px 12px;
  }

  .multi-select-copy strong {
    font-size: 0.94rem;
  }

  .multi-select-copy small {
    font-size: 0.8rem;
  }

  .public-body table,
  .public-body .table-wrap {
    width: 100%;
  }

  .public-body th,
  .public-body td {
    font-size: 0.8rem;
    padding: 9px 8px;
  }
}
