:root {
  --bg: #f1f2fb; --card: #ffffff; --text: #14172e; --muted: #626888; --line: #e0e2f1;
  --brand: #4338ca; --brand-ink: #ffffff; --accent: #f59e0b; --accent-ink: #2a1a00;
  --hero: linear-gradient(135deg, #312e81 0%, #4f46e5 60%, #0ea5e9 130%); --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --ok: #15803d;
  --tabs-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c0e1d; --card: #161a30; --text: #ecedf8; --muted: #9a9fc4; --line: #262a4a; --brand: #818cf8; --brand-ink: #0c0e1d; --accent: #fbbf24; --hero: linear-gradient(135deg, #1b1a4e 0%, #2e2a9c 65%, #0b6fa8 130%); --warn: #fbbf24; --warn-bg: #3a2c08; --bad: #f87171; --ok: #4ade80; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 8px) 16px 10px; background: var(--hero); color: #fff; box-shadow: 0 2px 12px rgba(30,27,100,.25); }
.title { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.4px; }
h1::first-letter { color: var(--accent); }
.chip { border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.14); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; font-size: 22px; color: rgba(255,255,255,.85); }

.banner { margin: 8px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }

.view { padding: 8px 16px 0; max-width: 640px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; min-height: 44px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.toggle input { width: 20px; height: 20px; }
.link-btn { color: var(--brand); font-size: 14px; padding: 10px 0 10px 12px; }

.day { margin: 14px 0 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day h2 { margin: 0; font-size: 15px; }
.day .sum { font-size: 13px; color: var(--muted); text-align: right; }
.rows { box-shadow: 0 1px 3px rgba(40,40,120,.06); background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; min-height: 68px; }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--bg); }
.th { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.mid { flex: 1; min-width: 0; }
.m { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m.dim { color: var(--muted); font-weight: 500; }
.s { font-size: 13px; color: var(--muted); }
.amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.mark { display: block; font-size: 12px; font-weight: 500; margin-top: 2px; }
.mark.ok { color: var(--ok); } .mark.todo { color: var(--muted); } .mark.warn { color: var(--warn); } .mark.bad { color: var(--bad); }
.spin { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty::before { content: ''; display: block; width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 24px; background: url(icons/icon.svg) center/cover; box-shadow: 0 8px 22px rgba(67,56,202,.3); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: 1fr 88px 1fr; align-items: center; background: var(--card); border-top: 1px solid var(--line); }
.tab { height: var(--tabs-h); border: 0; background: none; color: var(--muted); font-size: 15px; }
.tab.active { color: var(--brand); font-weight: 700; box-shadow: inset 0 3px 0 var(--brand); }
.fab { justify-self: center; width: 68px; height: 68px; margin-top: -30px; border-radius: 50%; background: linear-gradient(180deg, #fcd34d, var(--accent)); color: var(--accent-ink); display: grid; place-items: center; border: 4px solid var(--bg); box-shadow: 0 6px 16px rgba(245,158,11,.45); }
.fab:active { transform: scale(.96); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.field input, .field select { display: block; width: 100%; margin-top: 4px; min-height: 44px; padding: 8px 10px; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.field input[type="date"] { min-width: 0; -webkit-appearance: none; appearance: none; }

.sum-card h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.big { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl td { padding: 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.tbl td:last-child { text-align: right; }
.tbl td.n { color: var(--muted); text-align: center; width: 36px; }

.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0; }
button:not(.tab):not(.row):not(.icon-btn):not(.chip) { min-height: 46px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
button.primary:not(.tab):not(.row):not(.icon-btn):not(.chip) { background: linear-gradient(135deg, #4338ca, #4f46e5); border-color: transparent; color: #fff; font-weight: 700; }
button.danger:not(.tab):not(.row):not(.icon-btn):not(.chip) { color: var(--bad); }
.muted { color: var(--muted); font-size: 13px; }

.sheet { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--bg); -webkit-overflow-scrolling: touch; }
.sheet-card { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 32px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head button { border: 0 !important; background: none !important; min-height: 44px; padding: 0 4px !important; color: var(--brand); }
.sheet-head .danger { color: var(--bad); }
.photo-wrap { background: #000; border-radius: 12px; overflow: hidden; margin-bottom: 10px; max-height: 55vh; overflow-y: auto; }
.photo-wrap img { display: block; width: 100%; height: auto; }
.flag { padding: 8px 10px; margin-bottom: 8px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }
.flag.bad { color: var(--bad); }
.actions { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; margin-top: 12px; }
details { margin-top: 8px; font-size: 14px; }
pre { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; max-height: 240px; overflow: auto; }

.page { page-break-after: always; margin-bottom: 20px; }
.page h3 { margin: 0 0 6px; font-size: 14px; }
.page img { max-width: 100%; max-height: 80vh; display: block; }

@media print {
  body > *:not(#pack) { display: none !important; }
  #pack { position: static; overflow: visible; background: #fff; color: #000; }
  .no-print { display: none !important; }
  .page img { max-height: 235mm; }
}

/* trips + help */
.top-actions { display: flex; align-items: center; }
.icon-btn[aria-label^="Help"] { font-size: 20px; font-weight: 700; }
.toggles { display: flex; flex-direction: column; gap: 2px; }
.empty.plain { padding: 32px 16px; }
.empty.plain::before { display: none; }
.trip-row.on { box-shadow: inset 4px 0 0 var(--accent); }
.new-trip { margin-top: 16px; }
.inline { display: flex; gap: 8px; margin-top: 4px; }
.inline input { margin-top: 0 !important; flex: 1; min-width: 0; }
.faq-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 8px; padding: 0 14px; }
.faq-item summary { cursor: pointer; padding: 13px 0; font-weight: 600; font-size: 15px; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; color: var(--brand); font-weight: 700; }
.faq-item[open] summary::after { content: '–'; }
.faq-item p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.faq-item p strong, .faq-item p em { color: var(--text); font-style: normal; font-weight: 600; }
