:root {
    --ink: #1c1917;
    --muted: #78716c;
    --line: #e7e5e4;
    --paper: #ffffff;
    --page: #f5f5f4;
    --accent: #0f766e;
    --accent-deep: #115e59;
    --danger: #b91c1c;
    --ok: #166534;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 10px 28px rgba(28, 25, 23, 0.06);
    --font: "Segoe UI", system-ui, sans-serif;
    --field-font-size: 1.05rem;
    font-family: var(--font);
}

* { box-sizing: border-box; }
html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}
body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    overflow-x: hidden;
}

/* Same typeface + size for every control (browsers otherwise vary selects/dates/file). */
button,
input,
select,
textarea {
    font-family: inherit;
    font-size: var(--field-font-size);
}
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.ch-wrap {
    width: min(1120px, calc(100% - 2rem));
    margin-inline: auto;
}
.ch-topbar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}
.ch-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 64px;
    width: min(1120px, calc(100% - 2rem));
    margin-inline: auto;
}
.ch-brand {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--ink);
    text-decoration: none;
}
.ch-nav {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}
.ch-main { padding: 1.5rem 0 3rem; }

.ch-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.ch-page-head h1 {
    margin: 0;
    font-size: 1.75rem;
    letter-spacing: -0.02em;
}
.ch-page-head p {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.ch-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.ch-card + .ch-card { margin-top: 1rem; }
.ch-card__title {
    margin: 0 0 1rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent-deep);
}

.ch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 42px;
    padding: 0 1rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: var(--field-font-size);
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
}
.ch-btn:hover { text-decoration: none; background: #fafaf9; }
.ch-btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.ch-btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.ch-btn--danger {
    background: #fff;
    border-color: #fecaca;
    color: var(--danger);
}
.ch-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.ch-flash {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}
.ch-flash--ok { background: #ecfdf5; color: var(--ok); border: 1px solid #a7f3d0; }
.ch-flash--err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.ch-flash ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

.ch-draft-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}
.ch-draft-banner__text { flex: 1 1 16rem; }
.ch-draft-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.ch-draft-status {
    font-size: 0.85rem;
    align-self: center;
}

.ch-install__card {
    max-width: 40rem;
}
.ch-install__section {
    margin: 1.25rem 0 0.65rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink, #1f2937);
}
.ch-install__checks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}
.ch-install__checks li {
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    font-size: 0.9rem;
    display: grid;
    gap: 0.15rem;
}
.ch-install__checks li.is-ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.ch-install__checks li.is-fail {
    background: #fef2f2;
    border-color: #fecaca;
}
.ch-install__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.ch-install__full {
    grid-column: 1 / -1;
}
@media (max-width: 640px) {
    .ch-install__grid {
        grid-template-columns: 1fr;
    }
}

