/* ===== NOMAD TRAK — OUTBACK THEME ===== */
:root {
  --bg:        #1A1208;
  --surface:   #2A1D0F;
  --elevated:  #3A2815;
  --card:      #321E0C;
  --border:    #4A3520;
  --orange:    #E8700A;
  --rust:      #C44B00;
  --gold:      #D4A82A;
  --green:     #5A8A3C;
  --red:       #D94F4F;
  --text:      #F5ECD7;
  --text2:     #B8A882;
  --text3:     #7A6A4A;
  --radius:    12px;
  --radius-sm: 8px;
}

/* ===== LIGHT MODE ===== */
body.light {
  --bg:        #F2EBE0;
  --surface:   #FFFAF4;
  --elevated:  #EDE3D4;
  --card:      #FDF6EC;
  --border:    #D4C4A8;
  --orange:    #C45A00;
  --rust:      #A83A00;
  --gold:      #8A6410;
  --green:     #3A6A20;
  --red:       #B83030;
  --text:      #1A1208;
  --text2:     #5A4A2A;
  --text3:     #9A8060;
}
body.light .leaflet-container { background: #E8DDD0; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  overscroll-behavior: none;
}

/* ===== LAYOUT ===== */
#app { display: flex; flex-direction: column; height: 100dvh; }

.screen { display: none; flex: 1; overflow-y: auto; padding-bottom: 80px; }
.screen.active { display: block; }
/* Extra clearance on plan/budget screens so FAB doesn't cover last card */
#screen-plan, #screen-budget { padding-bottom: 140px; }

/* ===== TOP BAR ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 100;
  min-height: 56px;
}
.topbar h1 { font-size: 20px; font-weight: 700; color: var(--orange); flex: 1; }
.topbar h2 { font-size: 17px; font-weight: 600; flex: 1; }
.back-btn {
  background: none; border: none; color: var(--orange);
  font-size: 22px; cursor: pointer; padding: 4px; line-height: 1;
}
.topbar-actions { display: flex; gap: 8px; }

/* ===== BOTTOM NAV ===== */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 8px 2px;
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
  gap: 3px; transition: color 0.15s;
}
.nav-btn .icon { font-size: 20px; line-height: 1; }
.nav-btn.active { color: var(--orange); }

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 16px 0;
}
.card-tap { cursor: pointer; transition: border-color 0.15s; }
.card-tap:active { border-color: var(--orange); }

.card-title {
  font-size: 16px; font-weight: 700; margin-bottom: 4px;
}
.card-sub { font-size: 13px; color: var(--text2); }
.card-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.card-row:last-child { border-bottom: none; padding-bottom: 0; }
.card-row-label { font-size: 14px; color: var(--text2); }
.card-row-value { font-size: 14px; font-weight: 600; }

/* ===== SECTION HEADERS ===== */
.section-header {
  padding: 20px 16px 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text3);
}

/* ===== FAB (Floating Action Button) ===== */
.fab {
  position: fixed; bottom: 80px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--orange); border: none; color: white;
  font-size: 26px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(232,112,10,0.4);
  z-index: 99; transition: transform 0.15s;
}
.fab:active { transform: scale(0.93); }

/* ===== FORMS ===== */
.form-group { margin: 12px 16px 0; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text2); margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 12px 14px;
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 16px; outline: none;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--orange); }
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; margin-left: 0; margin-right: 0; }
.form-row .form-group:first-child { margin-left: 16px; }
.form-row .form-group:last-child { margin-right: 16px; }

/* ===== BUTTONS ===== */
.btn {
  display: block; width: calc(100% - 32px); margin: 16px auto 0;
  padding: 14px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-size: 16px; font-weight: 700;
  text-align: center; transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--orange); color: white; }
.btn-secondary { background: var(--elevated); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red); color: white; }
.btn-sm {
  display: inline-block; width: auto; margin: 0;
  padding: 8px 14px; font-size: 13px;
}

