:root {
  --ink: #1d2421;
  --muted: #5b6863;
  --line: #cfd6d1;
  --paper: #ffffff;
  --desk: #eef1f5;
  --accent: #18315b;          /* CSBC navy, sampled from the logo */
  --accent-soft: #e2e8f2;
  --pending: #8a5a12;
  --declined: #8b2e2e;
  --needed-bg: #f5e7cd;
  --text-size: 10.5pt;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 var(--sans); color: var(--ink); background: var(--desk); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.appbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
.appbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; }
.brand img { display: block; }
.brand-name { font: 700 17px/1.2 var(--serif); letter-spacing: .01em; }
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumbs img { display: block; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { color: var(--line); }
.account { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.account button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.account a { color: var(--accent); }
.banner { background: var(--needed-bg); color: var(--ink); padding: 8px 20px; font-size: 14px; }
.banner.error { background: #f6dede; }

.primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px; font-weight: 600; cursor: pointer; }
.primary:disabled { opacity: .55; cursor: default; }
.note { color: var(--muted); font-size: 13px; margin: 6px 0 0; min-height: 1.2em; }

.workspace { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; padding: 20px; align-items: start; }
.controls { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 12px; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
legend { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; padding: 0; }
.controls label { font-size: 13px; }
.controls input[type="date"], .controls input[type="number"], .controls select { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; background: var(--paper); width: 100%; }
.check { display: flex; gap: 8px; align-items: center; }
.types { display: flex; flex-direction: column; gap: 4px; }
.print { background: var(--paper); border: 2px solid var(--accent); color: var(--accent); border-radius: 8px; padding: 8px; font-weight: 700; cursor: pointer; }
.print:disabled { opacity: .45; cursor: default; }

.preview { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.preview > .empty { color: var(--muted); padding: 40px; text-align: center; background: var(--paper); border: 1px dashed var(--line); border-radius: 10px; }

/* ---------- the sheet: what gets printed ---------- */
.sheet { background: var(--paper); padding: 0.4in; box-shadow: 0 1px 3px rgba(0,0,0,.12); font-size: var(--text-size); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 8px; }
.sheet-head .church { font-size: .85em; color: var(--muted); }
.sheet-head h2 { font: 700 1.45em/1.15 var(--serif); margin: 0; }
.sheet-meta { text-align: right; font-size: .85em; }
.sheet-meta .printed { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.matrix { width: 100%; border-collapse: collapse; table-layout: fixed; }
.matrix col.col-position { width: 9.5em; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 3px 5px; vertical-align: top; text-align: left; }
.matrix thead th { background: var(--accent-soft); font-weight: 700; }
.matrix thead th.corner { color: var(--muted); font-weight: 600; font-size: .85em; vertical-align: bottom; }
.plan-date { white-space: nowrap; }
.plan-title { font-weight: 400; font-size: .85em; color: var(--muted); }
.team-row th { background: #f3f5f2; font: 700 1em/1.3 var(--serif); padding-top: 5px; }
th.position { font-weight: 600; }
.person { display: flex; gap: 4px; line-height: 1.3; }
.person .mark { width: 1em; flex: none; text-align: center; font-weight: 700; }
.person.confirmed .mark { color: var(--accent); }
.person.pending .mark, .person.pending .name { color: var(--pending); }
.person.declined .name { text-decoration: line-through; color: var(--declined); }
.person.declined .mark { color: var(--declined); }
.needed { display: inline-block; margin-top: 2px; background: var(--needed-bg); border-radius: 3px; padding: 0 5px; font-size: .85em; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: .8em; color: var(--muted); }
.legend .mark { font-weight: 700; }
.legend .confirmed .mark { color: var(--accent); }
.legend .pending .mark { color: var(--pending); }
.legend .declined .mark { color: var(--declined); }
.sheet .empty { color: var(--muted); }

/* ---------- home page ---------- */
.hub { max-width: 920px; margin: 0 auto; padding: 36px 20px 56px; }
.hub-intro { display: flex; gap: 20px; align-items: center; margin-bottom: 32px; }
.hub-intro h1 { font: 700 30px/1.15 var(--serif); color: var(--accent); margin: 0 0 6px; }
.hub-intro p { margin: 0; color: var(--muted); max-width: 62ch; }
.hub-sections { display: flex; flex-direction: column; gap: 28px; }
.hub-section-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.hub-section-head h2 { font: 700 19px/1.2 var(--serif); margin: 0; }
.hub-section-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.app-tile { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.app-icon { flex: none; display: block; }
.tool-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tool-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.tool-card:hover { border-color: var(--accent); }
.tool-name { font-weight: 700; font-size: 16px; color: var(--accent); }
.tool-desc { color: var(--muted); font-size: 14px; flex: 1; }
.tool-open { font-size: 13px; font-weight: 600; color: var(--accent); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 9px; }
.hub-foot { margin-top: 40px; font-size: 12.5px; color: var(--muted); }
.gate { max-width: 440px; margin: 48px auto 0; padding: 36px 32px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gate h1 { font: 700 26px/1.2 var(--serif); color: var(--accent); margin: 4px 0 0; }
.gate p { margin: 0; }
.gate .primary { padding: 11px 22px; font-size: 16px; margin: 6px 0; }
.gate .note a { color: var(--accent); }
.gate-message { background: var(--needed-bg); border-radius: 8px; padding: 6px 12px; font-size: 14px; }
.gate + .hub-foot, .hub > .hub-foot { text-align: center; }

/* ---------- labs ---------- */
.lab { max-width: 860px; margin: 0 auto; padding: 28px 20px 56px; display: flex; flex-direction: column; gap: 18px; }
.lab-intro h1 { font: 700 26px/1.2 var(--serif); color: var(--accent); margin: 0 0 8px; }
.lab-intro p { margin: 0; max-width: 68ch; }
.lab-input { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.lab-input label { font-weight: 600; font-size: 14px; }
.lab-input-row { display: flex; gap: 8px; margin-top: 6px; }
.lab-input-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; }
.lab-input .error { margin: 6px 0 0; font-size: 13px; color: var(--declined); }
.lab-demos { display: flex; flex-direction: column; gap: 14px; }
.lab-kind { margin: 0; font-weight: 600; }
.lab-card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.lab-card h2, .lab-notes h2 { font: 700 18px/1.2 var(--serif); margin: 0; display: flex; gap: 8px; align-items: center; }
.lab-card .note { margin: 0; }
.tag { font: 600 11.5px/1 var(--sans); background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 9px; }
.lab-stage { align-self: stretch; border: 1px dashed var(--line); border-radius: 8px; padding: 18px; background: var(--desk); display: flex; justify-content: center; }
.demo-link { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; border-radius: 8px; padding: 9px 18px; }
.secondary-btn { background: var(--paper); border: 1px solid var(--accent); color: var(--accent); border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.secondary-btn:disabled { opacity: .6; cursor: default; }
.snippet { align-self: stretch; margin: 0; background: #1d2421; color: #e7ece9; border-radius: 8px; padding: 10px 12px; overflow-x: auto; font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre; }
.copy { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.lab-notes { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.lab-notes ul { margin: 10px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.lab-notes a, .lab-card a:not(.demo-link) { color: var(--accent); }
.lab-unsupported { margin: 0; }

@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  .controls { position: static; }
  .sheet { padding: 12px; }
  .appbar { padding: 8px 16px; flex-wrap: wrap; }
  .crumbs > span:not([aria-current]), .crumbs .crumb-sep, .crumbs img { display: none; }
  .hub { padding: 24px 16px 40px; }
  .hub-intro { align-items: flex-start; }
  .hub-mark { width: 48px; height: 48px; }
  .hub-intro h1 { font-size: 24px; }
  .gate { margin-top: 16px; padding: 28px 20px; }
}

@media print {
  body { background: #fff; }
  .appbar, .banner, .controls, .gate { display: none !important; }
  .workspace { display: block; padding: 0; }
  .preview { display: block; }
  .sheet { box-shadow: none; padding: 0; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .table-wrap { overflow: visible; }
  .matrix thead { display: table-header-group; }
  .matrix tr { break-inside: avoid; }
  .team-row { break-after: avoid; }
  .matrix thead th, .team-row th, .needed { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
