:root {
  --brand: #1f5f8b;
  --brand-ink: #ffffff;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2530;
  --muted: #5d6b7a;
  --line: #cfd6de;
  --picked: #e3f0fa;
  --error: #b3261e;
  --ok: #1e7d3a;
  --missing: #fff4c2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4b9ad1;
    --brand-ink: #0d1620;
    --bg: #11161c;
    --card: #1a2129;
    --ink: #e6ebf0;
    --muted: #9aa7b4;
    --line: #34404c;
    --picked: #1d3446;
    --error: #ff8a80;
    --ok: #6fcf8c;
    --missing: #3d3419;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--brand);
  color: var(--brand-ink);
}
header h1 { margin: 0; font-size: 20px; }
header .link { color: var(--brand-ink); }
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
section { display: flex; flex-direction: column; gap: 14px; }

label, fieldset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  border: 0;
  padding: 0;
  margin: 0;
}
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
form { display: flex; flex-direction: column; gap: 18px; }

input, select, textarea {
  font: inherit;
  font-weight: 400;
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
/* Required fields that still need filling in */
.missing { background: var(--missing); }
#submitHint:empty { display: none; }

button, .big-button {
  font: inherit;
  font-weight: 600;
  min-height: 56px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.big-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  font-size: 20px;
  text-align: center;
  padding: 0 16px;
}
.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.primary:disabled { opacity: 0.6; }
.link { background: none; border: 0; min-height: 44px; color: var(--brand); text-decoration: underline; font-weight: 500; }

.picks { display: flex; flex-direction: column; gap: 8px; }
.picks button {
  text-align: left;
  padding: 12px 14px;
  font-weight: 500;
}
.picks button small { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }
.picks button[aria-pressed="true"] { background: var(--picked); border-color: var(--brand); border-width: 2px; }
#searchResults { max-height: 55vh; overflow-y: auto; }
#searchResults:empty { display: none; }
#projectSearch { font-weight: 600; }

.toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

#receiptPreview { display: flex; gap: 12px; align-items: center; }
#receiptImage, .pdf-badge { width: 72px; height: 96px; flex: none; border-radius: 8px; border: 1px solid var(--line); }
#receiptImage { object-fit: cover; }
.pdf-badge { display: grid; place-items: center; background: var(--card); color: var(--error); font-weight: 700; }
.status { margin: 0; color: var(--muted); }
.hint { margin: 0; color: var(--muted); }
.note { color: var(--muted); font-weight: 400; }
.error { margin: 0; color: var(--error); font-weight: 500; }
.error:empty { display: none; }
.done { font-size: 24px; font-weight: 700; color: var(--ok); margin: 24px 0 0; }

/* Mileage map screen */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; }
.chip button { min-height: 44px; padding: 0 14px; font-weight: 500; }
.chip button:first-child { border-radius: 22px 0 0 22px; }
.chip button:last-child { border-radius: 0 22px 22px 0; border-left: 0; padding: 0 12px; color: var(--muted); }
.chip button:only-child { border-radius: 22px; border-left: 1px solid var(--line); }
.label { margin: 0; font-weight: 600; }
#mapPreview { width: 100%; border: 1px solid var(--line); border-radius: 8px; }
#mapResult { display: flex; flex-direction: column; gap: 12px; }
#fromSuggest:empty, #toSuggest:empty { display: none; }
.save-row { display: flex; gap: 8px; }
.save-row input { flex: 1; }
.save-row button { padding: 0 18px; }

/* Receipt thumbnails can be tapped to view full size */
#receiptImage, .pdf-badge, #mapPreview { cursor: zoom-in; }
#viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}
#viewerImage { max-width: 100%; max-height: calc(100% - 40px); object-fit: contain; background: #fff; }
.viewer-hint { margin: 0; color: #fff; font-size: 15px; }

/* My expenses */
#mySheets { display: flex; flex-direction: column; gap: 18px; }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-size: 19px; }
.sheet .total { margin: 0; color: var(--muted); }
.badge { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 10px; background: var(--missing); color: var(--ink); font-size: 13px; font-weight: 600; vertical-align: middle; }
.line { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.line .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.line .meta { color: var(--muted); font-size: 15px; }
.line .actions { display: flex; gap: 8px; margin-top: 6px; }
.line .actions button { min-height: 44px; padding: 0 14px; font-weight: 500; }
.danger { color: var(--error); border-color: var(--error); }
.danger.armed { background: var(--error); color: var(--card); }
.confirm { background: var(--missing); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.confirm p { margin: 0; }
.line .badge { align-self: flex-start; margin-left: 0; }
.small-link { align-self: flex-start; min-height: 40px; padding: 0; font-size: 15px; }
.back-top { align-self: flex-start; min-height: 44px; padding: 0; font-size: 17px; text-decoration: none; font-weight: 600; }
.place-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.place-row .meta { color: var(--muted); font-size: 14px; }
.place-row button { min-height: 44px; padding: 0 14px; flex: none; }
.chips .note { align-self: center; font-size: 15px; }
