/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:    #1a4a7a;
  --navy-dk: #123558;
  --teal:    #2196a8;
  --white:   #ffffff;
  --bg:      #f0f4f8;
  --card:    #ffffff;
  --border:  #dce4ed;
  --text:    #1a2535;
  --muted:   #6b7a8f;
  --radius:  12px;
  --shadow:  0 2px 8px rgba(0,0,0,.08);

  --flight:     #2980b9;
  --hotel:      #8e44ad;
  --transport:  #d35400;
  --restaurant: #c0392b;
  --activity:   #27ae60;
  --misc:       #7f8c8d;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 1rem; }

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  padding-top: calc(.75rem + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 100;
  gap: .5rem;
}

.app-name { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }

.header-right { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }

.hdr-link {
  color: rgba(255,255,255,.8);
  font-size: .8rem;
  padding: .25rem .5rem;
  border-radius: 6px;
  white-space: nowrap;
}
.hdr-link:active { background: rgba(255,255,255,.15); }

.user-pill {
  background: rgba(255,255,255,.2);
  color: var(--white);
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 20px;
  white-space: nowrap;
}

.trip-switcher {
  background: rgba(255,255,255,.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px;
  padding: .3rem .5rem;
  font-size: .85rem;
  max-width: 180px;
}
.trip-switcher option { color: var(--text); background: var(--white); }

/* ── Flash ─────────────────────────────────────────────────────────────────── */
.flash-bar { background: #fff3cd; border-bottom: 1px solid #ffc107; }
.flash { padding: .6rem 1rem; font-size: .9rem; color: #856404; }

/* ── Main ──────────────────────────────────────────────────────────────────── */
main { max-width: 640px; margin: 0 auto; padding: 1rem; }

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; flex: 1; }
.btn-back {
  color: var(--navy); font-size: .9rem; font-weight: 600;
  white-space: nowrap;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--navy); color: var(--white);
  border: none; border-radius: 10px;
  padding: .65rem 1.2rem; font-weight: 600; font-size: .95rem;
  cursor: pointer; display: inline-block; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { background: var(--navy-dk); }
.btn-full { width: 100%; padding: .85rem; font-size: 1rem; }

.btn-outline {
  border: 1.5px solid var(--navy); color: var(--navy);
  background: transparent; border-radius: 10px;
  padding: .55rem 1rem; font-weight: 600; font-size: .9rem;
  cursor: pointer;
}
.btn-outline:active { background: rgba(26,74,122,.08); }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-wrap {
  max-width: 340px; margin: 3rem auto; text-align: center;
}
.login-logo { font-size: 3.5rem; margin-bottom: .25rem; }
.login-title {
  font-size: 1.8rem; font-weight: 800; color: var(--navy);
  margin-bottom: 2rem;
}
.login-form { display: flex; flex-direction: column; gap: .75rem; }
.login-form input {
  width: 100%; padding: .9rem 1rem;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 1rem; outline: none;
}
.login-form input:focus { border-color: var(--navy); }

/* ── Trip cards ────────────────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: .6rem; }

.trip-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
  gap: .5rem;
}
.trip-card:active { transform: scale(.99); }
.trip-name { font-weight: 700; font-size: 1.05rem; }
.trip-dest { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.trip-dates { color: var(--muted); font-size: .8rem; white-space: nowrap; flex-shrink: 0; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { margin-bottom: 1.5rem; }

/* ── Trip hero ─────────────────────────────────────────────────────────────── */
.trip-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--teal) 100%);
  color: var(--white);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  margin-bottom: 1rem;
}
.trip-hero-name { font-size: 1.35rem; font-weight: 800; }
.trip-hero-meta { font-size: .85rem; opacity: .85; margin-top: .25rem; }
.trip-hero-total { font-size: 1.5rem; font-weight: 700; margin-top: .6rem; }

/* ── Quick-add row ─────────────────────────────────────────────────────────── */
.quick-add {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: .5rem; margin-bottom: 1.25rem;
}
.qadd-btn {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .2rem;
  padding: .6rem .3rem; border-radius: 10px;
  font-size: .75rem; font-weight: 600; color: var(--white);
  -webkit-tap-highlight-color: transparent;
}
.qadd-btn:active { opacity: .85; transform: scale(.97); }
.qadd-btn span { font-size: .72rem; }

