:root {
  --forest: #2d5a45;
  --forest-dark: #1f3f31;
  --beige: #f4efe6;
  --sand: #e8dfd1;
  --white: #ffffff;
  --blue: #3b6ea8;
  --blue-soft: #e8f0fa;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #b45309;
  --danger-bg: #fff7ed;
  --success: #166534;
  --success-bg: #ecfdf5;
  --warning-bg: #fef9c3;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(31, 41, 55, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--beige) 0%, #faf8f4 240px);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

.shell { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 3rem; }

.topbar {
  background: var(--forest);
  color: #fff;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar__brand { font-weight: 700; font-size: 1.05rem; }
.topbar__nav { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.topbar a { color: #fff; font-size: 0.9rem; }

.page-title { font-size: 1.5rem; font-weight: 700; margin: 1.25rem 0 0.5rem; color: var(--forest-dark); }
.page-subtitle { color: var(--muted); margin: 0 0 1.25rem; }

.flash-stack { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9375rem;
}
.flash--success { background: var(--success-bg); color: var(--success); }
.flash--warning { background: var(--warning-bg); color: #854d0e; }
.flash--danger { background: var(--danger-bg); color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 12px;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--forest); color: #fff; box-shadow: var(--shadow); }
.btn--primary:hover { background: var(--forest-dark); color: #fff; text-decoration: none; }
.btn--primary:disabled,
.btn--primary[disabled] {
  background: #b8c4bb;
  color: #eef2ef;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}
.btn--primary:disabled:hover,
.btn--primary[disabled]:hover { background: #b8c4bb; color: #eef2ef; }
.btn--secondary { background: var(--white); color: var(--forest); border: 1px solid var(--sand); }
.btn--danger { background: #fff; color: var(--danger); border: 1px solid #fdba74; }
.btn--block { width: 100%; }

.card-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .card-grid--2 { grid-template-columns: repeat(2, 1fr); } }

.ride-card {
  background: var(--white);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow);
  animation: fadeIn 0.2s ease;
}
.ride-card__title { font-size: 1.125rem; font-weight: 700; margin: 0 0 0.25rem; }
.ride-card__meta { color: var(--muted); font-size: 0.875rem; margin-bottom: 0.75rem; }
.ride-card__footer { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-top: 0.75rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge--open { background: var(--success-bg); color: var(--success); }
.badge--full { background: #fee2e2; color: #991b1b; }
.badge--pending { background: var(--warning-bg); color: #854d0e; }
.badge--cancelled { background: #f3f4f6; color: #4b5563; }
.badge--completed { background: var(--blue-soft); color: var(--blue); }

.seat-pill {
  font-weight: 700;
  color: var(--forest);
  background: #edf5f0;
  border-radius: 999px;
  padding: 0.25rem 0.625rem;
  font-size: 0.875rem;
}

.panel {
  background: var(--white);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.form-grid { display: grid; gap: 1rem; }
.form-field label { display: block; font-weight: 600; margin-bottom: 0.375rem; font-size: 0.9rem; }
.form-field--checkbox { margin: 0.125rem 0; }
.form-field__checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0;
  width: fit-content;
  max-width: 100%;
}
.form-field__checkbox-row input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex: 0 0 1.125rem;
  cursor: pointer;
  accent-color: var(--forest);
}
.form-field__checkbox-row span {
  line-height: 1.3;
}
.form-field__help { margin: 0.375rem 0 0; font-size: 0.85rem; color: var(--text-muted, #5c6b5f); line-height: 1.4; }
.form-field input:not([type="checkbox"]),
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.75rem 0.875rem;
  font-size: 1rem;
  background: #fff;
}
.form-field textarea { min-height: 100px; resize: vertical; }
.form-errors { color: var(--danger); font-size: 0.875rem; margin-top: 0.25rem; }

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data-table th,
table.data-table td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--sand); text-align: left; }
table.data-table th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 1rem; border: 1px solid var(--sand); }
.stat-card__value { font-size: 1.75rem; font-weight: 700; color: var(--forest); }
.stat-card__label { color: var(--muted); font-size: 0.8125rem; }

.loading { opacity: 0.6; pointer-events: none; }

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

@keyframes seatPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.seat-pill.is-updated { animation: seatPop 0.35s ease; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: 18px;
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--sand);
}
.login-card h1 { margin: 0 0 0.25rem; color: var(--forest-dark); }
.login-card p { color: var(--muted); margin-top: 0; }

.app-shell { max-width: 720px; margin: 0 auto; padding: 0 0 5.5rem; min-height: 100vh; }
.mobile-page { padding: 1rem 1rem 1.5rem; }
.hero-header { margin: 0.5rem 0 1.25rem; }
.hero-header__greeting { color: var(--muted); margin: 0 0 0.25rem; font-size: 0.9375rem; }
.hero-header__title { margin: 0; font-size: 1.625rem; font-weight: 700; color: var(--forest-dark); line-height: 1.2; }
.hero-header__subtitle { margin: 0.375rem 0 0; color: var(--muted); font-size: 0.9375rem; }
.trip-board-section { margin-bottom: 1.5rem; }
.trip-board-section__title { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 0.75rem; }
.trip-board { display: grid; gap: 1rem; }
.trip-card { display: grid; grid-template-columns: 88px 1fr; gap: 0.875rem; background: var(--white); border: 1px solid var(--sand); border-radius: var(--radius); padding: 0.875rem; box-shadow: var(--shadow); }
.trip-card--compact { grid-template-columns: 64px 1fr; }
.trip-card__visual { border-radius: 12px; overflow: hidden; background: #edf5f0; min-height: 88px; display: flex; align-items: center; justify-content: center; }
.trip-card--compact .trip-card__visual { min-height: 64px; }
.trip-card__img { width: 100%; height: 100%; object-fit: cover; min-height: 88px; }
.trip-card__emoji { font-size: 2rem; line-height: 1; }
.trip-card__title { margin: 0 0 0.25rem; font-size: 1.125rem; font-weight: 700; color: var(--forest-dark); }
.trip-card__meta { margin: 0; color: var(--muted); font-size: 0.875rem; }
.trip-card__location { margin: 0.25rem 0 0; font-size: 0.8125rem; color: var(--text); }
.trip-card__footer { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.625rem; }
.trip-card__actions { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
.seat-pill--full { background: #fee2e2; color: #991b1b; }
.trip-hero { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; min-height: 180px; background: linear-gradient(135deg, #5a8f72, var(--forest)); }
.trip-hero__img { width: 100%; height: 180px; object-fit: cover; display: block; }
.trip-hero__emoji { font-size: 4rem; text-align: center; padding: 2.5rem 0 1rem; }
.trip-hero__overlay { position: absolute; inset: auto 0 0 0; padding: 1rem 1.125rem; background: linear-gradient(transparent, rgba(0,0,0,0.65)); color: #fff; }
.trip-hero__overlay h1 { margin: 0 0 0.375rem; font-size: 1.375rem; }
.detail-list { list-style: none; margin: 0; padding: 0; }
.detail-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--sand); font-size: 0.9375rem; }
.trip-detail-panel__seats { margin: 1rem 0 0; font-weight: 600; color: var(--forest); }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: var(--white); border-top: 1px solid var(--sand); padding: 0.375rem 0 calc(0.375rem + env(safe-area-inset-bottom)); z-index: 50; box-shadow: 0 -4px 16px rgba(31,41,55,0.06); }
.bottom-nav__link { display: flex; flex-direction: column; align-items: center; gap: 0.125rem; padding: 0.5rem 0.75rem; color: var(--muted); font-size: 0.6875rem; font-weight: 600; text-decoration: none; min-width: 72px; }
.bottom-nav__link.is-active { color: var(--forest); }
.bottom-nav__icon { font-size: 1.25rem; line-height: 1; }
.tab-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab-row__tab { padding: 0.5rem 0.875rem; border-radius: 999px; background: var(--white); border: 1px solid var(--sand); color: var(--text); font-size: 0.875rem; font-weight: 600; text-decoration: none; }
.tab-row__tab.is-active { background: var(--forest); color: #fff; border-color: var(--forest); }
.featured-trip { background: var(--white); border: 1px solid var(--sand); border-radius: 18px; padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; text-align: center; }
.featured-trip__badge { display: inline-block; background: #ecfdf5; color: var(--success); font-weight: 700; font-size: 0.8125rem; padding: 0.375rem 0.75rem; border-radius: 999px; margin-bottom: 0.75rem; }
.featured-trip__visual { font-size: 3rem; margin-bottom: 0.5rem; }
.featured-trip__title { margin: 0 0 0.375rem; font-size: 1.375rem; color: var(--forest-dark); }
.featured-trip__meta { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.9375rem; }
.featured-trip__actions { display: grid; gap: 0.625rem; margin-top: 1rem; }
.checklist-form .checklist-group { border: 1px solid var(--sand); border-radius: 12px; padding: 1rem; margin: 0; }
.checklist-form legend { font-weight: 700; padding: 0 0.25rem; }
.checklist-item { display: flex !important; align-items: center; gap: 0.625rem; padding: 0.625rem 0; border-bottom: 1px solid #f3f4f6; font-size: 1rem; }
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.checklist-item--important { font-weight: 600; color: var(--forest-dark); }
.vehicle-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.vehicle-card { background: var(--white); border: 1px solid var(--sand); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.vehicle-card__visual { height: 120px; background: #f3f6f4; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.vehicle-card__visual img { width: 100%; height: 100%; object-fit: cover; }
.vehicle-card__body { padding: 1rem; }
.vehicle-card__title { margin: 0 0 0.25rem; font-size: 1.0625rem; }
.vehicle-card__meta { margin: 0 0 0.375rem; color: var(--muted); font-size: 0.8125rem; }
.badge--vehicle { font-size: 0.6875rem; margin: 0.375rem 0 0.75rem; display: inline-flex; }
.badge--vehicle-available { background: var(--success-bg); color: var(--success); }
.badge--vehicle-assigned { background: var(--blue-soft); color: var(--blue); }
.badge--vehicle-needs_service { background: var(--danger-bg); color: var(--danger); }
.badge--vehicle-inactive { background: #f3f4f6; color: #4b5563; }
.empty-state { text-align: center; color: var(--muted); }
.trip-template-picker { margin-bottom: 1rem; }
.trip-template-picker__select { width: 100%; }

/* Pre-trip odometer */
.odometer-field__label,
.fuel-fader-field__label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.375rem;
  font-size: 0.9rem;
}
.odometer {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  background: #1a1a1a;
  border-radius: 14px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}
.odometer__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.odometer__step {
  width: 2.75rem;
  height: 2rem;
  border: 1px solid #3d4a42;
  border-radius: 8px;
  background: #eef2ef;
  color: var(--forest-dark, #1f3d2d);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.odometer__step:active { background: #dce8df; transform: scale(0.97); }
.seg-digit {
  position: relative;
  width: 2.1rem;
  height: 3.4rem;
}
.seg {
  position: absolute;
  background: #2a0909;
  border-radius: 2px;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.seg.is-on {
  background: #ff4d4d;
  box-shadow: 0 0 8px rgba(255, 77, 77, 0.65);
}
.seg-a { top: 0; left: 0.35rem; right: 0.35rem; height: 0.28rem; }
.seg-b { top: 0.28rem; right: 0; width: 0.28rem; height: 1.35rem; }
.seg-c { bottom: 0.28rem; right: 0; width: 0.28rem; height: 1.35rem; }
.seg-d { bottom: 0; left: 0.35rem; right: 0.35rem; height: 0.28rem; }
.seg-e { bottom: 0.28rem; left: 0; width: 0.28rem; height: 1.35rem; }
.seg-f { top: 0.28rem; left: 0; width: 0.28rem; height: 1.35rem; }
.seg-g { top: 1.55rem; left: 0.35rem; right: 0.35rem; height: 0.28rem; }

/* Pre-trip fuel fader */
.fuel-fader {
  --fuel-thumb-size: 2.35rem;
  --fuel-step-count: 8;
  padding: 1rem;
  background: #f7faf8;
  border: 1px solid var(--sand, #e5e0d5);
  border-radius: 14px;
}
.fuel-fader__value {
  display: block;
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--forest-dark, #1f3d2d);
  margin-bottom: 0.75rem;
}
.fuel-fader__track-wrap {
  position: relative;
  padding: 2rem 0 0.5rem;
}
.fuel-fader__mark-labels {
  position: absolute;
  left: calc(var(--fuel-thumb-size) / 2);
  right: calc(var(--fuel-thumb-size) / 2);
  top: 0.15rem;
  height: 1.25rem;
  pointer-events: none;
}
.fuel-fader__mark {
  position: absolute;
  left: calc(var(--mark-pos) / var(--fuel-step-count) * 100%);
  transform: translateX(-50%);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--forest-dark, #1f3d2d);
  line-height: 1;
}
.fuel-fader__rail {
  position: relative;
  height: var(--fuel-thumb-size);
  margin: 0.75rem 0 0.5rem;
  touch-action: none;
  cursor: pointer;
  outline: none;
}
.fuel-fader__rail:focus-visible .fuel-fader__thumb {
  outline: 2px solid var(--forest, #2d5a45);
  outline-offset: 3px;
}
.fuel-fader__track {
  position: absolute;
  left: calc(var(--fuel-thumb-size) / 2);
  right: calc(var(--fuel-thumb-size) / 2);
  top: 50%;
  transform: translateY(-50%);
  height: 0.55rem;
  background: #d8e4dc;
  border-radius: 999px;
  pointer-events: none;
}
.fuel-fader__steps {
  position: absolute;
  left: calc(var(--fuel-thumb-size) / 2);
  right: calc(var(--fuel-thumb-size) / 2);
  top: 0;
  bottom: 0;
  pointer-events: none;
}
.fuel-fader__tick {
  position: absolute;
  left: calc(var(--tick-index) / var(--fuel-step-count) * 100%);
  top: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 10px;
  background: #b8c4bb;
  border-radius: 1px;
}
.fuel-fader__thumb {
  position: absolute;
  left: calc(
    (var(--fuel-thumb-size) / 2) +
    (var(--fuel-index) / var(--fuel-step-count)) *
    (100% - var(--fuel-thumb-size))
  );
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--fuel-thumb-size);
  height: var(--fuel-thumb-size);
  border-radius: 50%;
  background: var(--forest, #2d5a45);
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(31, 61, 45, 0.28);
  pointer-events: none;
}
.fuel-fader__labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--muted, #5c6b5f);
  margin-top: 0.25rem;
  padding: 0 calc(var(--fuel-thumb-size) / 2);
}

.muted { color: var(--muted); }
.topbar--compact { padding: 0.625rem 1rem; }
@media (min-width: 768px) { .bottom-nav { max-width: 720px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; } }