/* ===== EMPTY STATE ===== */
.empty {
  text-align: center; padding: 60px 24px;
  color: var(--text3);
}
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty h3 { font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty p { font-size: 14px; line-height: 1.6; }

/* ===== BADGE ===== */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge-orange { background: rgba(232,112,10,0.2); color: var(--orange); }
.badge-gold { background: rgba(212,168,42,0.2); color: var(--gold); }
.badge-green { background: rgba(90,138,60,0.2); color: var(--green); }
.badge-red { background: rgba(217,79,79,0.2); color: var(--red); }

/* ===== HERO BANNER ===== */
.hero-banner {
  margin: 12px 16px 4px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  height: 160px;
  background-size: cover;
  background-position: center;
  /* Dark mode: outback starry night — Milky Way over red desert */
  background-image: url('https://images.unsplash.com/photo-1472214103451-9374bd1c798e?w=800&fit=crop&q=80');
}
body.light .hero-banner {
  /* Light mode: Australian outback red earth road */
  background-image: url('https://images.unsplash.com/photo-1529108190281-9a4f620bc2d8?w=800&fit=crop&q=80');
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(10,5,0,0.85) 40%, rgba(0,0,0,0.2) 100%);
}
body.light .hero-overlay {
  background: linear-gradient(to top, rgba(80,30,0,0.75) 40%, rgba(0,0,0,0.1) 100%);
}
.hero-text {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 12px 16px 14px;
}
.hero-tagline {
  font-size: 16px; font-weight: 800; color: #fff;
  letter-spacing: 0.2px; line-height: 1.2;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.hero-sub {
  font-size: 12px; color: rgba(255,255,255,0.75); margin-top: 3px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.hero-text {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 10px 14px 12px;
  background: linear-gradient(to top, rgba(26,12,5,0.95) 60%, transparent);
}
.hero-tagline {
  font-size: 15px; font-weight: 800; color: var(--orange);
  letter-spacing: 0.2px; line-height: 1.2;
}
.hero-sub {
  font-size: 11px; color: var(--text2); margin-top: 2px;
}

/* ===== TRIP CARD ===== */
.trip-card {
  position: relative;
  border-left: 3px solid var(--orange);
}
.trip-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.trip-card-name {
  font-size: 17px; font-weight: 700; flex: 1; padding-right: 28px; line-height: 1.3;
}
.trip-card-total {
  font-size: 20px; font-weight: 800; color: var(--gold);
  white-space: nowrap;
}
.trip-card-meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; flex-wrap: wrap;
}
.trip-total {
  margin-left: auto; font-size: 18px; font-weight: 700; color: var(--gold);
}
.trip-delete {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; color: var(--text3);
  font-size: 16px; cursor: pointer; padding: 4px;
}
.trip-card-vehicle {
  margin-top: 8px; font-size: 12px; color: var(--text3);
  display: flex; align-items: center; gap: 4px;
}

/* ===== STOP CARD ===== */
.stop-card { position: relative; }
.stop-num {
  position: absolute; top: -1px; left: -1px;
  width: 28px; height: 28px; border-radius: var(--radius) 0 var(--radius-sm) 0;
  background: var(--orange); color: white;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.stop-card-content { padding-left: 20px; }
.stop-leg {
  display: flex; align-items: center; gap: 8px;
  color: var(--text2); font-size: 12px; margin-top: 6px;
}
.stop-delete {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--text3);
  font-size: 18px; cursor: pointer;
}

/* ===== BUDGET SUMMARY ===== */
.budget-total-card {
  background: linear-gradient(135deg, #3A2010, #2A1D0F);
  border-color: var(--orange);
}
body.light .budget-total-card {
  background: linear-gradient(135deg, #FFF3E0, #FDEBD0);
}
.budget-total-label { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.budget-total-amount { font-size: 36px; font-weight: 800; color: var(--gold); }
.budget-total-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

.budget-bar-wrap { margin-top: 12px; }
.budget-bar-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text2); margin-bottom: 5px;
}
.budget-bar-track {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.budget-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }

/* ===== MAP ===== */
#map { height: calc(100dvh - 56px - 60px); width: 100%; }

/* ===== HELP SCREEN ===== */
#screen-help { overflow-y: auto; }
.help-section {
  margin: 0 16px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.help-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.help-section-header:active { background: var(--elevated); }
.help-chevron {
  font-size: 18px;
  color: var(--orange);
  transition: transform 0.2s ease;
  display: inline-block;
}
.help-section-body {
  padding: 0 16px 16px;
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
.help-section-body p { margin: 10px 0; }
.help-section-body ul, .help-section-body ol {
  padding-left: 20px;
  margin: 8px 0;
}
.help-section-body li { margin-bottom: 6px; }
.help-section-body strong { color: var(--text); }
.help-tip {
  background: var(--elevated);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.help-table th {
  background: var(--elevated);
  color: var(--orange);
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.help-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.help-table tr:last-child td { border-bottom: none; }
.leaflet-container { background: #1A1208; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200; display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: 20px 20px 0 0;
  width: 100%; max-height: 92dvh;
  overflow-y: auto; padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-handle {
  width: 36px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 12px auto 0;
}
.modal-title {
  padding: 16px 16px 4px; font-size: 18px; font-weight: 700;
}
.modal-actions {
  display: flex; gap: 10px; padding: 16px;
}
.modal-actions .btn { margin: 0; flex: 1; }

/* ===== DIVIDER ===== */
.divider { height: 1px; background: var(--border); margin: 12px 16px; }

/* ===== INSTALL BANNER ===== */
.install-banner {
  margin: 12px 16px 0;
  background: rgba(232,112,10,0.12);
  border: 1px solid rgba(232,112,10,0.3);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.install-banner p { font-size: 13px; color: var(--text2); flex: 1; line-height: 1.4; }
.install-banner button {
  background: var(--orange); border: none; color: white;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* ===== CURRENCY SELECTOR ===== */
.currency-btn-wrap {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px;
}
.currency-btn {
  padding: 9px 12px;
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.currency-btn.active {
  border-color: var(--orange);
  background: rgba(232,112,10,0.12);
  color: var(--orange);
}

/* ===== THEME TOGGLE ===== */
.theme-toggle-wrap {
  display: flex; gap: 10px; margin-top: 4px;
}
.theme-btn {
  flex: 1; padding: 12px 8px;
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.theme-btn.active {
  border-color: var(--orange);
  background: rgba(232,112,10,0.12);
  color: var(--orange);
}

/* ===== UTILITIES ===== */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-orange { color: var(--orange); }
.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text2); }
.text-sm { font-size: 13px; }
.fw-bold { font-weight: 700; }
.text-right { text-align: right; }
.p-16 { padding: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ===== RECEIPT PHOTOS ===== */
.receipt-photo-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 11px 14px; margin-top: 8px;
  background: var(--elevated); border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm); color: var(--text2);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.receipt-photo-btn:active { border-color: var(--orange); color: var(--orange); }

.receipt-photo-btn-sm {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: var(--elevated);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text2); font-size: 12px; cursor: pointer;
}
.receipt-photo-btn-sm:active { border-color: var(--orange); color: var(--orange); }

.receipt-thumb-wrap { display: flex; align-items: center; gap: 10px; }

.receipt-thumb {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; flex-shrink: 0;
  transition: opacity 0.15s;
}
.receipt-thumb:active { opacity: 0.75; }

.receipt-thumb-lg {
  width: 100%; max-height: 220px; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; background: rgba(0,0,0,0.25); display: block;
}
.receipt-thumb-lg:active { opacity: 0.85; }

.receipt-remove-btn {
  background: none; border: none; color: var(--red);
  font-size: 12px; cursor: pointer; padding: 4px 0;
  font-weight: 600;
}

.receipt-detail-wrap { padding: 6px 0 10px; }

.receipt-detail-actions { display: flex; gap: 8px; margin-top: 8px; }

.receipt-action-btn {
  padding: 7px 14px; background: var(--elevated);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.receipt-action-btn:active { opacity: 0.7; }
.receipt-action-danger { color: var(--red); border-color: rgba(217,79,79,0.4); }

/* ===== PHOTO VIEWER LIGHTBOX ===== */
#modal-photo-viewer {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.96);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  padding: 16px;
}
#modal-photo-viewer.open { opacity: 1; pointer-events: all; }
#photo-viewer-close {
  position: absolute; top: max(16px, env(safe-area-inset-top));
  right: 16px;
  background: rgba(255,255,255,0.15); border: none; border-radius: 50%;
  width: 40px; height: 40px; color: white; font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
#photo-viewer-img {
  max-width: 100%; max-height: 90dvh;
  object-fit: contain; border-radius: var(--radius);
  display: block;
}
