:root {
  --bg: #f6f7f4;
  --card: #ffffff;
  --ink: #1d2521;
  --muted: #5c6862;
  --line: #e2e6e1;
  --brand: #1f6f54;
  --brand-ink: #ffffff;
  --brand-soft: #e6f2ec;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --bad: #a3322a;
  --bad-soft: #fdecea;
  --ok: #1f6f54;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.05), 0 4px 16px rgba(20, 30, 25, 0.05);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800;
}
.nav { display: flex; gap: 18px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.nav a[aria-current="page"], .nav a:hover { color: var(--ink); }
.nav a { white-space: nowrap; }
/* Phones: logo on its own row, links in one row underneath. */
@media (max-width: 640px) {
  .header-inner { height: auto; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 12px; padding-bottom: 10px; }
  .nav { gap: 20px; }
}

/* Intro */
.intro { padding: 32px 0 20px; }
.intro h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 6px; letter-spacing: -0.01em; }
.lede { margin: 0 0 12px; color: var(--muted); font-size: 1.08rem; max-width: 680px; }
.privacy-pill {
  display: inline-flex; gap: 8px; align-items: center; margin: 0;
  background: var(--brand-soft); color: var(--brand); border-radius: 999px;
  padding: 6px 14px; font-size: 0.9rem; font-weight: 600;
}

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.col-side { position: sticky; top: 16px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .col-side { position: static; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card h2 { font-size: 1.1rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.step {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 0.85rem;
}

/* Fields */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.field em { font-weight: 400; font-style: normal; }
input[type="text"], input[type="date"], input[type="search"], input[type="number"], select {
  font: inherit; font-size: 1rem; color: var(--ink);
  border: 1px solid #cfd6d1; border-radius: 10px; padding: 10px 12px; background: #fff; width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(31, 111, 84, 0.25); outline-offset: 1px; border-color: var(--brand); }
.grid-3 { display: grid; grid-template-columns: 1.3fr 0.8fr 1.3fr; gap: 12px; }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }

/* Donation tabs */
.donation-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab {
  font: inherit; font-size: 0.88rem; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab .tab-total { opacity: 0.7; font-variant-numeric: tabular-nums; }
.tab.add { border-style: dashed; color: var(--brand); }
.tab .x { margin-left: 2px; opacity: 0.6; font-size: 0.8rem; }
.tab .x:hover { opacity: 1; }

/* Search */
.search-row { display: grid; grid-template-columns: 1fr 220px; gap: 10px; }
@media (max-width: 640px) { .search-row { grid-template-columns: 1fr; } }
.search-box { position: relative; }
#search { padding-left: 38px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%235c6862' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 12px center; }
.results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px;
  list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  max-height: 340px; overflow: auto;
}
.results li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: var(--brand-soft); }
.results .r-cat { color: var(--muted); font-size: 0.82rem; }
.results .r-range { color: var(--muted); font-size: 0.85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.results .r-custom { color: var(--brand); font-weight: 600; }

/* Browse by category */
.browse-panel { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fbfdfc; }
.browse-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.browse-head span { color: var(--muted); font-size: 0.85rem; flex: 1; }
.browse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; max-height: 320px; overflow: auto; }
.browse-item {
  font: inherit; font-size: 0.92rem; text-align: left; display: flex; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 11px; cursor: pointer;
}
.browse-item:hover, .browse-item:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.browse-item .b-range { color: var(--muted); font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Picker */
.picker { scroll-margin-top: 80px; margin-top: 14px; border: 2px solid var(--brand); border-radius: 12px; padding: 16px; background: #fbfdfc; }
.picker-top { display: flex; justify-content: space-between; align-items: flex-start; }
.picker-cat { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.picker-name { font-size: 1.2rem; font-weight: 700; }
.icon-btn { border: 0; background: transparent; font-size: 1rem; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--line); }

.conditions { border: 0; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.conditions legend { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; padding: 0; }
@media (max-width: 640px) { .conditions { gap: 6px; } .cond { padding: 8px; } .cond .c-hint { display: none; } }
.cond {
  font: inherit; text-align: left; border: 1px solid #cfd6d1; background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.cond strong { display: block; font-size: 0.95rem; }
.cond .c-val { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.cond .c-hint { display: block; font-size: 0.76rem; color: var(--muted); }
.cond[aria-pressed="true"] { border: 2px solid var(--brand); background: var(--brand-soft); padding: 9px 11px; }

.picker-bottom { display: grid; grid-template-columns: 150px 140px 1fr auto; gap: 12px; align-items: end; }
@media (max-width: 640px) { .picker-bottom { grid-template-columns: 1fr 1fr; } }
.stepper { display: flex; }
.stepper input { text-align: center; border-radius: 0; border-left: 0; border-right: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper button { font: inherit; font-size: 1.1rem; width: 40px; border: 1px solid #cfd6d1; background: #f2f4f2; cursor: pointer; }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.money-input { display: flex; align-items: center; border: 1px solid #cfd6d1; border-radius: 10px; background: #fff; padding-left: 10px; }
.money-input input { border: 0; padding-left: 4px; }
.money-input:focus-within { outline: 3px solid rgba(31, 111, 84, 0.25); border-color: var(--brand); }
.money-input input:focus { outline: none; }
.picker-total { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); font-weight: 600; padding-bottom: 8px; }
.picker-total strong { font-size: 1.25rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.picker-note { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); }
.picker-note.bad { color: var(--bad); }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 11px 16px; cursor: pointer;
  border: 1px solid #cfd6d1; background: #fff; color: var(--ink);
}
.btn:hover { background: #f2f4f2; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #185c45; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link-btn { font: inherit; font-size: 0.9rem; background: none; border: 0; color: var(--brand); cursor: pointer; padding: 4px 0; text-decoration: underline; }
.link-btn.danger { color: var(--muted); }
.link-btn.danger:hover { color: var(--bad); }

/* Items table */
.items-wrap { margin-top: 18px; }
.items { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.items th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.items td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.items .num { text-align: right; font-variant-numeric: tabular-nums; }
.items .i-name { font-weight: 600; }
.items .i-cat { font-size: 0.8rem; color: var(--muted); }
.items .i-src { font-size: 0.75rem; color: var(--muted); }
.items select, .items input { padding: 6px 8px; font-size: 0.9rem; border-radius: 8px; }
.items input.qty-in { width: 64px; text-align: right; }
.items input.unit-in { width: 84px; text-align: right; }
.items .rm { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px 8px; border-radius: 6px; }
.items .rm:hover { color: var(--bad); background: var(--bad-soft); }
.items tfoot td { font-weight: 700; border-bottom: 0; }
@media (max-width: 640px) {
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: minmax(0, 1fr) 48px 64px 66px; gap: 6px 6px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .items td { border: 0; padding: 0; }
  .items td:nth-child(1) { grid-column: 1 / 4; grid-row: 1; }
  .items td:nth-child(6) { grid-column: 4; grid-row: 1; text-align: right; }
  .items td:nth-child(2) select { width: 100%; }
  .items input.qty-in, .items input.unit-in { width: 100%; }
  .items td.line { font-weight: 700; }
}

.empty { text-align: center; padding: 24px 10px; color: var(--muted); }
.empty p { margin: 0 0 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { font: inherit; font-size: 0.88rem; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* Summary */
.summary h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.grand { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
.by-donation { list-style: none; margin: 0 0 12px; padding: 0; font-size: 0.9rem; }
.by-donation li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); }
.by-donation li span:last-child { font-variant-numeric: tabular-nums; }

.checklist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.note { font-size: 0.84rem; border-radius: 10px; padding: 10px 12px; line-height: 1.4; }
.note strong { display: block; margin-bottom: 2px; }
.note.info { background: var(--brand-soft); color: #174d3b; }
.note.warn { background: var(--warn-soft); color: #6b4000; }
.note.bad { background: var(--bad-soft); color: var(--bad); }

.export { margin: 10px 0 8px; }
.coffee-line { text-align: center; font-size: 0.85rem; color: var(--muted); margin: 10px 0 0; }
.coffee-line a { color: var(--ink); font-weight: 600; text-decoration: none; background: #fff6bf; padding: 2px 8px; border-radius: 999px; }
.coffee-line a:hover { background: #ffdd00; }
.resume { text-align: center; margin: 6px 0; }
.remember { display: flex; gap: 8px; align-items: flex-start; font-size: 0.85rem; color: var(--muted); margin: 12px 0 8px; cursor: pointer; }
.remember input { margin-top: 3px; }
.remember em { font-style: normal; opacity: 0.8; }

.disclaimer { font-size: 0.85rem; color: var(--muted); max-width: 780px; padding: 4px 0 30px; }

.site-footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: 0.85rem; background: var(--card); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.92rem;
  transition: all 0.2s ease; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Article pages */
.article { max-width: 760px; padding: 30px 0 40px; }
.article h1 { font-size: 2rem; margin: 0 0 10px; }
.article h2 { margin-top: 32px; font-size: 1.3rem; }
.article table { border-collapse: collapse; width: 100%; font-size: 0.95rem; margin: 12px 0; }
.article th, .article td { text-align: left; border-bottom: 1px solid var(--line); padding: 8px; }
.article .callout { background: var(--brand-soft); border-radius: 12px; padding: 14px 16px; }
.article p { font-size: 1.05rem; }
.about-points { padding-left: 20px; margin: 18px 0 22px; }
.about-points li { margin-bottom: 6px; }
.article a.btn { display: inline-block; text-decoration: none; }
.article .small-print { font-size: 0.85rem; color: var(--muted); margin-top: 28px; }
.support { margin-top: 34px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.support h2 { margin-top: 0; }
.btn.coffee { background: #ffdd00; border-color: #ffdd00; color: #1d2521; }
.btn.coffee:hover { background: #f5d300; }
.support-note { font-size: 0.82rem; color: var(--muted); margin-bottom: 0; }

/* Print */
.print-only { display: none; }
@media print {
  @page { margin: 14mm 12mm; }
  body { background: #fff; color: #111; }
  .site-header, .site-footer, main, .toast, dialog { display: none !important; }
  .print-only { display: block !important; padding: 0; font-size: 10.5pt; line-height: 1.35; }
  .print-only .p-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #1f6f54; padding-bottom: 6pt; margin-bottom: 10pt; }
  .print-only .p-brand { color: #1f6f54; font-weight: 700; font-size: 9pt; text-transform: uppercase; letter-spacing: 0.06em; }
  .print-only h1 { font-size: 16pt; margin: 2pt 0 0; }
  .print-only .p-meta { text-align: right; font-size: 9pt; color: #444; }
  .print-only h2 { font-size: 12pt; margin: 14pt 0 4pt; }
  .print-only h2 span { font-weight: 400; color: #555; font-size: 10pt; margin-left: 6pt; }
  .print-only table { width: 100%; border-collapse: collapse; }
  .print-only th { font-size: 8.5pt; text-transform: uppercase; letter-spacing: 0.04em; color: #555; border-bottom: 1.5px solid #999; padding: 3pt 4pt; text-align: left; }
  .print-only td { border-bottom: 1px solid #ddd; padding: 3pt 4pt; text-align: left; vertical-align: top; }
  .print-only tr { break-inside: avoid; }
  .print-only .num { text-align: right; white-space: nowrap; }
  .print-only .p-sub td, .print-only .p-grand td { font-weight: 700; border-bottom: 0; }
  .print-only .p-grand td { border-top: 1.5px solid #1f6f54; font-size: 11.5pt; }
  .print-only .p-summary { margin-bottom: 6pt; }
  .print-only .p-donation { break-inside: auto; }
  .print-only .p-donation h2 { break-after: avoid; }
  .print-only .small { font-size: 8.5pt; color: #555; }
  .print-only .p-foot { margin-top: 14pt; border-top: 1px solid #ccc; padding-top: 6pt; }
  .print-only .p-receipts { break-before: page; }
  .print-only .p-receipt { margin: 0 0 12pt; break-inside: avoid; text-align: center; }
  .print-only .p-receipt figcaption { font-size: 9pt; color: #444; text-align: left; margin-bottom: 4pt; }
  .print-only .p-receipt img { max-width: 100%; max-height: 225mm; object-fit: contain; border: 1px solid #ddd; }
}

/* Ads */
.ad-slot { margin: 0 0 20px; text-align: center; }
.ad-label { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
/* Hide the whole slot (label included) when Google has no ad to show,
   e.g. before the site is approved. */
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }
@media print { .ad-slot { display: none !important; } }

/* Receipt photos */
.receipts { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.receipts-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn.small { padding: 7px 12px; font-size: 0.88rem; }
.receipts-note { font-size: 0.8rem; color: var(--muted); flex: 1; min-width: 200px; }
.receipt-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.receipt-thumbs:empty { display: none; }
.receipt-thumb { position: relative; margin: 0; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f2f4f2; }
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rm-receipt {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 0.7rem; cursor: pointer; line-height: 22px; padding: 0;
}
.rm-receipt:hover { background: var(--bad); }

/* Dialog (Google Sheets how-to) */
.dialog {
  border: 0; border-radius: var(--radius); padding: 22px 24px; max-width: 460px; width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); color: var(--ink);
}
.dialog::backdrop { background: rgba(20, 30, 25, 0.45); }
.dialog h2 { margin: 0 0 6px; font-size: 1.15rem; }
.dialog ol { padding-left: 20px; margin: 12px 0; }
.dialog li { margin-bottom: 6px; }
.dlg-file { margin: 0; font-size: 0.88rem; color: var(--muted); word-break: break-all; }
.dlg-alt { font-size: 0.9rem; margin: 8px 0; }
.dlg-note { font-size: 0.82rem; color: var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 8px 10px; }
