/* ==========================================================
   styles.css — Travel Planner
   All visual styles. Shared by index.html (setup screen).
   ========================================================== */

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

:root {
  --bg:      #f2f0eb;
  --bg2:     #e8e6e1;
  --bg3:     #dddbd5;
  --surface: #ffffff;
  --text:    #1a1a18;
  --text2:   #5a5a56;
  --text3:   #9a9a96;
  --border:  rgba(0,0,0,0.09);
  --border2: rgba(0,0,0,0.15);
  --accent:  #c2621a;
  --slate:   #4b6cb7;
  --success: #2d7a4f;
  --danger:  #b91c1c;
  --r:       10px;
  --rl:      14px;
}

/* ── Base ── */
body { font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
.app { max-width: 640px; margin: 0 auto; padding: 28px 16px 32px; }

/* ── Setup screen ── */
#setup { max-width: 400px; margin: 50px auto; padding: 0 16px; }
#setup h1 { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 6px; color: var(--text); }
#setup .lead { font-size: 14px; color: var(--text2); margin-bottom: 28px; line-height: 1.6; }
.scard { background: var(--surface); border: 0.5px solid var(--border2); border-radius: var(--rl); padding: 20px; margin-bottom: 14px; }
.scard h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.scard p { font-size: 13px; color: var(--text2); margin-bottom: 14px; line-height: 1.5; }
.srow { display: flex; gap: 8px; }
.srow input { flex: 1; }
.divider { text-align: center; color: var(--text3); font-size: 12px; margin: 6px 0; }

/* ── App header ── */
.hdr { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.hdr-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.hdr-l { flex: 1; min-width: 0; }
.title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: nowrap; }
.etitle { font-size: 26px; font-weight: 700; letter-spacing: -.5px; outline: none; border-bottom: 2px solid transparent; padding-bottom: 2px; cursor: text; min-width: 40px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; transition: border-color .2s; color: var(--text); }
.etitle:hover { border-bottom-color: var(--border2); }
.etitle:focus { border-bottom-color: var(--accent); white-space: normal; overflow: visible; }
.ehint { font-size: 11px; color: var(--text3); white-space: nowrap; transition: opacity .3s; flex-shrink: 0; }
.ehint.h { opacity: 0; }
.hsub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.hacts { display: flex; gap: 6px; }

/* ── Status bar ── */
.stbar { background: var(--surface); border: 0.5px solid var(--border2); border-radius: var(--r); padding: 9px 13px; margin-bottom: 16px; font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 8px; }
.sdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sok { background: var(--success); }
.se { background: var(--text3); }
.ssy { background: var(--accent); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:.35} }

/* ── Cards ── */
.card { background: var(--surface); border: 0.5px solid var(--border2); border-radius: var(--rl); padding: 16px; margin-bottom: 16px; }
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }

/* ── Form elements ── */
label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text2); display: block; margin-bottom: 5px; }
input[type=text], input[type=date], input[type=time], input[type=number] {
  width: 100%; background: var(--bg); border: 0.5px solid var(--border2);
  border-radius: var(--r); padding: 0 12px; font-size: 16px; color: var(--text);
  font-family: inherit; outline: none; -webkit-appearance: none; appearance: none;
  text-align: left; display: block; transition: border-color .15s, box-shadow .15s;
  height: 44px; box-sizing: border-box; line-height: 44px;
}
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input[type=time]::-webkit-date-and-time-value { text-align: left; }
.exp-date-wrap { position: relative; }
.exp-date-wrap input[type=date] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.exp-date-display { width: 100%; background: var(--bg); border: 0.5px solid var(--border2); border-radius: var(--r); padding: 0 12px; font-size: 16px; font-weight: 400; color: var(--text3); font-family: inherit; pointer-events: none; display: flex; align-items: center; height: 44px; box-sizing: border-box; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194,98,26,.12); background: var(--surface); }

/* ── Grid layouts ── */
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.time-pair { display: contents; }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr; } .time-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; grid-column: 1; } }

