/* Receipts — warm paper background, deep green brand, iOS-style grouped lists. */
:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --text: #17201c;
  --muted: #6b746f;
  --faint: #a3aaa6;
  --line: rgba(23, 32, 28, 0.08);
  --brand: #0f5c4a;
  --brand-2: #1a7a62;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe9;
  --amber: #b86e00;
  --amber-soft: #fbefd9;
  --blue: #2563c9;
  --blue-soft: #e3ecfb;
  --violet: #6d4bc3;
  --violet-soft: #ece6fa;
  --grey-soft: #eceae4;
  --ok: #1e8a52;
  --danger: #c2372b;
  --danger-soft: #fbe5e2;
  --shadow: 0 1px 2px rgba(23, 32, 28, 0.04), 0 6px 20px rgba(23, 32, 28, 0.06);
  --radius: 18px;
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --surface: #18201d;
    --surface-2: #1d2622;
    --text: #e9efec;
    --muted: #97a29d;
    --faint: #66716c;
    --line: rgba(233, 239, 236, 0.08);
    --brand: #3fbf98;
    --brand-2: #2a9d7c;
    --brand-ink: #04211a;
    --brand-soft: #173a30;
    --amber: #f1b54a;
    --amber-soft: #3a2c12;
    --blue: #7ea8f2;
    --blue-soft: #1a2740;
    --violet: #b39cf0;
    --violet-soft: #2a2140;
    --grey-soft: #252d2a;
    --ok: #4fd08e;
    --danger: #ff7b6e;
    --danger-soft: #3d1f1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; font-optical-sizing: auto;
}
a { color: var(--brand); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

.view {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  animation: fade .18s ease-out;
}
body.detail .view { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- headings ---------- */
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.title-lg { font-size: 32px; line-height: 1.08; font-weight: 800; letter-spacing: -0.025em; margin: 2px 0 18px; text-wrap: balance; }
.section {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 26px 4px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.section a { text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 600; }
.back {
  display: inline-flex; align-items: center; gap: 2px; margin: 0 0 10px -6px; padding: 6px;
  font-size: 17px; font-weight: 600; color: var(--brand); background: none; border: 0;
}
.back svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden;
  border-radius: 22px; background: rgba(255, 255, 255, .14);
  box-shadow: 0 10px 30px rgba(15, 92, 74, .25);
}
.hero a {
  display: block; padding: 18px 16px 16px; color: #fff;
  background: linear-gradient(150deg, #13715a 0%, #0f5c4a 55%, #0b4a3b 100%);
}
@media (prefers-color-scheme: dark) { .hero a { background: linear-gradient(150deg, #1f6e59 0%, #174f42 60%, #123d33 100%); } }
.hero .k { font-size: 13px; font-weight: 600; opacity: .8; }
.hero .v { font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -0.025em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.hero .s { font-size: 13px; opacity: .8; margin-top: 2px; }

/* ---------- cards & grouped lists ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--text); position: relative;
}
.row-item + .row-item::before {
  content: ""; position: absolute; top: 0; right: 0; left: 64px; border-top: 1px solid var(--line);
}
.row-item:active { background: var(--surface-2); }
.row-item .main { flex: 1; min-width: 0; }
.row-item .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .s { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .end { text-align: right; flex: none; }
.row-item .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.chev { width: 8px; height: 13px; flex: none; stroke: var(--faint); fill: none; stroke-width: 2; }

.icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 20px; background: var(--grey-soft);
}
.icon.food { background: var(--amber-soft); }
.icon.travel { background: var(--blue-soft); }
.icon.office { background: var(--violet-soft); }
.icon.trip { background: var(--brand-soft); }
.icon svg { width: 20px; height: 20px; stroke: var(--brand); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; letter-spacing: .01em;
  font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: var(--grey-soft); color: var(--muted);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ask { background: var(--amber-soft); color: var(--amber); }
.pill.ok { background: var(--brand-soft); color: var(--ok); }
.pill.fail { background: var(--danger-soft); color: var(--danger); }
.pill.busy { color: var(--brand); background: var(--brand-soft); }
.pill.reimb { background: var(--violet-soft); color: var(--violet); }
.pill.busy::before { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.empty {
  text-align: center; color: var(--muted); padding: 28px 16px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 15px;
}
.empty .big { font-size: 30px; display: block; margin-bottom: 6px; }

/* ---------- trip banner ---------- */
.trip-banner {
  display: flex; gap: 14px; align-items: center; padding: 16px; margin-bottom: 14px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text);
  border-left: 4px solid var(--brand);
}
.trip-banner .main { flex: 1; min-width: 0; }
.trip-banner .t { font-weight: 750; font-size: 17px; }
.trip-banner .s { color: var(--muted); font-size: 14px; }
.progress { height: 6px; border-radius: 6px; background: var(--grey-soft); margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 15px 18px; border-radius: 14px; border: 0; font-size: 17px; font-weight: 650;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px rgba(15, 92, 74, .28); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--brand); }
.btn.danger { background: transparent; box-shadow: none; color: var(--danger); }
.btn:disabled { opacity: .55; }
.btn + .btn { margin-top: 10px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; }

/* ---------- receipt detail ---------- */
.shot { position: relative; display: block; border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.shot img { display: block; width: 100%; max-height: 46vh; object-fit: contain; background: var(--surface-2); }
.shot .tag {
  position: absolute; right: 10px; bottom: 10px; padding: 6px 10px; border-radius: 99px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 600; backdrop-filter: blur(8px);
}
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
.fact.wide { grid-column: 1 / -1; }
.fact .h, .row-item .home-amt { font-size: 13px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.fact { flex: 1; background: var(--surface); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); min-width: 0; }
.fact .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.fact .v { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guess {
  display: flex; gap: 10px; margin-top: 18px; padding: 12px 14px; border-radius: 14px;
  background: var(--brand-soft); color: var(--text); font-size: 14px;
}
.guess .spark { font-size: 18px; line-height: 1.2; }
.question { font-size: 22px; line-height: 1.2; font-weight: 750; letter-spacing: -0.015em; text-wrap: balance; margin: 18px 2px 10px; }

.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 22px 4px 8px; }
input[type=text], input[type=date], input[type=time], textarea {
  width: 100%; padding: 14px; font: inherit; font-size: 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; }
textarea { min-height: 88px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 550; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip.add { color: var(--brand); border-style: dashed; }
.segmented { display: flex; padding: 3px; border-radius: 12px; background: var(--grey-soft); }
.segmented button { flex: 1; padding: 9px; border: 0; border-radius: 10px; background: transparent; font-weight: 650; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.form-group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.form-row { display: flex; align-items: center; gap: 12px; padding: 4px 14px; min-height: 50px; position: relative; }
.form-row + .form-row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 1px solid var(--line); }
.form-row label { width: 92px; flex: none; color: var(--muted); font-size: 15px; }
.form-row input { border: 0; box-shadow: none; padding: 10px 0; background: transparent; text-align: right; border-radius: 0; }
.form-row input:focus { outline: none; }
.form-row select { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: inherit; text-align: right; text-align-last: right; padding: 10px 0; }
.items { padding: 10px 14px 14px; font-size: 14px; color: var(--muted); }
.items div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }

details.more { margin-top: 22px; }
details.more > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  margin: 0 4px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "Show"; text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 600; color: var(--brand); }
details.more[open] > summary::after { content: "Hide"; }
.warn-dot { color: var(--amber); }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--line);
}
.actionbar .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.meta-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------- forward ---------- */
.check-row input { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; flex: none; margin: 0;
  border-radius: 50%; border: 2px solid var(--faint); display: grid; place-items: center; }
.check-row input:checked { background: var(--brand); border-color: var(--brand); }
.check-row input:checked::after { content: ""; width: 6px; height: 11px; border: solid var(--brand-ink); border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.explain { color: var(--muted); font-size: 14px; margin: -8px 2px 16px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
body.detail .tabbar { display: none; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.tabbar a svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--brand); }
.fab {
  justify-self: center; width: 62px; height: 62px; margin-top: -26px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 8px 22px rgba(15, 92, 74, .4), 0 0 0 5px var(--bg);
}
.fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }

/* ---------- misc ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 99px; font-size: 15px; font-weight: 600;
  background: var(--text); color: var(--bg); box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: drop .2s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } }
.toast.out { animation: lift .2s ease-in forwards; }
@keyframes lift { to { opacity: 0; transform: translate(-50%, -8px); } }
.spinner { width: 34px; height: 34px; border: 3px solid var(--grey-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .9s linear infinite; margin: 26px auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; color: var(--muted); }
.error { color: var(--danger); }
.err-card { background: var(--danger-soft); color: var(--danger); border-radius: 14px; padding: 12px 14px; margin-top: 14px; font-size: 14px; }
.stack > * + * { margin-top: 10px; }
.two { display: flex; gap: 10px; }
.two > * { flex: 1; margin-top: 0 !important; }

/* ---------- switch ---------- */
.toggle-row { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.toggle-row .main { flex: 1; min-width: 0; }
.switch { appearance: none; -webkit-appearance: none; flex: none; margin: 0; width: 51px; height: 31px; border-radius: 99px;
  background: var(--grey-soft); position: relative; transition: background .2s; border: 1px solid var(--line); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.switch:checked { background: var(--brand); border-color: var(--brand); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- bottom sheet ---------- */
/* The sheet's position and the dimming behind it are driven from app.js (openSheet), so it
   can follow the finger and be flicked away. --scrim runs from 0 (hidden) to 1 (fully open). */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end;
  background: rgba(0, 0, 0, calc(.35 * var(--scrim, 1))); }
.sheet { width: 100%; max-width: 640px; margin: 0 auto; background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  touch-action: none; will-change: transform; }
.sheet-wrap.fading { opacity: 0; transition: opacity .2s ease; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--faint); opacity: .5; margin: 0 auto 10px; cursor: grab; }

/* ---------- press feedback ----------
   Things react the moment a finger lands, not when it lifts, and spring back on release. */
.btn, .chip, .fab, .hero a, .back, .tabbar a, .segmented button, .trip-banner, .shot {
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .2s;
}
.btn:active:not(:disabled), .chip:active, .hero a:active, .trip-banner:active, .shot:active { transform: scale(.97); transition-duration: 80ms; }
.fab:active, .tabbar a:active, .back:active, .segmented button:active { transform: scale(.92); transition-duration: 80ms; }
.row-item:active { transition: none; }

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  /* Cross-fades instead of slides; nothing bounces or scales. */
  .view { animation-name: fade-only; }
  @keyframes fade-only { from { opacity: 0; } }
  .toast { animation-name: fade-only; }
  .toast.out { animation: fade-out .2s forwards; }
  @keyframes fade-out { to { opacity: 0; } }
  .sheet-wrap { animation: fade-only .2s; }
  .btn, .chip, .fab, .hero a, .back, .tabbar a, .segmented button, .trip-banner, .shot, .switch::after { transition: opacity .15s; }
  .btn:active:not(:disabled), .chip:active, .hero a:active, .trip-banner:active, .shot:active,
  .fab:active, .tabbar a:active, .back:active, .segmented button:active { transform: none; opacity: .7; }
}
@media (prefers-reduced-transparency: reduce) {
  .tabbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .actionbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .shot .tag { background: #000; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(23, 32, 28, 0.35); --muted: #4a524e; }
  .tabbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; border-top-color: var(--text); }
  .actionbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .card, .group, .btn, .fact, .form-group, .chip { border: 1px solid var(--line); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --line: rgba(233, 239, 236, 0.4); --muted: #c3ccc8; }
}

/* ---------- sign-in and account ---------- */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 750; font-size: 16px;
}
.signin { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.signin-icon { border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.btn.provider { gap: 10px; font-weight: 650; }
.btn.provider.apple { background: #000; color: #fff; }
.btn.provider.google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; box-shadow: none; }
.p-icon { font-size: 19px; line-height: 1; font-weight: 700; }
.btn.provider.google .p-icon { color: #4285f4; }
@media (prefers-color-scheme: dark) { .btn.provider.apple { background: #fff; color: #000; } }
