/* Pilot Car Helper v51 - Clean Driver & Dispatch Layout */
html, body { max-width: 100%; overflow-x: hidden; }

/* Keep 16px strictly on form inputs to stop iPhone zoom — never blow up nav tabs or chips */
body.pch-role-driver input,
body.pch-role-driver select,
body.pch-role-driver textarea {
  font-size: 16px;
  box-sizing: border-box;
}
body.pch-role-driver:not(.pch-solo-active) {
  padding-bottom: 84px;
}
body.pch-role-driver .card {
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(11, 21, 40, 0.08);
}

/* Fix Classic Driver dark-on-navy header & align PCH badge beside title */
body.pch-role-driver .hdr-brand {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0;
}
body.pch-role-driver .hdr-brand .pch-sq-logo {
  margin-right: 0 !important;
  flex-shrink: 0 !important;
}
body.pch-role-driver .pch-hdr-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
body.pch-role-driver .hdr-brand,
body.pch-role-driver .hdr-brand h1,
body.pch-role-driver .hdr-brand h2,
body.pch-role-driver .hdr-brand strong,
body.pch-role-driver .hdr-brand .hdr-title,
body.pch-role-driver .hdr-brand .title,
body.pch-role-driver .pch-hdr-meta > :first-child {
  color: #FFFFFF !important;
  font-weight: 800 !important;
}
body.pch-role-driver .hdr-brand small,
body.pch-role-driver .hdr-brand .hdr-sub,
body.pch-role-driver .hdr-brand .sub,
body.pch-role-driver .pch-hdr-meta > :not(:first-child) {
  color: #CBD5E1 !important;
  font-weight: 600 !important;
}

/* Clean Solo Mode pill inside the Driver header (replaces overlapping bottom-right FAB) */
#pchHeaderSoloBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1.5px solid #FACC15;
  background: #FACC15;
  color: #0B1528;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}
#pchHeaderSoloBtn:hover { background: #FDE047; }

/* Fix Classic Driver bottom nav & wrapping chips */
body.pch-role-driver:not(.pch-solo-active) nav button,
body.pch-role-driver:not(.pch-solo-active) .bottom-nav button,
body.pch-role-driver:not(.pch-solo-active) .tab-bar button,
body.pch-role-driver:not(.pch-solo-active) .tabs button {
  min-height: 52px !important;
  padding: 8px 6px !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  white-space: nowrap;
}
@media (max-width: 640px) {
  body.pch-role-driver .wrap { padding: 10px 10px 28px !important; }
  body.pch-role-driver .grid-2,
  body.pch-role-driver .grid-3 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  body.pch-role-driver .card { padding: 14px !important; }
}
body.pch-role-driver .pch-secondary-item { display: revert; }

/* Dispatcher: Wide desktop command center */
@media (min-width: 1024px) {
  body.pch-role-dispatch .wrap,
  body.pch-role-dispatch main,
  body.pch-role-dispatch #app {
    max-width: 1360px !important;
    width: calc(100% - 32px);
    margin-left: auto;
    margin-right: auto;
  }
  body.pch-role-dispatch .card {
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(11, 21, 40, 0.07);
  }
}
body.pch-role-dispatch table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* Shared pills, ? help buttons & How-To modal */
.pch-pill-btn {
  min-height: 34px;
  font-size: 12.5px;
  font-weight: 800;
  border-radius: 9px;
  padding: 6px 12px;
  border: 1.5px solid #0B1528;
  background: #0B1528;
  color: #FACC15;
  cursor: pointer;
  white-space: nowrap;
}
.pch-pill-btn.is-light { background: #F8FAFC; color: #0B1528; border-color: #94A3B8; }
.pch-q-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid #0284C7;
  background: #E0F2FE;
  color: #0369A1;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
}
.pch-q-btn:hover { background: #0284C7; color: #FFFFFF; }
#pchHelpPop {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 24px));
  background: #0B1528;
  color: #FFFFFF;
  border: 2px solid #FACC15;
  border-radius: 14px;
  padding: 14px 16px;
  z-index: 95000;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.4);
  font-size: 13.5px;
  line-height: 1.45;
  font-family: system-ui, -apple-system, sans-serif;
}
#pchHowToBg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 21, 40, 0.72);
  z-index: 94000;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}