.qadd-btn.flight     { background: var(--flight); }
.qadd-btn.hotel      { background: var(--hotel); }
.qadd-btn.transport  { background: var(--transport); }
.qadd-btn.restaurant { background: var(--restaurant); }
.qadd-btn.activity   { background: var(--activity); }
.qadd-btn.misc       { background: var(--misc); }

/* ── Entry sections ────────────────────────────────────────────────────────── */
.section { margin-bottom: 1rem; }

.section-hdr {
  display: flex; justify-content: space-between; align-items: center;
  padding: .4rem 0; margin-bottom: .4rem;
}
.section-label {
  font-weight: 700; font-size: .95rem;
}
.section-total { font-weight: 700; color: var(--muted); font-size: .9rem; }

.type-flight     { color: var(--flight); }
.type-hotel      { color: var(--hotel); }
.type-transport  { color: var(--transport); }
.type-restaurant { color: var(--restaurant); }
.type-activity   { color: var(--activity); }
.type-misc       { color: var(--misc); }

.entry-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  background: var(--card); border-radius: 10px;
  padding: .8rem .9rem; margin-bottom: .4rem;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}

/* type-colored left border per entry */
.section:has(.type-flight)     .entry-row { border-left-color: var(--flight); }
.section:has(.type-hotel)      .entry-row { border-left-color: var(--hotel); }
.section:has(.type-transport)  .entry-row { border-left-color: var(--transport); }
.section:has(.type-restaurant) .entry-row { border-left-color: var(--restaurant); }
.section:has(.type-activity)   .entry-row { border-left-color: var(--activity); }
.section:has(.type-misc)       .entry-row { border-left-color: var(--misc); }

.entry-body { flex: 1; min-width: 0; }
.entry-vendor { font-weight: 600; font-size: .95rem; }
.entry-meta { color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.entry-notes {
  color: var(--muted); font-size: .8rem; margin-top: .25rem;
  white-space: pre-wrap; word-break: break-word;
}

.entry-aside {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: .15rem; padding-left: .75rem; flex-shrink: 0;
}
.entry-usd { font-weight: 700; font-size: 1rem; }
.entry-local { color: var(--muted); font-size: .75rem; }
.entry-who { color: var(--muted); font-size: .72rem; }

.btn-del {
  background: none; border: none; color: #ccc;
  font-size: 1.2rem; cursor: pointer; padding: .1rem .3rem;
  line-height: 1;
}
.btn-del:active { color: #e74c3c; }

/* ── Sync bar ──────────────────────────────────────────────────────────────── */
.sync-bar {
  display: flex; gap: .75rem; padding: .75rem 0;
  justify-content: flex-end;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-card, .card {
  background: var(--card); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.form-card { display: flex; flex-direction: column; gap: .9rem; }

.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: .75rem .9rem;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 1rem; outline: none; background: var(--white);
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--navy); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ── Add entry — image card ────────────────────────────────────────────────── */
.image-card { display: flex; flex-direction: column; gap: .75rem; }

.img-row {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}

.btn-camera {
  background: var(--navy); color: var(--white);
  border: none; border-radius: 10px;
  padding: .65rem 1rem; font-weight: 600; font-size: .9rem;
  cursor: pointer; white-space: nowrap;
}
.btn-camera:active { background: var(--navy-dk); }

.type-wrap select {
  padding: .6rem .75rem; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: .9rem; background: var(--white);
  flex: 1;
}

.btn-extract {
  background: #f0f4f8; color: var(--navy);
  border: 1.5px solid var(--navy);
  border-radius: 10px; padding: .6rem .9rem;
  font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.btn-extract:disabled { opacity: .45; cursor: default; }
.btn-extract:not(:disabled):active { background: #dce4ed; }

.preview-thumb {
  max-width: 100%; max-height: 160px; border-radius: 8px;
  object-fit: contain; display: block;
}

.ok-msg { color: #27ae60; font-size: .85rem; font-weight: 600; }
.err-msg { color: #c0392b; font-size: .85rem; }

#extract-status { min-height: 1.2rem; }

/* ── Scrollbar (desktop) ───────────────────────────────────────────────────── */
@media (min-width: 640px) {
  main { padding: 1.5rem; }
  .quick-add { grid-template-columns: repeat(6, 1fr); }
}
