:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --line: #dde2e8;
  --brand: #1b2541;
  --brand-2: #3a4f86;
  --accent: #2b3d6b;
  --accent-text: #ffffff;
  --accent-soft: #e9edf6;
  --good: #1a7f37;
  --good-bg: #e6f4ea;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 2px 8px rgb(16 24 40 / .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1b2027;
    --text: #e8ecf1;
    --muted: #9aa6b5;
    --line: #2e3640;
    --accent: #9db4ff;
    --accent-text: #0b1220;
    --accent-soft: #1d2438;
    --good: #5bd17d;
    --good-bg: #173322;
    --bad: #ff8a80;
    --bad-bg: #3d1b1b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 48px; }
h1 { font-size: 1.55rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
a { color: var(--accent); }

.hero { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; padding: 24px 0 60px; }
.hero .wrap { display: flex; align-items: center; gap: 14px; }
.logo {
  flex: none; width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 1.7rem;
  background: rgb(255 255 255 / .16); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .25);
}
a.logo { text-decoration: none; color: inherit; }
a.logo:hover { background: rgb(255 255 255 / .26); }
.hero p { margin: 2px 0 0; opacity: .85; font-size: .95rem; }
.lift { margin-top: -40px; position: relative; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 14px; box-shadow: var(--shadow); }

button, .button {
  font: inherit; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 9px 14px; cursor: pointer; min-height: 42px; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; text-decoration: none; white-space: nowrap;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; min-height: 0; }
button:disabled { opacity: .55; cursor: wait; }

label { display: block; font-weight: 600; margin: 0 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
.search { font-size: 1.05rem; padding: 12px 14px; }

/* Catalog */
.form-list { display: grid; gap: 10px; margin-top: 14px; }
.form-card { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.form-card .main { flex: 1; min-width: 0; }
.form-card .title { font-weight: 700; font-size: 1.05rem; }
.form-card .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-right: 6px; }

/* Form */
fieldset { min-width: 0; margin: 0 0 14px; }
.section h2 { padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.field { grid-column: 1 / -1; min-width: 0; }
.field.half { grid-column: span 1; }
.req { color: var(--bad); }
.help { margin: 4px 0 0; font-size: .85rem; color: var(--muted); }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices.inline { flex-direction: row; flex-wrap: wrap; }
.choices.inline .choice { flex: 1 1 110px; }
.uk { display: block; font-weight: 400; font-size: .85rem; color: var(--muted); }
h2 .uk { font-size: .9rem; margin-top: 2px; }
.note { margin: -4px 0 14px; color: var(--muted); font-size: .92rem; }
.center { text-align: center; }
.choice { display: flex; gap: 10px; align-items: center; font-weight: 400; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.choice input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; }
.sig { border: 1px dashed var(--muted); border-radius: 8px; background: #fff; touch-action: none; display: block; width: 100%; height: 150px; cursor: crosshair; }
.sig-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.submit-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.error-text { color: var(--bad); margin: 0; }
.done { text-align: center; padding: 30px 18px; }
.done .check { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: var(--good-bg); color: var(--good); font-size: 2rem; font-weight: 700; }

/* Staff */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar > input { flex: 2 1 220px; }
.toolbar > select { flex: 1 1 160px; width: auto; }
.rows { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rowi { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.rowi:first-child { border-top: 0; }
.rowi .main { flex: 1; min-width: 0; }
.rowi .name { font-weight: 700; }
.rowi .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted); font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(150%); visibility: hidden;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; transition: transform .2s, visibility .2s; z-index: 10;
}
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }

@media (max-width: 560px) {
  .fields { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
  .form-card, .rowi { flex-direction: column; align-items: stretch; }
  .form-card .actions, .rowi .actions { justify-content: stretch; }
  .form-card .actions > *, .rowi .actions > * { flex: 1; }
  h1 { font-size: 1.3rem; }
}
@media print {
  .hero, .no-print { display: none; }
}
.note-box { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; text-align: left; }

/* Parish manual */
.wrap.wide { max-width: 1180px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 260px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1 1 300px; }
.manual-layout { display: grid; grid-template-columns: 240px 1fr; gap: 14px; align-items: start; }
.toc { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.toc-title { font-weight: 700; margin-bottom: 6px; }
.toc a { display: block; padding: 3px 0; text-decoration: none; color: var(--text); font-size: .92rem; }
.toc a:hover { color: var(--accent); }
.toc a.lvl2 { padding-left: 10px; }
.toc a.lvl3 { padding-left: 22px; font-size: .86rem; color: var(--muted); }
.manual { line-height: 1.6; overflow-wrap: anywhere; }
.manual h1 { font-size: 1.5rem; margin: 1.2em 0 .4em; }
.manual h2 { font-size: 1.25rem; margin: 1.2em 0 .4em; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.manual h3 { font-size: 1.08rem; margin: 1em 0 .3em; }
.manual > :first-child { margin-top: 0; }
.manual table { border-collapse: collapse; width: 100%; }
.manual th, .manual td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.manual blockquote { margin: 0; padding: 4px 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.manual code { background: var(--accent-soft); padding: 1px 4px; border-radius: 4px; }
.manual img { max-width: 100%; }
mark { background: #ffe58a; color: #1b1f24; border-radius: 2px; }
mark.current { background: #ffb02e; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.md-input { min-height: 70vh; font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.md-preview { max-height: 75vh; overflow: auto; }
@media (max-width: 820px) {
  .manual-layout, .editor { grid-template-columns: 1fr; }
  .toc { position: static; max-height: 40vh; }
}
@media print {
  .wrap.wide { max-width: none; padding: 0; }
  .lift { margin: 0; }
  .manual-layout { display: block; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  body { background: #fff; color: #000; }
}

/* Photos (receipts) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.photo { border: 1px solid var(--line); border-radius: 8px; padding: 6px; text-align: center; background: var(--surface); }
.photo img { width: 100%; height: 120px; object-fit: cover; border-radius: 4px; display: block; }

/* Staff sign-in: passcode and email code side by side */
.signin-options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.signin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.signin-card h2 { margin: 0 0 6px; }
.signin-card label { margin-top: 6px; }
.signin-card .button, .signin-card button { margin-top: auto; width: 100%; }
.signin-card .error-text { margin: 4px 0; }
@media (max-width: 620px) { .signin-options { grid-template-columns: 1fr; } }
.add-account { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.add-account h3 { margin: 0 0 6px; font-size: 1rem; }
