/* ============================================================
   TRIP BUDGET PLANNER — Design System
   Dark Safari Theme · Mobile-First · No Horizontal Scroll
   ============================================================ */

/* === DESIGN TOKENS === */
:root {
  --bg-deep:        #0d1117;
  --bg-surface:     #161b22;
  --bg-card:        #21262d;
  --bg-card-hover:  #2d333b;
  --primary:        #f0c040;
  --primary-dim:    rgba(240,192,64,0.12);
  --primary-glow:   rgba(240,192,64,0.3);
  --green:          #3fb950;
  --green-dim:      rgba(63,185,80,0.15);
  --blue:           #58a6ff;
  --blue-dim:       rgba(88,166,255,0.15);
  --red:            #f85149;
  --red-dim:        rgba(248,81,73,0.12);
  --orange:         #f97316;
  --text-primary:   #e6edf3;
  --text-secondary: #7d8590;
  --text-muted:     #484f58;
  --border:         #30363d;
  --border-light:   #21262d;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --transition: 0.2s ease;
  /* Category palette */
  --cat-flights:       #6366f1;
  --cat-accommodations:#ec4899;
  --cat-transport:     #14b8a6;
  --cat-taxi:          #f59e0b;
  --cat-food:          #f97316;
  --cat-entertainment: #a855f7;
}

/* === LIGHT THEME OVERRIDES === */
[data-theme="light"] {
  --bg-deep:        #f5f0e8;
  --bg-surface:     #ede8de;
  --bg-card:        #ffffff;
  --bg-card-hover:  #faf7f2;
  --primary:        #c49a00;
  --primary-dim:    rgba(196,154,0,0.10);
  --primary-glow:   rgba(196,154,0,0.25);
  --green:          #1a7f37;
  --green-dim:      rgba(26,127,55,0.12);
  --blue:           #0969da;
  --blue-dim:       rgba(9,105,218,0.12);
  --red:            #d1242f;
  --red-dim:        rgba(209,36,47,0.10);
  --orange:         #bc4c00;
  --text-primary:   #1a1a2e;
  --text-secondary: #57606a;
  --text-muted:     #9ca3af;
  --border:         #d8d0c4;
  --border-light:   #e8e2d8;
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.14);
}

/* Theme transition — smooth but fast */
html, body, .screen, .bottom-nav, .card, input, select, textarea {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

/* Light-mode specific fixes */
html[data-theme="light"],
html[data-theme="light"] body { background: var(--bg-deep); }
html[data-theme="light"] .form-input,
html[data-theme="light"] .form-select,
html[data-theme="light"] .form-textarea {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border);
}
html[data-theme="light"] .form-input:focus,
html[data-theme="light"] .form-select:focus,
html[data-theme="light"] .form-textarea:focus { border-color: var(--primary); }
html[data-theme="light"] .hb-track,
html[data-theme="light"] .tile-bar-track { background: var(--border-light); }
html[data-theme="light"] .hb-bar-committed { background: var(--blue); }
html[data-theme="light"] .welcome-card { background: var(--bg-card); }

/* Theme toggle button */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s, border-color 0.2s;
  touch-action: manipulation;
  white-space: nowrap;
}
.theme-toggle:hover { background: var(--bg-card-hover); border-color: var(--primary); }
.theme-toggle-label { font-size: 11px; font-weight: 500; }


/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Explicit dark background on html so the white default NEVER bleeds through */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1117;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0d1117;
  background: var(--bg-deep);
  color: #e6edf3;
  color: var(--text-primary);
  /* NOTE: do NOT add position:fixed here — #app is already position:fixed.
     Double fixed-positioning corrupts touch hit-testing in iOS WKWebView
     (Mail attachments, Files Quick Look, Messages previews). */
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Eliminate 300ms tap delay on ALL interactive elements */
button, a, input, select, textarea, [onclick], [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* Divs used as buttons (toggle rows, nav items, etc.) */
[onclick] { cursor: pointer; }

/* Global button base — touch-action:manipulation is the iOS fix:
   prevents the 300ms scroll-detection delay inside overflow-scrolling:touch
   containers that silently cancels onclick on buttons */
button {
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
input, select, textarea { font-family: inherit; }


/* === APP CONTAINER === */
#app {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  background: #0d1117;
  background: var(--bg-deep);
}

/* ============================================================
   SCREENS & NAVIGATION
   ============================================================ */
.screen {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: #0d1117;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* visibility:hidden hides ALL descendants including position:fixed children
     (bottom navs, floating emojis) — they cannot block touches on other screens.
     opacity:0 alone does NOT do this for position:fixed children.            */
  visibility: hidden;
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
  z-index: 0;
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1),
              opacity 0.25s ease,
              visibility 0s linear 0.32s;   /* delay matches transform so it hides AFTER sliding out */
}
/* Active screen — fully visible and interactive */
.screen.active {
  visibility: visible;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  z-index: 2;
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1),
              opacity 0.25s ease,
              visibility 0s linear 0s;      /* show immediately when becoming active */
}
/* Slide-back — outgoing screen slides left; hide after transition */
.screen.slide-back {
  visibility: visible;
  opacity: 0.5;
  transform: translateX(-28%);
  pointer-events: none;
  z-index: 1;
}