.pch-ht-card {
  background: #FFFFFF;
  color: #0F172A;
  width: min(720px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 16px;
  border: 1px solid #CBD5E1;
  padding: 18px;
  font-family: system-ui, -apple-system, sans-serif;
}
.pch-ht-tabs { display: flex; gap: 8px; margin: 12px 0 14px; flex-wrap: wrap; }
.pch-ht-step {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-left: 4px solid #0284C7;
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 10px;
}
.pch-ht-step h4 { margin: 0 0 4px; font-size: 14px; color: #0B1528; }
.pch-ht-step p { margin: 0; font-size: 13px; color: #334155; line-height: 1.45; }

/* v67 classic modal contrast & fields fix */
#newRunModal .modal {
  overflow-y: auto !important;
  max-height: 92vh !important;
}
#newRunModal .grid-2,
#newRunModal .grid-3 {
  display: grid !important;
}
#newRunModal strong[style*="#7dd3fc"] {
  color: #0369A1 !important;
}
#newRunModal #nrSpecNote {
  color: #92400E !important;
  font-weight: 700 !important;
}
#nrCommAlert,
#nrCommAlert *,
#nrWatchAlert,
#nrWatchAlert * {
  color: #0F172A !important;
}
#nrCommAlert > div,
#nrWatchAlert > div {
  background: #ECFDF5 !important;
  border: 1.5px solid #16A34A !important;
  color: #14532D !important;
  font-weight: 700 !important;
}
#nrCommAlert > div[style*="#ef4444"],
#nrCommAlert > div[style*="239,68,68"],
#nrWatchAlert > div[style*="#ef4444"],
#nrWatchAlert > div[style*="239,68,68"] {
  background: #FEF2F2 !important;
  border-color: #DC2626 !important;
  color: #991B1B !important;
}
#nrCommAlert > div[style*="#f59e0b"],
#nrCommAlert > div[style*="245,158,11"],
#nrWatchAlert > div[style*="#f59e0b"],
#nrWatchAlert > div[style*="245,158,11"] {
  background: #FFFBEB !important;
  border-color: #D97706 !important;
  color: #78350F !important;
}
#nrAdvancedDetails summary {
  color: #0B1528 !important;
  background: #F1F5F9 !important;
  border: 1px solid #CBD5E1 !important;
  font-weight: 800 !important;
}

/* v74 uniform topbars */
body.pch-role-driver .hdr,
body.pch-role-dispatch .topbar,
body.pch-role-driver .ps-top {
  min-height: 58px !important;
  padding: 8px 16px !important;
  background: #0B1528 !important;
  color: #FFFFFF !important;
  border-bottom: 2px solid #FACC15 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  box-sizing: border-box !important;
}
body.pch-role-dispatch .topbar .brand {
  display: inline-flex !important;
  align-items: center !important;
  gap: 9px !important;
  color: #FFFFFF !important;
  font-weight: 900 !important;
  font-size: 15px !important;
}
body.pch-role-driver .hdr .pch-sq-logo,
body.pch-role-dispatch .topbar .pch-sq-logo,
body.pch-role-driver .ps-top .pch-sq-logo {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 7px !important;
  background: #0B1528 !important;
  border: 2px solid #FACC15 !important;
  color: #FACC15 !important;
  font-weight: 900 !important;
  font-size: 11px !important;
  flex-shrink: 0 !important;
}