/* ── Buttons ── */
button { font-family: inherit; cursor: pointer; border-radius: var(--r); font-size: 13px; transition: opacity .12s, transform .1s; border: 0.5px solid var(--border2); background: var(--surface); color: var(--text2); padding: 7px 13px; }
button:hover { background: var(--bg2); }
button:active { transform: scale(.97); opacity: .85; }
.btn-p { width: 100%; background: var(--accent); color: #fff; border: none; padding: 12px; font-size: 15px; font-weight: 600; border-radius: var(--r); margin-top: 4px; }
.btn-p:hover { opacity: .88; background: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.ferr { color: var(--danger); font-size: 12px; margin-top: 8px; display: none; }

/* ── Day groups (itinerary) ── */
.dgrp { margin-bottom: 24px; }
.dhdr { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ddot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dname { font-size: 13px; font-weight: 600; color: var(--text); }
.dct { font-size: 11px; color: var(--text3); }
.dstops { border-left: 2px solid; margin-left: 4px; padding-left: 18px; display: grid; gap: 10px; }

/* ── Stop cards ── */
.stcard { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--rl); padding: 12px 14px; }
.strow { display: flex; align-items: stretch; justify-content: space-between; gap: 8px; }
.stbody { flex: 1; min-width: 0; }
.stmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; min-height: 24px; }
.tpill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 6px; }
.dtag { font-size: 11px; color: var(--text3); }
.sname-text { font-size: 15px; font-weight: 600; color: var(--text); display: block; margin-bottom: 3px; }
.smaps { font-size: 11px; font-weight: 500; color: var(--slate); text-decoration: none; display: block; margin-bottom: 2px; }
.smaps:hover { text-decoration: underline; }
.snote { font-size: 12px; color: var(--text2); font-style: italic; margin-top: 8px; padding-top: 8px; border-top: 0.5px solid var(--border); }
.sauth { font-size: 11px; color: var(--text3); margin-top: 4px; }
.rm { background: none; border: none; color: var(--text3); font-size: 22px; padding: 0 4px; line-height: 1; flex-shrink: 0; cursor: pointer; transition: color .15s; display:flex; align-items:center; }
.rm:hover { color: var(--danger); background: none; }
.edit-link { font-size:11px; color:var(--text3); background:none; border:none; padding:0; cursor:pointer; text-decoration:underline; font-family:inherit; }
.edit-link:hover { color:var(--text); background:none; }
.empty { text-align: center; color: var(--text3); font-size: 14px; padding: 40px 0; }

/* ── Modals ── */
.modal-wrap { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:100; align-items:flex-end; justify-content:center; padding:0; }
.modal-wrap.open { display:flex; }
.modal { background:var(--surface); border-radius:20px 20px 0 0; padding:20px 16px 36px; width:100%; max-width:640px; max-height:90vh; overflow-y:auto; }
.modal-title { font-size:17px; font-weight:700; margin-bottom:16px; color:var(--text); }
.modal-actions { display:flex; gap:8px; margin-top:4px; }
.modal-actions .btn-p { flex:1; }
.modal-actions .btn-cancel { flex:0 0 auto; padding:12px 18px; }
.search-btn { background:none; border:none; color:var(--text3); font-size:15px; padding:0 4px; line-height:1; cursor:pointer; transition:color .15s; display:flex; align-items:center; }
.search-btn:hover { color:var(--text); background:none; }
.stop-btns { display:flex; align-items:center; gap:4px; flex-shrink:0; }

/* ── Trip ID banner ── */
.banner { background: var(--surface); border: 0.5px solid var(--border2); border-radius: var(--r); padding: 14px 16px; margin-bottom: 16px; font-size: 12px; display: none; }
.banner b { font-weight: 600; color: var(--text); }
.bid { font-family: monospace; font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: 3px; display: block; margin: 6px 0 4px; }
.bcopy { font-size: 11px; padding: 5px 12px; background: var(--text); color: var(--bg); border: none; border-radius: var(--r); font-weight: 600; margin-top: 6px; cursor: pointer; }
.bcopy:hover { opacity: .85; }