.screen-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.screen-content.has-bottom-nav { padding-bottom: 76px; }
.screen-content::-webkit-scrollbar { width: 3px; }
.screen-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(13,17,23,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.btn-icon:hover  { background: var(--bg-card-hover); }
.btn-icon:active { transform: scale(0.93); }

/* ============================================================
   BRAND HEADER (Trip List)
   ============================================================ */
.trips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  font-size: 34px;
  filter: drop-shadow(0 2px 12px rgba(240,192,64,0.5));
  animation: floatIcon 3s ease-in-out infinite;
}
@keyframes floatIcon {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.brand-name {
  font-size: 21px;
  font-weight: 800;
  background: linear-gradient(135deg, #f0c040, #ff8a65);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.btn-new-trip {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), #ff8a65);
  color: #0d1117;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px var(--primary-glow);
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-new-trip:hover  { transform: scale(1.1); box-shadow: 0 6px 20px var(--primary-glow); }
.btn-new-trip:active { transform: scale(0.94); }

/* ============================================================
   TRIPS LIST
   ============================================================ */
.trips-list-container { padding: 16px 18px; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 24px 40px;
}
.empty-state-icon {
  font-size: 72px;
  margin-bottom: 16px;
  display: block;
  filter: grayscale(0.2);
}
.empty-state h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.empty-state p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

/* Trip Card */
.trip-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.trip-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), #ff8a65);
  opacity: 0;
  transition: opacity var(--transition);
}
.trip-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: rgba(240,192,64,0.4); }
.trip-card:hover::before { opacity: 1; }
.trip-card.is-active { border-color: rgba(240,192,64,0.35); background: rgba(240,192,64,0.04); }
.trip-card.is-active::before { opacity: 1; }

.trip-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.trip-card-name { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.trip-card-meta { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }

.trip-badge {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 100px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.trip-badge-upcoming  { background: var(--primary-dim); color: var(--primary); }
.trip-badge-active    { background: var(--green-dim); color: var(--green); }
.trip-badge-completed { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

.trip-stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.trip-stat-label { font-size: 10px; color: var(--text-secondary); margin-bottom: 2px; }
.trip-stat-value { font-size: 13px; font-weight: 700; }

.trip-progress-track {
  height: 4px;
  background: var(--bg-deep);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 12px;
}
.trip-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 100px;
  transition: width 0.7s ease;
}

.trip-card-actions { display: flex; gap: 8px; padding-top: 2px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #ff8a65);
  color: #0d1117;
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 4px 18px var(--primary-glow); }

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-secondary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248,81,73,0.25);
}
.btn-danger:hover { background: rgba(248,81,73,0.22); }

/* Clone button — teal, non-destructive */
.btn-clone {
  background: rgba(56,189,248,0.12);
  color: #38bdf8;
  border: 1px solid rgba(56,189,248,0.25);
}
.btn-clone:hover { background: rgba(56,189,248,0.22); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 7px 13px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }

/* Small icon action buttons */
.btn-edit, .btn-del {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card-hover);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  color: var(--text-secondary);
}
.btn-edit:hover { color: var(--primary); border-color: var(--primary); }
.btn-del {
  border-color: rgba(248,81,73,0.25);
  background: var(--red-dim);
  color: var(--red);
}
.btn-del:hover { background: rgba(248,81,73,0.22); }

/* ============================================================
   FORMS
   ============================================================ */
.form-container { padding: 18px 18px 32px; }

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.form-label .req { color: var(--red); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d8590' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-textarea { resize: vertical; min-height: 76px; }
.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
  line-height: 1.5;
}
.rate-badge {
  float: right;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.85;
  transition: color 0.3s;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-divider { height: 1px; background: var(--border); margin: 20px 0; }

/* Calculated total preview */
.calc-total {
  background: var(--primary-dim);
  border: 1px solid rgba(240,192,64,0.25);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  margin-bottom: 18px;
}
.calc-total-label { font-size: 11px; color: var(--primary); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 3px; }
.calc-total-value { font-size: 24px; font-weight: 800; color: var(--primary); }

/* Status toggle (Committed / Actual) */
.status-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
}
.status-btn {
  flex: 1;
  padding: 9px 8px;
  border: none;
  border-radius: calc(var(--radius-md) - 4px);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  color: var(--text-secondary);
}
.status-btn.on-committed { background: var(--blue-dim); color: var(--blue); }
.status-btn.on-actual    { background: var(--green-dim); color: var(--green); }