/* v89 mobile-first zero-overflow header & layout */
html, body {
  max-width: 100% !important;
  overflow-x: clip !important;
}
@media (min-width: 769px) {
  html {
    overflow-y: scroll !important;
    scrollbar-gutter: stable;
  }
}
body.pch-role-driver,
body.pch-role-dispatch {
  margin: 0 !important;
  padding-top: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: clip !important;
  box-sizing: border-box !important;
}
#pchPreviewBar,
#pchBetaBar {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}
body.pch-role-driver .hdr,
body.pch-role-dispatch .topbar,
body.pch-role-driver .ps-top {
  width: 100% !important;
  max-width: 100% !important;
  height: 58px !important;
  min-height: 58px !important;
  max-height: 58px !important;
  padding: 0 14px !important;
  margin: 0 !important;
  border-radius: 0 !important;
  background: #0B1528 !important;
  color: #FFFFFF !important;
  border-bottom: 2px solid #FACC15 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  position: relative !important;
  top: auto !important;
}
body.pch-role-driver .hdr-brand,
body.pch-role-dispatch .topbar .brand,
body.pch-role-driver .ps-top .ps-brand {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  overflow: hidden !important;
}
body.pch-role-driver .pch-hdr-meta,
body.pch-role-driver .ps-top .ps-brand-txt {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  overflow: hidden !important;
}
body.pch-role-driver .pch-hdr-meta > *,
body.pch-role-driver .hdr-brand h1,
body.pch-role-driver .hdr-brand h2,
body.pch-role-driver .hdr-brand strong,
body.pch-role-driver .hdr-brand small,
body.pch-role-driver .ps-top .ps-brand-txt strong,
body.pch-role-driver .ps-top .ps-brand-txt span {
  display: block !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
body.pch-role-driver .hdr-actions,
body.pch-role-driver .ps-top .ps-top-btns {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
  flex-shrink: 0 !important;
}
body.pch-role-dispatch .topbar .nav {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  scrollbar-width: none;
  max-width: 100%;
}
body.pch-role-dispatch .topbar .nav::-webkit-scrollbar { display: none; }
body.pch-role-dispatch .topbar .nav button,
body.pch-role-driver .hdr-actions button,
body.pch-role-driver .hdr button {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}
#pchHeaderSoloBtn {
  background: #FACC15 !important;
  color: #0B1528 !important;
  border: 1.5px solid #FACC15 !important;
  border-radius: 8px !important;
  padding: 5px 10px !important;
  height: 34px !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* Mobile 390px-safe overrides */
@media (max-width: 640px) {
  body.pch-role-driver .hdr,
  body.pch-role-driver .ps-top {
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    padding: 0 8px !important;
    gap: 6px !important;
  }
  body.pch-role-dispatch .topbar {
    height: auto !important;
    max-height: none !important;
    padding: 8px 10px !important;
    flex-wrap: wrap !important;
  }
  body.pch-role-driver .hdr-brand .pch-sq-logo,
  body.pch-role-driver .ps-top .pch-sq-logo {
    width: 28px !important;
    height: 28px !important;
    font-size: 10px !important;
    flex-shrink: 0 !important;
  }
  body.pch-role-driver .pch-hdr-meta > :first-child,
  body.pch-role-driver .ps-top .ps-brand-txt strong {
    font-size: 12.5px !important;
    line-height: 1.15 !important;
  }
  body.pch-role-driver .pch-hdr-meta > :not(:first-child),
  body.pch-role-driver .ps-top .ps-brand-txt span {
    font-size: 10.5px !important;
    line-height: 1.15 !important;
  }
  body.pch-role-driver .hdr-actions,
  body.pch-role-driver .ps-top .ps-top-btns {
    gap: 4px !important;
  }
  #pchHeaderSoloBtn,
  body.pch-role-driver .hdr button,
  body.pch-role-driver .ps-top .ps-mini-btn {
    padding: 4px 7px !important;
    height: 30px !important;
    min-height: 30px !important;
    font-size: 11px !important;
    border-radius: 7px !important;
  }
  body.pch-role-driver .wrap,
  body.pch-role-driver #app,
  body.pch-role-driver main,
  body.pch-role-driver .card {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }
  body.pch-role-driver .card,
  body.pch-role-driver .run-card {
    padding: 12px !important;
  }
  body.pch-role-driver .subtabs,
  body.pch-role-driver .tabs,
  body.pch-role-driver .tab-bar {
    display: flex !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    gap: 4px !important;
    box-sizing: border-box !important;
  }
  body.pch-role-driver .bottom-nav,
  body.pch-role-driver nav.bottom-nav {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    box-sizing: border-box !important;
  }
  body.pch-role-driver .bottom-nav button {
    padding: 6px 3px !important;
    font-size: 11px !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}