/* ── My trips list ── */
.trips-list { display: grid; gap: 8px; margin-top: 4px; }
.trip-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg); border: 0.5px solid var(--border2); border-radius: var(--r); padding: 10px 12px; cursor: pointer; transition: background .15s; }
.trip-item:hover { background: var(--bg2); }
.trip-item-left { flex: 1; min-width: 0; }
.trip-item-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-item-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }
.trip-item-id { font-family: monospace; font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 1px; flex-shrink: 0; }
.trip-del { background: none; border: none; color: var(--text3); font-size: 18px; padding: 0 2px; cursor: pointer; flex-shrink: 0; line-height: 1; }
.trip-del:hover { color: var(--danger); background: none; }
.no-trips { font-size: 13px; color: var(--text3); text-align: center; padding: 12px 0; }

/* ── Photo upload ── */
.photo-upload-label { display:flex; align-items:center; gap:8px; background:var(--bg); border:0.5px dashed var(--border2); border-radius:var(--r); padding:10px 12px; cursor:pointer; font-size:14px; color:var(--text2) !important; transition:border-color .15s; }
.photo-upload-label:hover { border-color:var(--border2); color:var(--text) !important; }
.photo-upload-label input { display:none; }
.photo-preview { display:grid; grid-template-columns:repeat(4, 1fr); gap:6px; }
.camera-btn { background:rgba(194,98,26,0.08); border:0.5px solid rgba(194,98,26,0.2); border-radius:var(--r); height:44px; width:44px; min-width:44px; display:flex; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0; }
.camera-btn:active { background:rgba(194,98,26,0.15); }
.field-with-btn { display:flex; gap:8px; align-items:flex-end; }
.field-with-btn > div { flex:1; min-width:0; }
.photo-thumb { position:relative; aspect-ratio:1; border-radius:var(--r); overflow:hidden; }
.photo-thumb img { width:100%; height:100%; object-fit:cover; }
.photo-add-btn { aspect-ratio:1; border:1.5px dashed rgba(0,0,0,0.15); border-radius:8px; display:flex; align-items:center; justify-content:center; color:var(--text3); cursor:pointer; font-size:22px; background:none; }
.photo-thumb .rm-photo { position:absolute; top:2px; right:2px; background:rgba(0,0,0,0.6); color:#fff; border:none; border-radius:50%; width:18px; height:18px; font-size:12px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; padding:0; }
.photo-uploading { font-size:11px; color:var(--text3); margin-top:4px; }
.stop-photos { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.stop-photo { width:72px; height:72px; border-radius:var(--r); object-fit:cover; cursor:pointer; }

/* ── Tabs ── */
.tab-bar { display:flex; gap:0; background:var(--bg2); border-radius:var(--r); padding:3px; margin-bottom:18px; }
.tab-btn { flex:1; padding:8px; font-size:13px; font-weight:600; border:none; background:none; border-radius:calc(var(--r) - 2px); color:var(--text3); cursor:pointer; transition:background .15s,color .15s; }
.tab-btn.active { background:var(--surface); color:var(--text); box-shadow:0 1px 3px rgba(0,0,0,0.08); }

/* ── Pack / Checklist ── */
.pack-section-label { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.6px; color:var(--text2); margin:20px 0 12px; }
.pack-group { margin-bottom:20px; }
.pack-group-hdr { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.pack-group-dot { width:9px; height:9px; border-radius:50%; background:var(--accent); flex-shrink:0; }
.pack-group-name { font-size:13px; font-weight:600; color:var(--text); }
.pack-group-ct { font-size:11px; color:var(--text3); }
.pack-group-stops { border-left:2px solid rgba(194,98,26,0.2); margin-left:4px; padding-left:18px; display:grid; gap:8px; }
.pack-item { background:var(--surface); border:0.5px solid var(--border); border-radius:var(--rl); padding:12px 14px; display:flex; align-items:center; gap:12px; transition:opacity .2s; cursor:pointer; }
.pack-item.checked { opacity:0.5; }
.pack-checkbox { width:20px; height:20px; border-radius:6px; border:1.5px solid var(--border2); flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.pack-checkbox.ticked { background:var(--accent); border-color:var(--accent); }
.pack-item-name { flex:1; font-size:15px; font-weight:600; color:var(--text); }
.pack-item.checked .pack-item-name { text-decoration:line-through; color:var(--text3); }
.pack-rm { background:none; border:none; color:var(--text3); font-size:16px; padding:0 4px; cursor:pointer; flex-shrink:0; line-height:1; }
.pack-rm:hover { color:var(--danger); background:none; }
.pack-empty { text-align:center; color:var(--text3); font-size:14px; padding:32px 0; }

/* ── Expense form ── */
.bill-form { margin-bottom:16px; }
.bill-grid2b { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.bill-currency { width:100%; background:var(--bg); border:0.5px solid var(--border2); border-radius:var(--r); padding:0 28px 0 12px; font-size:16px; font-weight:400; color:var(--text); font-family:inherit; outline:none; -webkit-appearance:none; appearance:none; transition:border-color .15s,box-shadow .15s; height:44px; box-sizing:border-box; line-height:44px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239a9a96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; }
.bill-currency:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(194,98,26,.12); background-color:var(--surface); }
.bill-paidby { width:100%; background:var(--bg); border:0.5px solid var(--border2); border-radius:var(--r); padding:0 28px 0 12px; font-size:16px; font-weight:400; color:var(--text3); font-family:inherit; outline:none; -webkit-appearance:none; appearance:none; transition:border-color .15s,box-shadow .15s; height:44px; box-sizing:border-box; line-height:44px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239a9a96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; }
.bill-paidby.has-value { color:var(--text); }
.bill-paidby:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(194,98,26,.12); background-color:var(--surface); background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239a9a96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; }
.bill-split-people { display:flex; flex-direction:column; gap:6px; margin-bottom:8px; }
.bill-person-row { background:var(--bg); border:0.5px solid var(--border2); border-radius:var(--r); padding:10px 12px; min-height:44px; display:flex; align-items:center; gap:10px; cursor:pointer; user-select:none; transition:border-color .12s; }
.bill-person-row:hover { border-color:var(--accent); }
.bill-check { width:18px; height:18px; border-radius:5px; background:var(--accent); display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:background .12s; }
.bill-check svg { display:block; }
.bill-person-row.unselected .bill-check { background:var(--bg2); }
.bill-person-row.unselected .bill-check svg { opacity:0; }
.bill-person-row.unselected { opacity:0.55; }
.bill-person-name { font-size:16px; color:var(--text); flex:1; }
.bill-person-share { font-size:13px; color:var(--accent); font-weight:600; }
.bill-add-person { display:flex; gap:8px; margin-bottom:12px; }
.bill-add-person input { flex:1; }
.bill-add-person .btn-add { background:var(--accent); color:#fff; border:none; font-weight:600; padding:10px 16px; font-size:14px; white-space:nowrap; border-radius:var(--r); cursor:pointer; }

/* ── Expense records ── */
.exp-section-label { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.6px; color:var(--text2); margin:20px 0 12px; }
.exp-day-group { margin-bottom:24px; }
.exp-day-hdr { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.exp-day-dot { width:9px; height:9px; border-radius:50%; background:var(--accent); flex-shrink:0; }
.exp-day-name { font-size:13px; font-weight:600; color:var(--text); }
.exp-day-ct { font-size:11px; color:var(--text3); }
.exp-day-stops { border-left:2px solid rgba(194,98,26,0.2); margin-left:4px; padding-left:18px; display:grid; gap:10px; }
.exp-card { background:var(--surface); border:0.5px solid var(--border); border-radius:var(--rl); padding:12px 14px; cursor:pointer; transition:border-color .15s; }
.exp-card:hover { border-color:var(--border2); }
.exp-card-row { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.exp-card-body { flex:1; min-width:0; }
.exp-card-title { font-size:15px; font-weight:600; color:var(--text); display:block; margin-bottom:3px; }
.exp-card-meta { font-size:11px; color:var(--text3); }
.exp-card-right { display:flex; align-items:center; flex-shrink:0; }
.exp-card-amt { font-size:14px; font-weight:600; color:var(--text); white-space:nowrap; }
.exp-empty { text-align:center; color:var(--text3); font-size:14px; padding:32px 0; }

/* ── Balances ── */
.bal-outer { background:var(--surface); border:0.5px solid var(--border2); border-radius:var(--rl); padding:14px; }
.bal-convert-select { width:100%; background:var(--bg); border:0.5px solid var(--border2); border-radius:var(--r); padding:0 28px 0 12px; font-size:16px; font-weight:400; color:var(--text); font-family:inherit; outline:none; -webkit-appearance:none; appearance:none; transition:border-color .15s,box-shadow .15s; height:44px; box-sizing:border-box; line-height:44px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239a9a96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; margin-bottom:0; }
.bal-convert-select:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(194,98,26,.12); }
.bal-merged { background:var(--surface); border:0.5px solid var(--border2); border-radius:var(--rl); overflow:hidden; margin-top:10px; }
.bal-merged-rates { padding:14px 14px 14px; }
.bal-exchange-title { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.6px; color:var(--text2); margin-bottom:6px; }
.bal-exchange-row { font-size:12px; color:var(--text2); line-height:1.9; }
.bal-inset-divider { margin:0 14px; border-top:0.5px solid var(--border); }
.bal-results { background:var(--surface); border:0.5px solid var(--border2); border-radius:var(--rl); overflow:hidden; }
.bal-results-inner { display:grid; gap:0; }
.bal-row-item { display:flex; align-items:center; justify-content:space-between; padding:16px 14px; }
.bal-name { font-size:15px; font-weight:600; color:var(--text); }
.bal-amt { font-size:15px; font-weight:600; white-space:nowrap; }
.bal-amt.pos { color:var(--success); }
.bal-amt.neg { color:var(--danger); }
.bal-loading { font-size:13px; color:var(--text3); padding:12px 14px; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--text); color: var(--surface); font-size: 13px; padding: 10px 18px; border-radius: 30px; z-index: 200; transition: transform .3s; white-space: nowrap; pointer-events: none; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Lightbox ── */
.lb { display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.92); z-index:300; flex-direction:column; align-items:center; justify-content:center; -webkit-overflow-scrolling:touch; }
.lb.open { display:flex; }
.lb-inner { position:relative; width:100%; height:100%; display:flex; align-items:center; justify-content:center; padding:60px 16px 80px; box-sizing:border-box; }
.lb-img { max-width:100%; max-height:100%; border-radius:10px; object-fit:contain; user-select:none; display:block; -webkit-user-drag:none; }
.lb-close { position:absolute; top:16px; right:16px; background:none !important; border:none; color:#fff; font-size:28px; width:40px; height:40px; display:flex; align-items:center; justify-content:center; cursor:pointer; line-height:1; z-index:10; flex-shrink:0; -webkit-tap-highlight-color:transparent; -webkit-appearance:none; appearance:none; outline:none; text-shadow:0 1px 4px rgba(0,0,0,0.5); }
.lb-nav { position:absolute; top:50%; transform:translateY(-50%); background:none !important; border:none; color:#fff; font-size:36px; width:44px; height:44px; display:flex; align-items:center; justify-content:center; cursor:pointer; z-index:10; line-height:1; text-shadow:0 1px 4px rgba(0,0,0,0.5); -webkit-tap-highlight-color:transparent; -webkit-appearance:none; appearance:none; outline:none; }
.lb-counter { position:absolute; bottom:24px; left:50%; transform:translateX(-50%); font-size:13px; color:rgba(255,255,255,0.6); white-space:nowrap; }