/* Currency conversion preview */
.currency-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  margin-top: 8px;
}
.currency-preview-label { font-size: 12px; color: var(--text-secondary); }
.currency-preview-value { font-size: 16px; font-weight: 700; color: var(--green); }

/* ============================================================
   OVERVIEW SCREEN
   ============================================================ */
.overview-header-wrap {
  padding: 18px 18px 0;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-deep) 100%);
}
.ov-trip-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px; }
.ov-trip-name  { font-size: 22px; font-weight: 800; margin-bottom: 3px; line-height: 1.2; }
.ov-trip-meta  { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.ov-trip-meta strong { color: var(--primary); font-weight: 600; }

/* Health bar */
.health-bar-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  margin-bottom: 18px;
}
.hb-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hb-label  { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }
.hb-pct    { font-size: 14px; font-weight: 700; }
.hb-track  {
  height: 10px;
  background: var(--bg-deep);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
}
.hb-bar-committed {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: var(--blue);
  border-radius: 100px;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.hb-bar-actual {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: var(--green);
  border-radius: 100px;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.hb-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); }
.legend-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Category grid */
.overview-body { padding: 0 18px; }
.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
/* ── Budget alert banner ─────────────────────────────────────────────── */
.budget-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity:0; transform:translateY(-6px); }
  to   { opacity:1; transform:translateY(0); }
}
.budget-alert-warn {
  background: rgba(240,192,64,0.10);
  border: 1px solid rgba(240,192,64,0.30);
  color: #f0c040;
}
.budget-alert-over {
  background: rgba(248,81,73,0.10);
  border: 1px solid rgba(248,81,73,0.30);
  color: #f85149;
}
.budget-alert-close {
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0 4px;
  flex-shrink: 0;
  touch-action: manipulation;
}
.budget-alert-close:hover { opacity: 1; }

.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.cat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 13px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.cat-tile::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--cc, var(--primary));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.cat-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--cc, var(--primary)); }
.cat-tile:hover::after { transform: scaleX(1); }
.cat-tile:active { transform: scale(0.97); }

.tile-icon   { font-size: 26px; margin-bottom: 8px; display: block; }
.tile-name   { font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.tile-budget { font-size: 15px; font-weight: 800; margin-bottom: 9px; }
.tile-bar-track {
  height: 4px;
  background: var(--bg-deep);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 5px;
}
.tile-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--cc, var(--primary));
  transition: width 0.8s ease;
}
.tile-spent { font-size: 11px; color: var(--text-secondary); }
.tile-spent b { color: var(--cc, var(--primary)); }

/* Grand total bar */
.grand-total-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.gtc-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 3px; }
.gtc-value { font-size: 22px; font-weight: 800; }

/* ============================================================
   CATEGORY DETAIL
   ============================================================ */
.cat-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.cat-detail-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.cat-detail-name { font-size: 19px; font-weight: 800; }
.cat-detail-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Summary 4-column grid */
.summary-row {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0 18px 18px;
}
.summary-cell {
  background: var(--bg-card);
  padding: 12px 8px;
  text-align: center;
}
.sc-label { font-size: 9px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.sc-value { font-size: 13px; font-weight: 700; }
.sc-budget     { color: var(--primary); }
.sc-committed  { color: var(--blue); }
.sc-actual     { color: var(--green); }
.sc-remaining  { color: var(--green); }
.sc-remaining.over { color: var(--red); }

/* Section header */
.section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 18px;
}
.section-hdr .section-title { margin-bottom: 0; }

.cat-body { padding-bottom: 20px; }

/* Budget item card */
.bi-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 0 18px 8px;
}
.bi-info { flex: 1; min-width: 0; }
.bi-label  { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bi-detail { font-size: 11px; color: var(--text-secondary); margin-top: 2px; line-height: 1.4; }
.bi-amount { font-size: 15px; font-weight: 800; color: var(--primary); white-space: nowrap; }
.bi-actions { display: flex; gap: 5px; }

/* Transaction card */
.txn-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 0 18px 8px;
}
.txn-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.txn-dot.committed { background: var(--blue); }
.txn-dot.actual    { background: var(--green); }
.txn-info { flex: 1; min-width: 0; }
.txn-desc { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.txn-badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 100px;
  font-weight: 600;
}
.txn-badge.committed { background: var(--blue-dim); color: var(--blue); }
.txn-badge.actual    { background: var(--green-dim); color: var(--green); }
.txn-right { text-align: right; flex-shrink: 0; }
.txn-amount      { font-size: 14px; font-weight: 700; white-space: nowrap; }
.txn-amount-base { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.txn-actions { display: flex; gap: 5px; }

/* No items */
.no-items {
  text-align: center;
  padding: 28px 20px;
  color: var(--text-secondary);
  font-size: 13px;
}
.no-items-icon { font-size: 30px; margin-bottom: 6px; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-body { padding: 0 18px 20px; }

.dash-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  position: relative;
  overflow: hidden;
}
.dash-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
}
.dash-card.d-budget::before   { background: var(--primary); }
.dash-card.d-committed::before{ background: var(--blue); }
.dash-card.d-actual::before   { background: var(--green); }
.dash-card.d-remaining::before{ background: var(--green); }
.dash-card.d-remaining.over::before { background: var(--red); }
.dash-card-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 7px; }
.dash-card-value { font-size: 18px; font-weight: 800; line-height: 1; margin-bottom: 5px; }
.dash-card-sub   { font-size: 11px; color: var(--text-secondary); }

.chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  margin-bottom: 14px;
}
.chart-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.chart-canvas-wrap   { position: relative; height: 220px; }
.chart-canvas-wrap-s { position: relative; height: 200px; }

/* Breakdown table */
.bkdn-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
}
.bkdn-head, .bkdn-row {
  display: grid;
  grid-template-columns: 1fr 72px 72px 72px;
  gap: 4px;
  padding: 10px 13px;
  align-items: center;
}
.bkdn-head {
  background: var(--bg-surface);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.bkdn-row {
  border-top: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.bkdn-row:hover { background: var(--bg-card-hover); }
.bkdn-row.total-row { background: var(--bg-surface); font-weight: 700; font-size: 13px; }
.bkdn-cat  { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.bkdn-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bkdn-num  { text-align: right; font-weight: 600; }
.bkdn-budget { color: var(--primary); }
.bkdn-actual { color: var(--green); }
.bkdn-var-pos { color: var(--green); }
.bkdn-var-neg { color: var(--red); }
.bkdn-head div:not(:first-child) { text-align: right; }

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 70px;
  background: rgba(22,27,34,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 6px;
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
  flex: 1;
  max-width: 68px;
}
.nav-item span { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.nav-item:hover, .nav-item.nav-active { color: var(--primary); }

.nav-add-btn {
  width: 50px; height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), #ff8a65);
  color: #0d1117;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px var(--primary-glow);
  transition: transform var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}
.nav-add-btn:hover  { transform: scale(1.1); box-shadow: 0 6px 24px var(--primary-glow); }
.nav-add-btn:active { transform: scale(0.94); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 11px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast.show-toast { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.t-success { border-color: var(--green); color: var(--green); }
.toast.t-error   { border-color: var(--red); color: var(--red); }

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.confirm-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;  /* inset:0 not supported on iOS <15 */
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  padding: 20px;
}
/* Triple-lock .hidden: display+visibility+pointer-events so it cannot block taps */
.confirm-overlay.hidden { display: none; visibility: hidden; pointer-events: none; }
.confirm-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 310px;
  width: 100%;
  animation: popIn 0.2s ease;
}
@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.confirm-box p { font-size: 15px; line-height: 1.55; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { flex: 1; }

/* ============================================================
   ANIMATIONS & UTILITIES
   ============================================================ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-in { animation: fadeSlideUp 0.28s ease both; }
.anim-d1 { animation-delay: 0.04s; }
.anim-d2 { animation-delay: 0.08s; }
.anim-d3 { animation-delay: 0.12s; }
.anim-d4 { animation-delay: 0.16s; }
.anim-d5 { animation-delay: 0.20s; }
.anim-d6 { animation-delay: 0.24s; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-secondary); }

/* ============================================================
   WELCOME / ONBOARDING SCREEN
   ============================================================ */
.welcome-bg {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  /* Large padding-bottom ensures CTA button sits above the iOS Quick Look
     native toolbar (~50-88px) that physically covers bottom web content */
  padding-bottom: max(120px, calc(88px + env(safe-area-inset-bottom, 0px)));
  position: relative;
}

/* Floating emoji particles — absolute (not fixed) so they stay within
   the welcome screen stacking context and never intercept form touches */
/* Confines the floating emoji to the hero band so they can never overlap
   the form fields, at any viewport size. */
.wf-float-zone {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 360px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.wf-float {
  position: absolute;
  font-size: 28px;
  pointer-events: none !important;
  opacity: 0;
  animation: wfFloat 7s ease-in-out infinite;
  z-index: 0;
  user-select: none;
}
@keyframes wfFloat {
  0%   { transform: translateY(0)     rotate(0deg);  opacity: 0; }
  15%  { opacity: 0.35; }
  50%  { transform: translateY(-60px) rotate(12deg); opacity: 0.45; }
  85%  { opacity: 0.35; }
  100% { transform: translateY(0)     rotate(0deg);  opacity: 0; }
}

/* Hero */
.welcome-hero {
  text-align: center;
  padding: 52px 24px 32px;
  position: relative;
  background: radial-gradient(ellipse at 50% -10%, rgba(240,192,64,0.18) 0%, transparent 65%),
              radial-gradient(ellipse at 80% 110%, rgba(99,102,241,0.14) 0%, transparent 60%);
  z-index: 1;
}
.welcome-globe {
  font-size: 72px;
  display: block;
  margin-bottom: 18px;
  animation: globeBob 3.5s ease-in-out infinite;
  transform-origin: center;
}
@keyframes globeBob {
  0%,100% { transform: translateY(0)     scale(1);    filter: drop-shadow(0 0 12px rgba(240,192,64,0)); }
  50%     { transform: translateY(-10px) scale(1.07); filter: drop-shadow(0 8px 24px rgba(240,192,64,0.4)); }
}
.welcome-title {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #f0c040 0%, #ff8a65 45%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-tagline {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
}

/* Benefit cards */
.welcome-benefits {
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 26px;
  position: relative;
  z-index: 1;
}
.benefit-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  opacity: 0;
  animation: benefitIn 0.5s ease forwards;
}
.benefit-card:nth-child(1) { animation-delay: 0.2s; }
.benefit-card:nth-child(2) { animation-delay: 0.35s; }
.benefit-card:nth-child(3) { animation-delay: 0.5s; }
.benefit-card:nth-child(4) { animation-delay: 0.65s; }
@keyframes benefitIn {
  from { transform: translateX(28px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.benefit-card:hover { border-color: rgba(240,192,64,0.25); }
.benefit-icon { font-size: 30px; flex-shrink: 0; }
.benefit-text h4 { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.benefit-text p  { font-size: 11px; color: var(--text-secondary); line-height: 1.45; }

/* Form section */
.welcome-form {
  padding: 0 18px;
  margin-bottom: 20px;
  position: relative;
  z-index: 10;
}
.welcome-form .form-group { margin-bottom: 12px; }

/* Partner toggle row */
/* Hidden native checkbox — label handles the visual tap area.
   pointer-events:none is NOT set: the <label for=> association handles clicks
   while the checkbox itself stays accessible for form serialization. */
.partner-cb-native {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: 0;
}

/* CSS-only partner toggle — no JavaScript needed.
   When the native checkbox is checked, slide the thumb and show the partner group.
   These selectors require: <input#partner-cb> immediately before <label> and <div#wf-partner-group> */
#partner-cb:checked + label .toggle-sw {
  background: var(--primary);
  border-color: var(--primary);
}
#partner-cb:checked + label .toggle-thumb { left: 22px; }
#partner-cb:checked ~ #wf-partner-group   { display: block !important; }

.partner-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--transition);
  margin-bottom: 12px;
  user-select: none;
  /* Button resets for iOS */
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.partner-toggle-row:hover { border-color: rgba(240,192,64,0.3); }
.partner-toggle-label { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* Toggle switch */
.toggle-sw {
  width: 44px; height: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.22s, border-color 0.22s;
}
.toggle-sw.on { background: var(--primary); border-color: var(--primary); }
.toggle-thumb {
  position: absolute;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left 0.22s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-sw.on .toggle-thumb { left: 22px; }

/* CTA */
.welcome-cta {
  padding: 0 18px;
  position: relative;
  z-index: 10;
}
.btn-welcome {
  width: 100%;
  padding: 17px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, #f0c040 0%, #ff8a65 100%);
  color: #0d1117;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 24px rgba(240,192,64,0.38);
  animation: ctaPulse 2.8s ease-in-out infinite;
  touch-action: manipulation;
}
@keyframes ctaPulse {
  0%,100% { box-shadow: 0 4px 24px rgba(240,192,64,0.38); }
  50%     { box-shadow: 0 6px 36px rgba(240,192,64,0.62); }
}
.btn-welcome:hover  { transform: translateY(-2px); }
.btn-welcome:active { transform: scale(0.97); animation: none; }

.share-tip {
  margin-top: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: center;
}
.share-tip strong { color: var(--primary); }

/* Greeting badge shown in trips header / overview */
.greeting-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.greeting-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ---- Data action buttons (Export / Import) in header ---- */
.data-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-data {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform 0.12s;
  flex-shrink: 0;
}
.btn-data:hover  { border-color: var(--primary); color: var(--primary); background: rgba(240,192,64,.08); }
.btn-data:active { transform: scale(0.9); }

/* Sync status dot */
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  margin-left: 2px;
  transition: background 0.3s;
}
.sync-dot.connected { background: #3fb950; box-shadow: 0 0 6px #3fb950; }
.sync-dot.portable  { background: #f0c040; box-shadow: 0 0 6px #f0c040; }

/* Portable mode banner */
.portable-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(240,192,64,0.10);
  border: 1px solid rgba(240,192,64,0.30);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 10px 14px 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.portable-banner.hidden { display: none; }
.portable-banner-icon { font-size: 20px; flex-shrink: 0; }
.portable-banner a {
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color .2s;
}
.portable-banner a:hover { text-decoration-color: var(--primary); }


/* ============================================================
   V1.1 ADDITIONS
   ============================================================ */

/* === FLATPICKR OVERRIDES (match dark safari theme) === */
.flatpickr-calendar {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: 'Inter', sans-serif !important;
}
.flatpickr-day { color: var(--text-primary) !important; border-radius: var(--radius-sm) !important; border-color: transparent !important; }
.flatpickr-day:hover { background: var(--bg-card-hover) !important; }
.flatpickr-day.selected, .flatpickr-day.selected:hover {
  background: var(--primary) !important; border-color: var(--primary) !important; color: #0d1117 !important; font-weight: 700;
}
.flatpickr-day.today { border-color: var(--primary) !important; }
.flatpickr-day.flatpickr-disabled, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay {
  color: var(--text-muted) !important;
}
.flatpickr-months { background: var(--bg-surface) !important; border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important; }
.flatpickr-month, .flatpickr-current-month, .flatpickr-current-month .cur-month,
.flatpickr-current-month .cur-year, .flatpickr-weekday {
  color: var(--text-primary) !important; font-family: 'Inter', sans-serif !important;
}
.flatpickr-current-month .cur-month { font-weight: 700 !important; }
.flatpickr-prev-month svg, .flatpickr-next-month svg { fill: var(--text-secondary) !important; }
.flatpickr-prev-month:hover svg, .flatpickr-next-month:hover svg { fill: var(--primary) !important; }
.numInputWrapper:hover { background: transparent !important; }
.numInput { color: var(--text-primary) !important; background: transparent !important; font-family: 'Inter', sans-serif !important; }
.flatpickr-weekdays { background: var(--bg-surface) !important; }
.flatpickr-innerContainer { border-top: 1px solid var(--border) !important; }
.flatpickr-rContainer { padding: 4px; }

/* === AI PRICE GUIDE BUTTON === */
.label-with-ai {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.label-with-ai .form-label { margin-bottom: 0; flex: 1; }
.btn-ai {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid rgba(240,192,64,0.4);
  background: var(--primary-dim);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-ai:hover { background: rgba(240,192,64,0.22); border-color: var(--primary); transform: scale(1.03); }
.btn-ai:active { transform: scale(0.97); }

/* === AI PRICE GUIDE POPUP (slides up from bottom) === */
.ai-popup-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;  /* inset:0 not supported on iOS <15 */
  background: rgba(0,0,0,0.76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 700;
}
/* Triple-lock .hidden */
.ai-popup-overlay.hidden { display: none; visibility: hidden; pointer-events: none; }
.ai-popup-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  animation: slideUpSheet 0.3s cubic-bezier(0.4,0,0.2,1);
}
@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.ai-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(240,192,64,0.1), rgba(255,138,101,0.08));
  position: sticky;
  top: 0;
  z-index: 2;
}
.ai-popup-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ai-close-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
}
.ai-close-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.ai-popup-body { padding: 18px; }
.ai-response-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 15px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  margin: 10px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  padding: 18px 14px;
  font-size: 13px;
}
.ai-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: aiPulse 1.3s ease-in-out infinite;
}
.ai-dot:nth-child(2) { animation-delay: 0.18s; }
.ai-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes aiPulse {
  0%,80%,100% { transform: scale(0.5); opacity: 0.25; }
  40%          { transform: scale(1);   opacity: 1; }
}
.ai-key-section {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
}
.ai-key-link {
  color: var(--primary);
  font-size: 10px;
  text-decoration: none;
  float: right;
  font-weight: 600;
}
.ai-key-link:hover { text-decoration: underline; }

/* === ITINERARY TIMELINE === */
.itin-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(13,17,23,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.itin-body { padding: 16px 18px 20px; }

.itin-day { margin-bottom: 28px; }
.itin-day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}
.itin-day-date { font-size: 14px; font-weight: 700; }
.itin-day-tag {
  font-size: 10px;
  padding: 2px 9px;
  border-radius: 100px;
  background: var(--primary-dim);
  color: var(--primary);
  font-weight: 600;
}

/* ── My Trips footer strip (About / Exit) ──────────────────── */
.trips-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 18px 0 28px;
  margin-top: 8px;
}
.trips-footer-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 20px;
  transition: color 0.2s, background 0.2s;
  touch-action: manipulation;
}
.trips-footer-btn:hover { color: var(--text-secondary); background: var(--bg-card); }
.trips-footer-divider {
  width: 1px; height: 16px; background: var(--border); flex-shrink: 0;
}

/* ── Welcome back button (for returning visitors) ────────── */
.btn-welcome-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 24px;
  cursor: pointer;
  margin-top: 10px;
  width: 100%;
  transition: border-color 0.2s, color 0.2s;
  touch-action: manipulation;
}
.btn-welcome-back:hover { border-color: var(--primary); color: var(--primary); }

.itin-events {
  position: relative;
  padding-left: 26px;
}
.itin-events::before {
  content: '';
  position: absolute;
  left: 7px; top: 6px; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--border) 0%, transparent 100%);
}
.itin-event {
  position: relative;
  margin-bottom: 9px;
}
.itin-event-dot {
  position: absolute;
  left: -22px; top: 13px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-deep);
  z-index: 1;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.05);
}
.itin-event-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  transition: border-color var(--transition), transform var(--transition);
}
.itin-event-card:hover { border-color: rgba(255,255,255,0.12); transform: translateX(2px); }
.itin-event-card.is-note { border-style: dashed; background: rgba(255,255,255,0.02); }
.itin-event-icon { font-size: 20px; flex-shrink: 0; }
.itin-event-info { flex: 1; min-width: 0; }
.itin-event-title  { font-size: 13px; font-weight: 600; }
.itin-event-detail { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.itin-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-secondary);
}
.itin-empty-icon { font-size: 56px; margin-bottom: 14px; }
.itin-empty h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.itin-empty p { font-size: 13px; line-height: 1.65; max-width: 280px; margin: 0 auto; }

