* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f2f4f7;
  color: #111827;
  -webkit-text-size-adjust: 100%;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0f172a;
}

.login-screen[hidden] {
  display: none;
}

.login-form {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 20px;
  color: #111827;
  text-align: center;
}

.login-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
  margin: 16px 0 6px;
}

.login-input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
}

.login-input:focus {
  outline: 2px solid #1a56db;
  outline-offset: 1px;
}

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.login-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  border: none;
  border-radius: 10px;
  background: #1a56db;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-home-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
}

.panel-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0f172a;
}

.panel-screen[hidden] {
  display: none;
}

.panel-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.panel-title {
  margin: 0 0 4px;
  font-size: 1.5rem;
  text-align: center;
}

.panel-subtitle {
  margin: 0 0 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6b7280;
  text-align: center;
}

.panel-action {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  border: 2px solid #1a56db;
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.panel-action:active {
  background: #eef2ff;
}

.panel-action-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a56db;
}

.panel-action-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  color: #6b7280;
}

.terms-text {
  margin-top: 16px;
  padding: 14px;
  max-height: 42vh;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #374151;
  white-space: pre-wrap;
}

.panel-label {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #374151;
}

.panel-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
}

.panel-input:focus {
  outline: 2px solid #1a56db;
  outline-offset: 1px;
}

.panel-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
}

.panel-check input {
  width: 22px;
  height: 22px;
}

.panel-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.panel-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  border: none;
  border-radius: 8px;
  background: #1a56db;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.panel-submit:disabled {
  background: #9ca3af;
}

.panel-back {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.menu-btn {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #0f172a;
  color: #fff;
  padding: env(safe-area-inset-top, 0) 16px 12px;
  padding-top: calc(env(safe-area-inset-top, 0) + 12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.asset-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.route-status {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-clear {
  background: #16a34a;
  color: #fff;
}

.status-blocked {
  background: #dc2626;
  color: #fff;
}

.status-unknown {
  background: #6b7280;
  color: #fff;
}

.demo-banner {
  background: #92400e;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 12px;
}

.location-banner {
  background: #f3f4f6;
  color: #4b5563;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 6px 12px;
}

/* Shown when a trip loaded from the local cache instead of a live
   request (see fetchTrip's offline fallback in app.js) -- same visual
   language as .demo-banner (both mean "what you're looking at isn't a
   fresh live answer") but a distinct colour so the two are never
   confused with each other. */
.offline-banner {
  background: #475569;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 12px;
}

/* Placeholder shown in the map area when Google Maps itself never loaded
   (offline, blocked, or simply too slow) -- see renderMap's mapAvailable
   guard in app.js. The route data underneath (turn banner, bridge
   proximity, auto-reroute) still works fine without it. */
.map-unavailable {
  height: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: #dfe3e8;
  color: #4b5563;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
}

.turn-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #0f172a;
  color: #fff;
  padding: 14px 16px;
}

.turn-banner[hidden] {
  display: none;
}

/* Proactive "bridge coming up" alert -- distinct from the turn banner
   (which is about direction, not restrictions) so a driver gets an
   advance warning of the restriction itself, not just a name buried in
   the scrollable card list below the map. Same severity colours as the
   bridge cards/map dots (see bridgeSeverity() in app.js). */
.bridge-alert {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.bridge-alert[hidden] {
  display: none;
}

.bridge-alert.severity-yellow {
  background: #f59e0b;
  color: #1a1a1a;
}

.bridge-alert.severity-red {
  background: #dc2626;
  color: #fff;
}

.turn-arrow {
  font-size: 2rem;
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
  line-height: 1;
}

.turn-text {
  font-size: 1.15rem;
  font-weight: 700;
}

.map-wrap {
  position: relative;
}

.recenter-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #1a56db;
  font-size: 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.recenter-btn:active {
  background: #e5e7eb;
}

.reroute-btn {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 10;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.reroute-btn:active {
  background: #d97706;
}

.reroute-btn:disabled {
  background: #d1d5db;
  cursor: default;
}

/* Quick, self-dismissing confirmation that an AUTOMATIC reroute just
   happened (see checkAutoReroute() in app.js) -- distinct from the
   persistent turn/bridge banners, which stay up until their condition
   changes. Same amber as the manual reroute button, for the same reason
   (reroute = amber, consistently). */
.reroute-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 64px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: #f59e0b;
  color: #1a1a1a;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.reroute-toast[hidden] {
  display: none;
}

.error-banner {
  background: #fef2f2;
  color: #991b1b;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  padding: 16px;
  border-bottom: 1px solid #fecaca;
}

.map {
  width: 100%;
  height: 42vh;
  min-height: 240px;
  background: #dfe3e8;
}

.restrictions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.restrictions[hidden] {
  display: none;
}

.restriction-chip {
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.bridge-list {
  padding: 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 24px);
}

.bridge-empty {
  margin: 0;
  padding: 16px;
  background: #fff;
  border-radius: 12px;
  color: #4b5563;
  font-size: 0.95rem;
  font-weight: 600;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: #374151;
}

.bridge-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bridge-list-header .section-title {
  margin-bottom: 0;
}

/* Downloads this trip's bridge list as a CSV -- the "prove it" record,
   ready to hand over without retyping anything by hand. See
   downloadRouteRecordCsv() in app.js. */
.download-record-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a56db;
  background: #eef2ff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.download-record-btn[hidden] {
  display: none;
}

/* Bridge severity colour code -- green (Own Lane), yellow (Central/Offset),
   red (Do Not Cross). See bridgeSeverity() in app.js for the exact rule.
   Full solid background, not just a border/tint, so severity reads at a
   glance from a driver's seat -- this was a deliberate ask, not a subtle
   accent. Text colour picked per background for contrast (dark text on the
   lighter yellow, white on the darker green/red). */
.bridge-card {
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 6px solid transparent;
}

.bridge-card.severity-green {
  background: #16a34a;
  border-left-color: #15803d;
  color: #fff;
}

.bridge-card.severity-yellow {
  background: #f59e0b;
  border-left-color: #b45309;
  color: #1a1a1a;
}

.bridge-card.severity-red {
  background: #dc2626;
  border-left-color: #991b1b;
  color: #fff;
}

.bridge-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.bridge-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: inherit;
}

.bridge-distance {
  font-size: 0.95rem;
  font-weight: 600;
  color: inherit;
  opacity: 0.85;
}

.bridge-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* One consistent pill style for all badges, on top of any of the three
   card colours above -- a near-opaque white pill with dark text reads
   clearly against green, yellow, or red alike, rather than needing a
   separate colour combination tuned for each card colour. */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
}

.badge-danger {
  background: #000;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

@media (min-width: 600px) {
  .map {
    height: 50vh;
  }

  .bridge-list {
    max-width: 720px;
    margin: 0 auto;
  }
}
