/* 旅記 Trip Ledger — mobile-first */
:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --coral: #f97316;
  --bg: #f0fdfa;
  --card: #ffffff;
  --ink: #134e4a;
  --muted: #5eead4;
  --text: #115e59;
  --text-dim: #64748b;
  --border: #ccfbf1;
  --danger: #e11d48;
  --ok: #059669;
  --shadow: 0 8px 24px rgba(13, 148, 136, 0.12);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 8px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--teal); color: #fff; display: grid; place-items: center; font-size: 18px; }
.brand h1 { margin: 0; font-size: 1.25rem; line-height: 1.1; color: var(--ink); }
.subtitle { margin: 0; font-size: 0.7rem; color: var(--text-dim); letter-spacing: 0.02em; }
.trip-chip {
  max-width: 46%; min-height: 44px; padding: 8px 12px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border); color: var(--teal-dark);
  font-weight: 600; font-size: 0.85rem; box-shadow: var(--shadow);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.main { flex: 1; padding: 16px; }
.panel { display: none; animation: fade .2s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  border: 1px solid var(--border); box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; color: var(--ink); }
.card h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--ink); }
.muted { color: var(--text-dim); font-size: 0.85rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: linear-gradient(145deg, #ecfdf5, #fff); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
}
.stat .label { font-size: 0.75rem; color: var(--text-dim); }
.stat .value { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin-top: 4px; word-break: break-all; }

.btn {
  min-height: 48px; padding: 12px 16px; border-radius: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:active { background: var(--teal-dark); }
.btn-secondary { background: #fff; border: 1px solid var(--border); color: var(--teal-dark); }
.btn-danger { background: #fff1f2; color: var(--danger); border: 1px solid #fecdd3; }
.btn-ghost { color: var(--teal-dark); min-height: 44px; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 8px 12px; font-size: 0.85rem; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); }
.field input, .field select, .field textarea {
  min-height: 48px; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; color: var(--ink);
}
.field textarea { min-height: 88px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .icon {
  width: 40px; height: 40px; border-radius: 12px; background: #ecfdf5;
  display: grid; place-items: center; flex-shrink: 0; font-size: 1.1rem;
}
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--ink); }
.list-item .meta { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }
.list-item .amt { font-weight: 700; white-space: nowrap; }
.list-item button.hit { text-align: left; width: 100%; display: flex; gap: 12px; align-items: flex-start; min-height: 44px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem;
  background: #ecfdf5; color: var(--teal-dark); font-weight: 600;
}
.badge.coral { background: #fff7ed; color: var(--coral); }
.badge.rose { background: #fff1f2; color: var(--danger); }

.bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }

.empty {
  text-align: center; padding: 32px 16px; color: var(--text-dim);
}
.empty .emoji { font-size: 2.5rem; margin-bottom: 8px; }

.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(480px, 100%);
  height: calc(var(--tab-h) + var(--safe-b)); padding: 6px 4px var(--safe-b);
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px;
  background: #fff; border-top: 1px solid var(--border); z-index: 30;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 0.65rem; color: var(--text-dim); min-height: 48px; border-radius: 10px;
}
.tab span { font-size: 1.05rem; line-height: 1; }
.tab.active { color: var(--teal-dark); font-weight: 700; background: #ecfdf5; }

.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.modal-sheet {
  position: relative; width: min(480px, 100%); max-height: 90dvh; overflow: auto;
  background: #fff; border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + var(--safe-b));
  box-shadow: 0 -8px 32px rgba(0,0,0,.15);
}
.modal-sheet h2 { margin: 0 0 12px; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.check-row input { width: 22px; height: 22px; accent-color: var(--teal); }

.fx-note { font-size: 0.75rem; color: var(--text-dim); margin-top: 8px; }
.settle-item { padding: 10px 0; border-bottom: 1px dashed var(--border); font-weight: 600; }
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  min-height: 40px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; font-size: 0.85rem;
}
.pill.on { background: var(--teal); color: #fff; border-color: var(--teal); }

@media (min-width: 481px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