/* === NOTE OVERLAY === */
.note-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;  /* inset:0 not supported on iOS <15 */
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  padding: 20px;
}
/* Triple-lock .hidden */
.note-overlay.hidden { display: none; visibility: hidden; pointer-events: none; }
.note-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px;
  max-width: 360px;
  width: 100%;
  animation: popIn 0.2s ease;
}
.note-box h3 { font-size: 16px; font-weight: 700; margin-bottom: 18px; }


/* ═══════════════════════════════════════════════════════════
   TRIP DISCOVERY UI
   ═══════════════════════════════════════════════════════════ */
.disc-progress {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 20px;
}
.disc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: background 0.3s;
}
.disc-dot-on   { background: var(--primary); transform: scale(1.3); }
.disc-dot-done { background: var(--green); }

.disc-title {
  font-size: 17px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 6px; text-align: center;
}
.disc-hint {
  font-size: 13px; color: var(--text-secondary);
  text-align: center; margin-bottom: 18px;
}

/* Chip selectors */
.disc-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-bottom: 18px;
}
.disc-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.18s;
  touch-action: manipulation;
}
.disc-chip:hover { border-color: var(--primary); background: var(--primary-dim); }
.disc-chip-on   {
  background: var(--primary-dim) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}
.disc-chip-wide {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 10px 18px; border-radius: 14px; min-width: 90px;
}