.ch-search {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.ch-search input {
    flex: 1;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-family: inherit;
    font-size: var(--field-font-size);
}

.ch-table { width: 100%; border-collapse: collapse; }
.ch-table th, .ch-table td {
    text-align: left;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.ch-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.ch-muted { color: var(--muted); }
.ch-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.ch-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1rem;
}
.ch-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ch-span-2 { grid-column: span 2; }
.ch-span-3 { grid-column: span 3; }

.ch-field label {
    display: block;
    font-size: 0.95rem;
    font-weight: 650;
    margin-bottom: 0.35rem;
}
.ch-field input,
.ch-field select,
.ch-field textarea,
.ch-children-row input,
.ch-parish-table input {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-size: var(--field-font-size);
    line-height: 1.4;
    color: var(--ink);
}
.ch-field textarea { min-height: 100px; resize: vertical; }
.ch-field input:disabled {
    background: #f5f5f4;
    color: var(--muted);
}
.ch-field input[type="file"] {
    min-height: 0;
    padding: 0.45rem 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.ch-field .ch-error { color: var(--danger); font-size: 0.88rem; margin-top: 0.25rem; }

.ch-ids {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: start;
}
.ch-photo {
    width: 120px;
    text-align: center;
}
.ch-photo__frame {
    width: 110px;
    height: 130px;
    margin: 0 auto 0.5rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fafaf9;
    overflow: hidden;
}
.ch-photo img,
.ch-photo__placeholder {
    width: 110px;
    height: 130px;
    object-fit: cover;
    display: block;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #fafaf9;
}
.ch-photo__placeholder {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.8rem;
}
.ch-photo [hidden],
.ch-photo__placeholder[hidden],
.ch-photo img[hidden] {
    display: none !important;
}

.ch-dl {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0.45rem 1rem;
}
.ch-dl dt { color: var(--muted); font-size: 0.85rem; }
.ch-dl dd { margin: 0; font-weight: 550; }

.ch-btn--small {
    min-height: 36px;
    padding: 0 0.85rem;
    font-size: 0.95rem;
}

.ch-children-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}
.ch-children-head label { margin: 0; }
.ch-children-hint { margin: 0 0 0.65rem; font-size: 0.82rem; }
.ch-children-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.ch-children-row {
    display: grid;
    grid-template-columns: 2rem 1fr auto;
    gap: 0.5rem;
    align-items: center;
}
.ch-children-index {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: var(--accent-deep);
    font-size: 0.78rem;
    font-weight: 700;
}

.ch-combo {
    position: relative;
}
.ch-combo__control {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
}
.ch-combo__input {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
.ch-combo__toggle {
    min-width: 44px;
    border: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 10px 10px 0;
    background: #fafaf9;
    color: var(--ink);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--field-font-size);
}
.ch-combo.is-open .ch-combo__toggle,
.ch-combo.is-open .ch-combo__input {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.ch-combo__list {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    max-height: 240px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.ch-combo__option {
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--field-font-size);
}
.ch-combo__option:hover,
.ch-combo__option.is-active {
    background: #ecfdf5;
    color: var(--accent-deep);
}
.ch-combo__option.is-selected {
    font-weight: 700;
}
.ch-combo__empty {
    padding: 0.7rem;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Photo crop modal */
body.ch-crop-open { overflow: hidden; }
.ch-crop-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 1rem;
}
.ch-crop-modal[hidden] { display: none !important; }
.ch-crop-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 25, 23, 0.55);
}
.ch-crop-modal__panel {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem 1.1rem;
}
.ch-crop-modal__head h2 {
    margin: 0;
    font-size: 1.2rem;
}
.ch-crop-modal__head p {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}
.ch-crop-modal__stage {
    margin-top: 0.9rem;
    height: min(58vh, 460px);
    background: #111;
    border-radius: 12px;
    overflow: hidden;
}
.ch-crop-modal__stage img {
    display: block;
    max-width: 100%;
}
.ch-crop-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1rem;
}

.ch-parish-block { margin-top: 1.1rem; }
.ch-parish-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}
.ch-parish-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.ch-parish-row {
    display: grid;
    grid-template-columns: 2rem 1fr auto;
    gap: 0.55rem;
    align-items: start;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafaf9;
}
.ch-parish-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.55rem;
}
@media (max-width: 900px) {
    .ch-parish-fields { grid-template-columns: 1fr 1fr; }
    .ch-parish-row { grid-template-columns: 2rem 1fr; }
    .ch-parish-row .ch-btn { grid-column: 2; justify-self: start; }
}

.ch-parish-table input { min-height: 44px; }

