/* Third Space: calm, warm and readable. Designed for staff who are not "computer people". */
:root {
  --paper: #f6f3ed;
  --card: #ffffff;
  --ink: #1e2a33;
  --ink-2: #3f4b55;
  --muted: #6c757d;
  --line: #e4ded3;
  --line-2: #efeae2;
  --accent: #2f6f62;
  --accent-ink: #ffffff;
  --accent-soft: #e5f0ec;
  --warm: #9a5a1c;
  --warm-soft: #f8ecdf;
  --rose: #9b3b56;
  --rose-soft: #f7e6ec;
  --alert: #a8261b;
  --alert-soft: #fbe7e4;
  --side: #1f2c33;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 42, 51, .06), 0 2px 8px rgba(30, 42, 51, .04);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font: 600 1.85rem/1.2 var(--serif); letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.pre { white-space: pre-line; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: #d6dde0; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font: 600 1.15rem var(--serif); }
.brand small { color: #9fb0b6; font-size: .75rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; gap: 12px; align-items: center; color: #d6dde0; padding: 9px 12px; border-radius: 9px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.sidebar nav a.on { background: rgba(255, 255, 255, .12); color: #fff; }
.sidebar nav a.on .i { color: #8fd1bf; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f9299; padding: 16px 12px 6px; }
.me { border-top: 1px solid rgba(255, 255, 255, .1); padding: 12px 12px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.me a { color: #fff; display: flex; flex-direction: column; line-height: 1.25; }
.me small { color: #9fb0b6; text-transform: capitalize; }
.me .link { color: #9fb0b6; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 14px 28px; background: var(--paper); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line-2); }
.search { flex: 1; max-width: 640px; position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 14px; color: var(--muted); }
.search input { width: 100%; padding: 11px 14px 11px 42px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 1rem; }
.topbar .btn.primary { margin-left: auto; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; color: var(--ink); cursor: pointer; }
.content { padding: 24px 28px 64px; max-width: 1400px; width: 100%; }
.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

/* ---------- Common blocks ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 720px; }
.card.empty { text-align: center; padding: 40px; color: var(--muted); }
.card.attention { border-color: #e7c79f; background: #fffaf3; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-head a { font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; align-items: start; }
.grid-2 > .card { margin: 0; }
.section-title { font: 600 1.1rem var(--serif); margin: 24px 0 12px; color: var(--ink-2); }
.count { display: inline-block; min-width: 26px; padding: 1px 8px; border-radius: 99px; background: var(--line-2); font-size: .8rem; text-align: center; color: var(--ink-2); font-weight: 600; }
.empty-page { max-width: 520px; margin: 60px auto; text-align: center; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 500 .95rem var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: #cfc6b8; background: #fdfcfa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #275f54; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--alert); border-color: #eab8b2; }
.btn.danger:hover { background: var(--alert-soft); }
.btn.big { padding: 11px 22px; font-size: 1rem; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: 0; padding: 4px; color: var(--muted); cursor: pointer; border-radius: 6px; display: inline-flex; }
.icon-btn:hover { background: var(--alert-soft); color: var(--alert); }
.icon-btn .i { width: 16px; height: 16px; }

/* Flash */
.flash { margin: 16px 28px 0; padding: 12px 16px; border-radius: 10px; background: var(--accent-soft); color: #1f4f45; border: 1px solid #c6ddd5; }
.content .flash, .login .flash, .card .flash { margin: 0 0 16px; }
.flash.error { background: var(--alert-soft); color: var(--alert); border-color: #efc3bd; }

/* Tags */
.tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 550; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
a.tag:hover { text-decoration: none; background: var(--accent-soft); color: var(--accent); }
.tag.warm { background: var(--warm-soft); color: var(--warm); }
.tag.rose { background: var(--rose-soft); color: var(--rose); }
.tag.alert { background: var(--alert-soft); color: var(--alert); }
.tag.dark { background: var(--ink-2); color: #fff; }
.tag.status-member { background: var(--accent-soft); color: #22584d; }
.tag.status-participant { background: #e7eef8; color: #2d4f7c; }
.tag.status-community-connection { background: var(--warm-soft); color: var(--warm); }
.tag.status-non-participant { background: #eeeeee; color: #666; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Avatars */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 650; font-size: .9rem; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar.xl { width: 88px; height: 88px; font-size: 1.8rem; }
.av-0 { background: #dcebe6; color: #22584d; } .av-1 { background: #f3e3d1; color: #7d4818; }
.av-2 { background: #e3e8f3; color: #34507b; } .av-3 { background: #f1e1e7; color: #84324b; }
.av-4 { background: #e8e5f2; color: #4e437e; } .av-5 { background: #e2eedd; color: #3e6330; }
.av-6 { background: #f4ecd2; color: #6f5a12; } .av-7 { background: #dfecef; color: #2d5d68; }

/* Rows (simple lists) */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.rows li:last-child { border-bottom: 0; }
.rows .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rows.big li { padding: 12px 0; }
.rows .when { width: 72px; font-weight: 600; font-size: .9rem; color: var(--ink-2); flex: none; }
.rows .when.today { color: var(--warm); }
.rows.activity li { align-items: flex-start; flex-direction: column; gap: 0; }
.rows form { margin: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; color: var(--ink); box-shadow: var(--shadow); }
a.stat:hover { text-decoration: none; border-color: #cfc6b8; }
.stat strong { font: 600 2rem/1.1 var(--serif); }
.stat span { color: var(--muted); font-size: .9rem; }
.card .stats .stat { box-shadow: none; background: var(--paper); }

.bars { list-style: none; padding: 0; margin: 0; }
.bars a { display: grid; grid-template-columns: 170px 1fr 40px; gap: 12px; align-items: center; padding: 7px 0; color: var(--ink); }
.bars a:hover { text-decoration: none; color: var(--accent); }
.bars meter { width: 100%; height: 10px; }
.bars meter::-webkit-meter-bar { background: var(--line-2); border: 0; border-radius: 99px; height: 10px; }
.bars meter::-webkit-meter-optimum-value { background: var(--accent); border-radius: 99px; }
.bars meter::-moz-meter-bar { background: var(--accent); border-radius: 99px; }
.bars .num { text-align: right; font-weight: 600; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover { background: #fbf9f5; }
.table tr.faded { opacity: .55; }
.table form { margin: 0; }
.card:not(.flush) .table th, .card:not(.flush) .table td { padding-left: 0; }
.person { display: flex; gap: 12px; align-items: center; color: var(--ink); }
.person:hover { text-decoration: none; }
.person:hover strong { color: var(--accent); }
.person span { display: flex; flex-direction: column; line-height: 1.25; }
.table.map tr.matched td:last-child select { border-color: #a9cfc3; background: var(--accent-soft); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.filters input[type=search] { min-width: 220px; }
.filters select.set { border-color: var(--accent); background-color: var(--accent-soft); color: #1f4f45; font-weight: 550; }
.more-filters { flex-basis: 100%; }
.more-filters summary { margin: 2px 0 8px; display: inline-block; }
.more-filters .filters { margin: 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 16px 0; }

/* Forms */
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid #d7d0c4; border-radius: 9px; padding: 8px 11px; background: #fff; max-width: 100%; }
select { padding-right: 28px; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: .92rem; color: var(--ink-2); }
label input, label select, label textarea { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 450; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.req { color: var(--alert); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 18px; }
.span-all { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 550; font-size: .92rem; color: var(--ink-2); margin-bottom: 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { flex-direction: row; cursor: pointer; font-weight: 450; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span { padding: 6px 13px; border: 1px solid #d7d0c4; border-radius: 99px; background: #fff; font-size: .9rem; color: var(--ink-2); user-select: none; }
.pill input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill input:checked + span::before { content: "✓ "; }
.pill input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.row-form.tight { margin: 0; flex-wrap: nowrap; }
.row-form input:not([type=checkbox]) { flex: 1; min-width: 140px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 500; margin-top: 10px; }
.edit-form { max-width: 980px; }
.section-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; position: sticky; top: 70px; z-index: 3; background: var(--paper); padding: 6px 0; }
.section-nav a { padding: 5px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: .88rem; color: var(--ink-2); }
.section-nav a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.edit-form .card { scroll-margin-top: 160px; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding: 20px 0 16px; display: flex; gap: 10px; z-index: 3; }
.danger-zone { margin-top: 32px; padding-top: 20px; border-top: 1px dashed var(--line); max-width: 980px; }
.secret code { font-size: 1.3rem; padding: 6px 12px; background: var(--paper); border-radius: 8px; letter-spacing: .05em; }
.steps { padding-left: 20px; } .steps li { margin-bottom: 6px; }
.cols { columns: 2; }

/* Login */
.login { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 36px 32px; box-shadow: var(--shadow); text-align: center; }
.login h1 { margin-top: 14px; }
.login form { text-align: left; margin: 20px 0; }
.login .btn { justify-content: center; }

/* Google sign-in */
.btn.google { width: 100%; justify-content: center; gap: 12px; margin-top: 20px; border-color: #d0ccc4; font-weight: 600; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; margin: 18px 0 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.me .me-link { flex-direction: row; align-items: center; gap: 10px; }
.me .me-link span { display: flex; flex-direction: column; line-height: 1.25; }
.me img { border-radius: 50%; }

/* Profile */
.profile-head { display: flex; gap: 20px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.profile-head h1 { margin: 0; }
.profile-head p { margin: 2px 0 0; }
.profile { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.facts { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: .88rem; padding-top: 1px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.notes { list-style: none; padding: 0; margin: 14px 0 0; }
.notes li { padding: 12px 0; border-top: 1px solid var(--line-2); }
.notes p { margin-bottom: 4px; }
.notes form { display: inline; margin-left: 8px; }

/* Households / groups / care */
.hh-grid, .group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.hh, .group { display: flex; flex-direction: column; gap: 6px; color: var(--ink); margin: 0; }
.hh:hover, .group:hover { text-decoration: none; border-color: #c9bfae; }
.hh strong, .group strong { color: var(--ink); font-size: 1.02rem; }
.faces { display: flex; }
.faces .avatar { border: 2px solid #fff; margin-right: -8px; }
.group.inactive { opacity: .6; }
.care-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.care-grid .card { margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.settings-grid .card { margin: 0; scroll-margin-top: 80px; }
.options input { border-color: transparent; background: transparent; padding: 4px 8px; }
.options input:hover { border-color: var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .profile { grid-template-columns: 1fr 1fr; }
  .hide-md { display: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .topbar .btn.primary span { display: none; }
  .content { padding: 18px 14px 48px; }
  .profile { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .bars a { grid-template-columns: 120px 1fr 36px; }
  .facts { grid-template-columns: 100px 1fr; }
  .section-nav { top: 58px; }
}

/* ---------- Print (deacon lists, rosters) ---------- */
@media print {
  .sidebar, .topbar, .actions, .filters, .row-form, details, .btn, .icon-btn, .flash, .attention, .pager { display: none !important; }
  .shell { display: block; }
  body { background: #fff; font-size: 12px; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .care-grid { grid-template-columns: 1fr 1fr; }
  a { color: inherit; }
}