/* Actions row */
.disc-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-bottom: 20px;
}
.disc-next { min-width: 160px; }

/* Divider */
.disc-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 14px; color: var(--text-muted); font-size: 12px;
}
.disc-divider::before, .disc-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Template quick-pick grid */
.disc-templates {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px;
}
.disc-tpl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; text-align: left;
  transition: all 0.18s; touch-action: manipulation;
}
.disc-tpl-btn:hover {
  border-color: var(--primary); background: var(--primary-dim);
  transform: translateY(-1px);
}
.disc-tpl-icon  { font-size: 18px; flex-shrink: 0; }
.disc-tpl-label { font-size: 12px; font-weight: 600; color: var(--text-primary); flex: 1; }
.disc-tpl-days  { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* AI suggestion cards */
.disc-suggestions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.disc-suggestion {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.disc-suggestion:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.disc-sug-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.disc-sug-dest   { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.disc-sug-badge  {
  font-size: 10px; font-weight: 600;
  background: var(--primary-dim); color: var(--primary);
  border: 1px solid var(--primary-glow);
  border-radius: 10px; padding: 2px 8px;
}
.disc-sug-why    { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.disc-sug-highlights { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.disc-sug-tag {
  font-size: 11px; color: var(--blue);
  background: var(--blue-dim); border-radius: 8px; padding: 2px 7px;
}
.disc-sug-budget { font-size: 12px; color: var(--green); font-weight: 600; }

/* Loading spinner */
.disc-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 20px; gap: 16px;
}
.disc-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.disc-loading-text { font-size: 14px; color: var(--text-secondary); }

/* Departure city text input (Step 1) */
.disc-city-wrap  { margin-top: 14px; }
.disc-city-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); display:block; margin-bottom:4px; }
.disc-city-input { width: 100%; box-sizing: border-box; }

/* ── Gemini key entry inside the Discovery panel ───────────────── */
.disc-key-box {
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 12px;
  padding: 14px;
}
.disc-key-error {
  background: rgba(248, 81, 73, .12);
  border: 1px solid rgba(248, 81, 73, .45);
  color: var(--red, #f85149);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.disc-key-help { margin-top: 12px; }
.disc-key-help summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--blue, #58a6ff);
  list-style: none;
}
.disc-key-help summary::-webkit-details-marker { display: none; }
.disc-key-help summary::before { content: "❔ "; }
.disc-key-help > div {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary, #8b949e);
}
.disc-key-help p { margin: 0 0 8px; }
.disc-key-help code {
  background: var(--bg-base, #0d1117);
  padding: 1px 5px;
  border-radius: 4px;
}

.disc-key-steps { margin: 0 0 10px; padding-left: 20px; }
.disc-key-steps li { margin-bottom: 7px; }

/* ── Import review sheet ───────────────────────────────────────── */
.idf-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.idf-box {
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 16px;
  width: 100%; max-width: 520px;
  max-height: 86vh; display: flex; flex-direction: column;
  padding: 18px;
}
.idf-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.idf-src { font-size: 12px; color: var(--text-secondary, #8b949e); margin-bottom: 12px; word-break: break-all; }
.idf-src span { opacity: .8; }
.idf-warn {
  background: rgba(240,192,64,.12);
  border: 1px solid rgba(240,192,64,.45);
  color: #f0c040;
  border-radius: 10px; padding: 10px 12px;
  font-size: 13px; line-height: 1.5; margin-bottom: 12px;
}
.idf-body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.idf-note { font-size: 13px; color: var(--text-secondary, #8b949e); padding: 6px 0 10px; }
.idf-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted, #6e7681); margin: 12px 0 6px;
}
.idf-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border, #30363d); }
.idf-row:last-child { border-bottom: 0; }
.idf-icon { font-size: 15px; width: 18px; flex: none; text-align: center; }
.idf-add .idf-icon { color: #3fb950; }
.idf-chg .idf-icon { color: #f0c040; }
.idf-del .idf-icon { color: #f85149; }
.idf-name { font-size: 14px; font-weight: 600; }
.idf-sub  { font-size: 12px; color: var(--text-secondary, #8b949e); margin-top: 2px; }
.idf-bit  { font-size: 12px; margin-top: 3px; }
.idf-bit span { display: inline-block; min-width: 76px; color: var(--text-muted, #6e7681); }
.idf-bit s { opacity: .65; }
.idf-actions { display: flex; gap: 10px; margin-top: 14px; }
.idf-actions .btn { flex: 1; }

/* ── In-app help ───────────────────────────────────────────────── */
.help-overlay {
  position: fixed; inset: 0; z-index: 9100;
  background: rgba(0,0,0,.66);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.help-box {
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 16px;
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column; padding: 18px;
}
.help-head { display: flex; align-items: center; justify-content: space-between; }
.help-title { font-size: 18px; font-weight: 700; }
.help-close {
  background: none; border: 0; color: var(--text-secondary, #8b949e);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
}
.help-lead {
  font-size: 13px; line-height: 1.6; color: var(--text-secondary, #8b949e);
  margin: 6px 0 12px;
}
.help-body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.help-sec { border-top: 1px solid var(--border, #30363d); }
.help-sec:last-child { border-bottom: 1px solid var(--border, #30363d); }
.help-sec summary {
  cursor: pointer; list-style: none; padding: 12px 2px;
  font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 9px;
}
.help-sec summary::-webkit-details-marker { display: none; }
.help-sec summary::after {
  content: "+"; margin-left: auto; color: var(--text-muted, #6e7681); font-weight: 400;
}
.help-sec[open] summary::after { content: "−"; }
.help-ico { font-size: 16px; }
.help-sec-body {
  padding: 0 2px 14px;
  font-size: 13px; line-height: 1.65; color: var(--text-secondary, #8b949e);
}
.help-sec-body p { margin: 0 0 9px; }
.help-sec-body code {
  background: var(--bg-base, #0d1117); padding: 1px 5px; border-radius: 4px;
}
.help-sec-body a { color: var(--blue, #58a6ff); }

/* ── Language switcher ─────────────────────────────────────────── */
.lang-select {
  background: var(--bg-card, #161b22);
  color: var(--text-primary, #e6edf3);
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  -webkit-appearance: none; appearance: none;
  cursor: pointer;
}
.welcome-lang {
  position: absolute; top: 14px; right: 14px; z-index: 3;
}