/* Simple pagination */
.pagination { display: flex; gap: 0.35rem; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.pagination .page-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
}
.pagination .active .page-link { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .disabled .page-link { opacity: 0.45; pointer-events: none; }

/* Auth / guest login */
.ch-guest {
    min-height: 100vh;
}
.ch-guest__main {
    display: grid;
    place-items: center;
    padding: 2rem 1rem 3rem;
    min-height: calc(100vh - 64px);
}
.ch-guest__flash {
    width: min(420px, 100%);
    margin-bottom: 1rem;
}
.ch-login {
    width: min(420px, 100%);
}
.ch-login__card {
    padding: 1.5rem 1.4rem 1.4rem;
}
.ch-login__title {
    margin: 0;
    font-size: 1.55rem;
    letter-spacing: -0.02em;
}
.ch-login__lead {
    margin: 0.4rem 0 1.1rem;
}
.ch-login__form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.ch-login__remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--ink);
    cursor: pointer;
}
.ch-login__remember input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--accent);
}
.ch-login__submit {
    width: 100%;
    min-height: 46px;
    margin-top: 0.25rem;
}
.ch-nav__user {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ch-nav__logout {
    display: inline;
    margin: 0;
}

/* Print reports */
.ch-print-body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: var(--font);
}
.ch-print-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-bottom: 1px solid var(--line);
}
.ch-print-toolbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 56px;
    width: min(920px, calc(100% - 2rem));
    margin-inline: auto;
}
.ch-print-toolbar__brand {
    font-weight: 800;
}
.ch-print-toolbar__actions {
    display: flex;
    gap: 0.5rem;
}
.ch-print-sheet {
    width: min(920px, calc(100% - 2rem));
    margin: 1.25rem auto 2.5rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.4rem 1.5rem 1.75rem;
}
.ch-print-letterhead {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.85rem;
    margin-bottom: 1.1rem;
}
.ch-print-letterhead h1 {
    margin: 0;
    font-size: 1.35rem;
}
.ch-print-letterhead p {
    margin: 0.25rem 0 0;
    color: var(--muted);
}
.ch-print-letterhead__meta {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}
.ch-print-header {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 1rem;
    margin-bottom: 1.1rem;
}
.ch-print-name {
    margin: 0 0 0.65rem;
    font-size: 1.45rem;
}
.ch-print-ids {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem 1rem;
    margin: 0;
}
.ch-print-ids dt {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
}
.ch-print-ids dd {
    margin: 0.1rem 0 0;
    font-weight: 650;
}
.ch-print-photo,
.ch-print-photo img,
.ch-print-photo__empty {
    width: 110px;
    height: 130px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafaf9;
}
.ch-print-photo__empty {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.8rem;
}
.ch-print-section {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
    break-inside: avoid;
}
.ch-print-section h3 {
    margin: 0 0 0.65rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent-deep);
}
.ch-print-subhead {
    margin: 0.85rem 0 0.45rem;
    font-size: 0.9rem;
}
.ch-print-dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem 1rem;
    margin: 0;
}
.ch-print-dl > div dt {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
}
.ch-print-dl > div dd {
    margin: 0.15rem 0 0;
    font-weight: 550;
}
.ch-print-span-2 { grid-column: span 2; }
.ch-print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
.ch-print-table th,
.ch-print-table td {
    border: 1px solid var(--line);
    padding: 0.45rem 0.55rem;
    text-align: left;
    vertical-align: top;
}
.ch-print-table th {
    background: #fafaf9;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}
.ch-print-table--directory td:nth-child(1),
.ch-print-table--directory th:nth-child(1) { width: 4.5rem; }
.ch-print-summary {
    margin: 0 0 0.85rem;
    color: var(--muted);
}
.ch-print-empty,
.ch-print-remarks {
    margin: 0;
    white-space: pre-wrap;
}

@media print {
    body.ch-print-body {
        background: #fff;
    }
    .ch-print-toolbar {
        display: none !important;
    }
    .ch-print-sheet {
        width: auto;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
    }
    .ch-print-section {
        break-inside: avoid;
    }
    a { color: inherit; text-decoration: none; }
}

@media (max-width: 800px) {
    .ch-grid, .ch-grid--3, .ch-ids { grid-template-columns: 1fr; }
    .ch-span-2, .ch-span-3 { grid-column: auto; }
    .ch-photo { width: 100%; }
    .ch-dl { grid-template-columns: 1fr; }
    .ch-print-header { grid-template-columns: 1fr; }
    .ch-print-dl { grid-template-columns: 1fr; }
    .ch-print-span-2 { grid-column: auto; }
}
