/* Styled after oakhillbc.org: warm off-white pages, charcoal navigation, green accents.
   Colors and fonts come from the church site's own stylesheet. */
/* Fonts are served from this site (/fonts), latin letters only; anything else falls back to the system font. */
@font-face { font-family: "Lato"; font-weight: 400; font-display: swap; src: url(/fonts/lato-400.woff2) format("woff2"); }
@font-face { font-family: "Lato"; font-weight: 700; font-display: swap; src: url(/fonts/lato-700.woff2) format("woff2"); }
@font-face { font-family: "Libre Franklin"; font-weight: 500 700; font-display: swap; src: url(/fonts/libre-franklin.woff2) format("woff2"); }
* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f6f4f2;
  --surface: #ffffff;
  --border: #d2cfcc;
  --text: #33312e;
  --muted: #6b665f;
  --charcoal: #33312e;
  --charcoal-hover: #46433f;
  --on-charcoal: #f6f4f2;
  --on-charcoal-muted: #bdb8b1;
  --green: #67a044;
  --green-dark: #4f8433;
  --link: #24648c;
  --error: #b3261e;
  --ok: #3d7a22;
  --focus: #24648c;
}

body {
  margin: 0;
  font-family: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

h1, h2, h3, button, .btn, th {
  font-family: "Libre Franklin", "Lato", system-ui, sans-serif;
}
h1 { font-size: 1.9rem; font-weight: 700; margin: 0.25rem 0; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 0.5rem; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
a { color: var(--link); }

.muted { color: var(--muted); }
.small-text { font-size: 0.85rem; }
.strong { font-weight: 700; }
.location { color: var(--muted); font-size: 1.05rem; margin: 0; }
.num { text-align: right; }
.icon { display: inline-flex; width: 20px; height: 20px; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; }

/* ---- Shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 256px;
  height: 100vh;
  padding: 1rem 0.6rem;
  background: var(--charcoal);
  color: var(--on-charcoal);
  overflow-y: auto;
}
.sidebar .muted { color: var(--on-charcoal-muted); }
.org { display: flex; gap: 0.7rem; align-items: center; padding: 0.4rem 0.5rem 1.2rem; }
.org-logo { width: 46px; height: 46px; flex-shrink: 0; }
.org-name { font-family: "Libre Franklin", sans-serif; font-weight: 700; line-height: 1.2; }
.nav-group { margin: 1rem 0.5rem 0.3rem; font-size: 0.8rem; color: var(--on-charcoal-muted); }
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  font-family: "Libre Franklin", sans-serif;
  font-weight: 500;
  color: var(--on-charcoal);
  text-decoration: none;
  border-radius: 7px;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--charcoal-hover); color: var(--green); }
.nav-link.active { background: var(--charcoal-hover); border-left-color: var(--green); }
.account-box { margin-top: auto; padding: 0.8rem 0.5rem 0.2rem; border-top: 1px solid var(--charcoal-hover); }
.account-box .link { margin-top: 0.3rem; color: var(--on-charcoal); }

.main-col { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  height: 56px;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-family: "Libre Franklin", sans-serif; font-weight: 500; }
.menu-btn { display: none; }
.page { padding: 1.5rem 1.5rem 3rem; }
.view { max-width: 1200px; }
.view.narrow { max-width: 560px; }
.backdrop { display: none; }

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.open { transform: none; }
  .backdrop.show { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(51, 49, 46, 0.6); }
  .menu-btn { display: inline-flex; }
  .page { padding: 1.25rem 1rem 3rem; }
}

/* ---- Auth screens ---- */
.auth-box { max-width: 460px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.auth-logo { display: block; width: 96px; height: 96px; margin: 0 0 0.5rem; }
.overlay { position: fixed; inset: 0; z-index: 50; overflow-y: auto; background: var(--bg); }

/* ---- Page headers and actions ---- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.small-icon { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.8rem; font-size: 0.9rem; }
.small-icon .icon { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; padding: 0.2rem; color: var(--muted); background: none; border: 0; cursor: pointer; }
.icon-btn:hover { color: var(--text); }
.icon-btn .icon { width: 18px; height: 18px; }

/* ---- Client picker ---- */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.7rem 0.9rem;
  font: inherit;
  color: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover { border-color: var(--green); }

/* ---- Tables and search ---- */
.search { max-width: 360px; margin-bottom: 1rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 0.8rem 1rem; text-align: left; white-space: nowrap; }
table.data th { font-weight: 500; color: var(--muted); font-size: 0.9rem; }
table.data td { border-top: 1px solid var(--border); }
table.data td.num { text-align: right; }
.ssn { letter-spacing: 0.1em; margin-right: 0.4rem; }
.picker-list { margin: 1rem 0; }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { color: var(--link); text-decoration: underline; }

/* ---- Forms ---- */
.section { margin-bottom: 2rem; }
.field { margin: 1.25rem 0; }
.field label { display: block; font-weight: 700; margin-bottom: 0.4rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: stretch; max-width: 520px; }
.inline-form .btn { white-space: nowrap; }
.field-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0.75rem; }
form.narrow { max-width: 460px; }

input:not([type="checkbox"]), select, textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input::placeholder, textarea::placeholder { color: #8f8a83; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
input[type="checkbox"] { accent-color: var(--green-dark); }
textarea { resize: vertical; min-height: 5rem; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--error); }
.error { color: var(--error); font-size: 0.85rem; margin-top: 0.25rem; display: block; }

.check-card {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.check-card input { width: 1.2rem; height: 1.2rem; margin: 0.15rem 0 0; flex-shrink: 0; }
.check-card > span { display: flex; flex-direction: column; gap: 0.15rem; }
.check-title { font-weight: 700; }

.dep-row { margin-bottom: 0.75rem; }
.dep-fields { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 6rem auto; gap: 0.5rem; align-items: center; }
.dep-row.invalid input { border-color: var(--error); }
@media (max-width: 520px) {
  .dep-fields { grid-template-columns: 1fr 1fr; }
  .dep-fields input:first-child { grid-column: 1 / -1; }
}

/* ---- Wizard ---- */
.crumb { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 0.4rem; }
.crumb:hover { color: var(--link); }
.stepper { display: flex; list-style: none; margin: 0 0 2rem; padding: 0; }
.stepper li {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.stepper li:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 21px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
}
.stepper li.done::before, .stepper li.current::before { background: var(--green); }
.stepper .circle {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
}
.stepper .done .circle { background: var(--green-dark); color: #fff; border-color: var(--green-dark); cursor: pointer; }
.stepper .current .circle { background: var(--charcoal); color: #fff; border-color: var(--charcoal); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--green); }
.stepper .current, .stepper .done { color: var(--text); font-weight: 700; }

.catalog { margin-top: 1rem; }
.category { border-top: 1px solid var(--border); }
.category summary { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 0.25rem; font-size: 1.05rem; cursor: pointer; }
.cat-name { flex: 1; }
.pill { padding: 0.2rem 0.65rem; font-size: 0.85rem; white-space: nowrap; background: #ebe8e4; border-radius: 999px; }
.item, .selected-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.25rem 0.6rem 1rem; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 1.02rem; }
input.qty { width: 5rem; padding: 0.4rem 0.5rem; }
.selected-row { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 0.5rem; padding: 0.6rem 0.75rem; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 2rem 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.empty .icon { width: 40px; height: 40px; color: var(--muted); }

.card { margin-bottom: 1.25rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0; }
.row span:last-child { text-align: right; }
.stack { padding: 0.5rem 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.card-head h3 { margin-bottom: 0.5rem; }
.stack table { margin-top: 0.4rem; }
.repeat { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.notice { margin: 0 0 0.6rem; padding: 0.5rem 0.75rem; background: #eef5e8; border-left: 3px solid var(--green); border-radius: 4px; }
.stack span { display: block; }
.card table { width: 100%; border-collapse: collapse; border: 1px solid var(--border); }
.card th, .card td { padding: 0.75rem; text-align: left; }
.card th { background: #efece8; font-weight: 700; }
.card td { border-top: 1px solid var(--border); }
.card td.num, .card th.num { text-align: right; }
.submitted { text-align: center; padding: 2.5rem 1.25rem; }

/* ---- Dashboard ---- */
.dash-controls { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); column-gap: 1rem; }
.stat-row { display: flex; gap: 2rem; }
.stat-number { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.bars { display: flex; gap: 0.4rem; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.bar-track { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; width: 100%; height: 180px; }
.bar { width: 100%; max-width: 48px; min-height: 2px; background: var(--green); border-radius: 4px 4px 0 0; }
.bar-value { font-size: 0.85rem; }
.bar-label { margin-top: 0.3rem; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

/* ---- Buttons ---- */
.nav { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-top: 2rem; }
.nav.center { justify-content: center; }
.btn {
  padding: 0.75rem 1.4rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.btn.primary { color: #fff; background: var(--green-dark); }
.btn.outline { background: var(--surface); border-color: var(--border); }
.btn.small { padding: 0.4rem 0.9rem; font-size: 0.9rem; background: var(--surface); border-color: var(--border); }
.btn.small.primary { background: var(--green-dark); border-color: transparent; }
.btn.ghost, .btn.ghost.small { background: transparent; border-color: transparent; color: var(--muted); }
.btn:hover:not(:disabled) { border-color: var(--green); }
.btn.primary:hover:not(:disabled) { background: #3f6c28; border-color: transparent; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: default; }
button.link {
  padding: 0;
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}
.switch { margin-top: 1.5rem; }

.status { margin: 1rem 0 0; }
.status.fail { color: var(--error); }
.status.ok { color: var(--ok); }

/* ---- Test accounts ---- */
.test-badge { display: inline-block; margin-left: 0.5rem; padding: 0.05rem 0.5rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; color: #3b2a00; background: #ffd866; border: 1px solid #c79100; border-radius: 999px; }
table.data tr.test-row td { background: #fff8e1; }
.test-tag { margin: 0 0 0.75rem; padding: 0.3rem 0.6rem; font-weight: 700; text-align: center; color: #3b2a00; background: #ffd866; border: 1px dashed #c79100; border-radius: 4px; }
.filter-line { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0 0; }

/* ---- Printable visit summary ---- */
.view.summary-view { max-width: 800px; }
.sheet-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 2px solid var(--green); }
.sheet-logo { width: 64px; height: 64px; }
.sheet-org { font-family: "Libre Franklin", sans-serif; font-weight: 700; font-size: 1.1rem; }
.sheet-title { margin: 0; font-size: 1.6rem; }
.printout { display: none; }
.client-hero { margin-bottom: 1rem; padding: 1rem 1.25rem; background: #f3f7ee; border: 2px solid var(--green); border-radius: 10px; }
.client-name { font-weight: 700; color: #444; }
.client-line { margin-top: 0.3rem; font-family: "Libre Franklin", sans-serif; font-weight: 700; font-size: 1.9rem; line-height: 1.2; }
.client-notes { margin-top: 0.8rem; font-size: 1.1rem; white-space: pre-wrap; }
.food-for { display: flex; align-items: baseline; gap: 0.75rem; margin: 0.5rem 0; font-size: 1.4rem; }
.agreement { margin-top: 2rem; break-inside: avoid; }
.agreement p { margin: 0; line-height: 1.5; }
.signature { display: flex; align-items: flex-end; gap: 0.6rem; margin-top: 2.75rem; }
.sig-line { flex: 1; min-height: 1.1rem; border-bottom: 1px solid #000; }
.sig-line.short { flex: 0.55; }

@media print {
  /* A zero page margin is what makes browsers drop their own header and footer (page title, date,
     address, page numbers). The spacing comes back as padding on .page below. */
  @page { margin: 0; }
  html, body { height: auto; margin: 0; background: #fff; color: #000; }
  .sidebar, .topbar, .backdrop, .no-print, .icon-btn, #auth-overlay { display: none !important; }
  /* min-height: 100vh on the shell is what spilled onto a blank second page. */
  .shell, .main-col { display: block; min-height: 0; }
  .page { padding: 12mm 14mm; }
  .view, .view.summary-view, .view.narrow { max-width: none; }
  body { font-size: 10pt; line-height: 1.3; }
  .sheet-head { margin-bottom: 0.7rem; padding-bottom: 0.5rem; }
  .sheet-logo { width: 48px; height: 48px; }
  .sheet-title { font-size: 1.3rem; }
  .card { margin-bottom: 0.5rem; padding: 0.5rem 0.75rem; border: 1px solid #999; border-radius: 6px; break-inside: avoid; }
  .card h3 { margin-bottom: 0.25rem; font-size: 1rem; }
  .row { padding: 0.15rem 0; }
  .stack { padding: 0.25rem 0; }
  .card th, .card td { padding: 0.3rem 0.6rem; }
  .card th { background: #eee; }
  /* The acknowledgment and signature line sit at the bottom of the page (a little under the page height, so
     Letter and A4 both stay on one sheet). */
  .screen-only { display: none !important; }
  .printout { display: flex !important; flex-direction: column; min-height: calc(100vh - 28mm); }
  .agreement { margin-top: auto; padding-top: 1.5rem; }
  .client-hero { padding: 0.7rem 1rem; }
  .client-line { font-size: 1.7rem; }
  .muted { color: #444; }
  a { color: inherit; text-decoration: none; }
}

/* ---- Hidden elements ---- */
.nav-link[hidden], .pill[hidden] { display: none; }
.nav-link .pill { margin-left: auto; color: var(--text); }

