:root {
    --brand: #785027;
    --brand-dark: #3f2a14;
    --brand-tint: color-mix(in srgb, var(--brand) 14%, #fff);
    --on-dark: #f6efe4;
    --on-dark-muted: #d9c6a8;
    --color-text: #1f2421;
    --color-muted: #5b645e;
    --color-border: #d7ddd8;
    --color-bg: #fdfdfb;
    --color-header-bg: #f4f1ea;
    --color-accent: var(--brand);
    --color-accent-hover: var(--brand-dark);
    --color-row-hover: color-mix(in srgb, var(--brand) 7%, #fff);
    --color-danger: #8a3a3a;
    --color-danger-hover: #722f2f;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 4px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

a { color: var(--color-accent); }

.site-header {
    background: var(--brand-dark);
    color: var(--on-dark);
    border-bottom: 1px solid var(--brand-dark);
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-size: 1.15rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    letter-spacing: 0.01em;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.version-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--brand-dark);
    background: var(--on-dark);
    border: 1px solid var(--on-dark-muted);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    vertical-align: middle;
    margin-left: 0.3rem;
}

.pages-nav-bar {
    background: color-mix(in srgb, var(--brand-dark), #fff 9%);
}
.pages-nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: stretch;
    gap: 0;
    font-size: 1rem;
}
.pages-nav a.nav-btn {
    text-decoration: none;
    color: var(--on-dark);
    font-weight: 600;
    padding: 0.75rem 1.2rem;
    background: transparent;
    border: 0;
    border-radius: 0;
}
.pages-nav a.nav-btn:hover {
    background: color-mix(in srgb, var(--on-dark) 14%, transparent);
    color: #fff;
}
.pages-nav a.nav-btn.is-active {
    background: var(--on-dark);
    color: var(--brand-dark);
}
.site-header .auth-slot { color: var(--on-dark-muted); }

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.95rem;
}

.auth-slot {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
}

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; }

/* Flash messages */
.flash-messages { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    font-size: 0.9rem;
}
.flash-success { background: #eef4ea; border-color: #cfe0c6; }
.flash-error { background: #f8ecec; border-color: #e3c6c6; }
.flash-dismiss {
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-muted);
}

/* Toolbar */
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

#search-box {
    flex: 1 1 260px;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.toolbar-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.toolbar-field select {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.toolbar-checkbox { cursor: pointer; }

.toolbar-actions {
    display: flex;
    gap: 0.6rem;
    margin-left: auto;
}

.btn {
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn:hover { background: var(--color-row-hover); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }

.btn-primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn-danger {
    background: #fff;
    border-color: var(--color-danger);
    color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) { background: #fbeeee; }

/* Member table */
.member-table, .membership-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.member-table th, .member-table td,
.membership-table th, .membership-table td {
    padding: 0.55rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.member-table thead th,
.membership-table thead th {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}
.member-table thead th {
    cursor: pointer;
    user-select: none;
}
.member-table thead th:hover { background: var(--brand-dark); }
.member-table thead th.sort-asc::after { content: " \25B2"; font-size: 0.7em; }
.member-table thead th.sort-desc::after { content: " \25BC"; font-size: 0.7em; }

.member-row { cursor: pointer; }
.member-row:hover { background: var(--color-row-hover); }
.member-row.is-hidden { display: none; }

.row-deceased { background: #e6e6e6; }
.row-deceased:hover { background: #dcdcdc; }

.deceased-legend { display: flex; align-items: center; gap: 0.4rem; }
.legend-swatch {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    background: #e6e6e6;
    border: 1px solid var(--color-border);
    border-radius: 2px;
    vertical-align: middle;
}

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--color-row-hover); }

.cell-center { text-align: center; }
.change-log-cell { white-space: pre-line; }
.empty-state { color: var(--color-muted); text-align: center; padding: 1.5rem; }

/* Detail page */
.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.detail-actions { display: flex; gap: 0.6rem; flex-shrink: 0; }

.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    vertical-align: middle;
    text-decoration: none;
}
.badge { border: 1px solid currentColor; }
.badge-deceased { background: #ece4db; color: #4d4a46; border-color: #6f6a64; }
.badge-current { background: var(--brand-tint); color: var(--brand-dark); border-color: var(--brand); }
.badge-lapsed { background: #f6d9d9; color: #8a1f1f; border-color: #b23a3a; }
a.badge:hover { filter: brightness(0.95); }

.detail-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 2rem;
    margin: 0 0 1.5rem;
}
.detail-fields > div { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.4rem; }
.detail-fields dt { color: var(--color-muted); min-width: 9rem; flex-shrink: 0; }
.detail-fields dd { margin: 0; }
.detail-notes { grid-column: 1 / -1; }

.inline-form { display: inline; }

.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--color-accent);
    text-decoration: underline;
    cursor: pointer;
}

/* Member form */
.member-form fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin: 0 0 1.5rem;
    padding: 1rem 1.25rem 1.25rem;
}
.member-form legend {
    font-weight: 600;
    color: var(--color-muted);
    padding: 0 0.4rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1.5rem;
}
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--color-muted);
}
.form-grid label.is-hidden {
    display: none;
}
.address-row + .address-row {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}
.form-grid input[type="text"],
.form-grid input[type="email"],
.form-grid input[type="date"],
.form-grid input[type="number"],
.form-grid select,
.form-grid textarea {
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--color-text);
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.form-grid textarea { resize: vertical; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--color-text);
}

.membership-form-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.membership-form-table th, .membership-form-table td {
    padding: 0.45rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.membership-form-table select, .membership-form-table input[type="date"] {
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: inherit;
}

.membership-edit-table input[type="text"],
.membership-edit-table input[type="date"],
.membership-edit-table input[type="number"],
.membership-edit-table select {
    width: 100%;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
}
.membership-edit-table input[type="checkbox"] { transform: scale(1.1); }

.newsletter-fields-edit {
    display: flex;
    gap: 0.3rem;
}
.newsletter-fields-edit input { width: 4.5rem; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Phone type field */
.phone-field {
    display: flex;
    gap: 0.4rem;
}
.phone-field input { flex: 1 1 auto; min-width: 0; }
.phone-field select { flex: 0 0 auto; width: auto; }
.subsection-heading {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-muted);
    margin: 1rem 0 0.6rem;
}
.checkbox-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.phone-type-badge {
    display: inline-block;
    font-size: 0.7rem;
    text-transform: capitalize;
    color: var(--color-muted);
    background: var(--color-header-bg);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    vertical-align: middle;
}

/* Application date parts */
.date-parts {
    display: flex;
    gap: 0.5rem;
}
.date-parts select { flex: 1 1 40%; }
.date-parts input[type="number"] { flex: 1 1 30%; }

/* Surname tag input */
.tag-input {
    position: relative;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.4rem 0.5rem;
}
.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}
.tag-chips:empty { margin-bottom: 0; }
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand-dark);
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px color-mix(in srgb, var(--brand-dark) 55%, #fff);
    border-radius: 999px;
    padding: 0.15rem 0.4rem 0.15rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 600;
}
a.tag-chip { text-decoration: none; }
a.tag-chip:hover { background: var(--brand-dark); }
.tag-chip-readonly {
    padding: 0.15rem 0.7rem;
    margin: 0 0.3rem 0.3rem 0;
}
.tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--on-dark-muted);
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.2rem;
}
.tag-remove:hover { color: #fff; }
#surname-tag-text {
    border: none;
    outline: none;
    width: 100%;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.2rem 0;
}
.tag-suggestions {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    z-index: 10;
    max-height: 12rem;
    overflow-y: auto;
}
.tag-suggestions.is-open { display: block; }
.tag-suggestion {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    cursor: pointer;
}
.tag-suggestion:hover { background: var(--color-row-hover); }

/* Donation form */
.donation-form { margin-top: 1.5rem; }

/* Settings */
.settings-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
}
.settings-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.6rem 0.9rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-muted);
    cursor: pointer;
}
.settings-tab-btn.is-active {
    color: var(--color-text);
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}
.settings-tab-panel.is-hidden { display: none; }
.settings-note {
    color: var(--color-muted);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

/* Columns picker */
.columns-picker { position: relative; }
.columns-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.3rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    padding: 0.6rem 0.9rem;
    z-index: 15;
    min-width: 12rem;
}
.columns-panel.is-open { display: block; column-count: 2; column-gap: 1.5rem; min-width: 22rem; }
.columns-panel-item { display: block; font-size: 0.9rem; color: var(--color-text); break-inside: avoid; margin-bottom: 0.4rem; }

/* Account menu */
.account-menu { position: relative; }
.account-menu-btn { display: inline-flex; align-items: center; gap: 0.3rem; }
.account-menu-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.3rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    padding: 0.4rem;
    z-index: 25;
    min-width: 11rem;
}
.account-menu-panel.is-open { display: flex; flex-direction: column; }
.account-menu-panel a,
.account-menu-panel .link-button,
.account-menu-panel .menu-link-button {
    background: none;
    border: 0;
    font-family: inherit;
    cursor: pointer;
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
}
.account-menu-panel a:hover,
.account-menu-panel .link-button:hover,
.account-menu-panel .menu-link-button:hover {
    background: var(--color-row-hover);
    text-decoration: none;
}
.account-menu-panel form { margin: 0; }
.col-hidden { display: none; }

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.25rem;
}
.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.pagination-info {
    font-size: 0.85rem;
    color: var(--color-muted);
    white-space: nowrap;
}

/* Status column highlight */
.status-current { color: var(--color-accent); font-weight: 600; }

/* Cards (member detail) */
.card {
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}
.card h2 { margin-top: 0; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.card-header h2 { margin-bottom: 0.75rem; }
.card-header-actions { display: flex; align-items: center; gap: 0.5rem; }

.modal-box-wide { max-width: 48rem; }

.detail-header-card { margin-bottom: 1.5rem; }
.back-link {
    display: inline-block;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.detail-header-card .detail-header { margin-bottom: 0; }

.notes-log { display: flex; flex-direction: column; gap: 0.9rem; }
.note-entry {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.75rem;
}
.note-entry:last-child { border-bottom: none; padding-bottom: 0; }
.note-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.note-entry-meta { color: var(--color-muted); font-size: 0.8rem; }
.note-entry-text { margin: 0.3rem 0 0; white-space: pre-wrap; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 20, 0.45);
    z-index: 30;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.is-open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.modal-header h2 { margin: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-muted);
}
.modal-close:hover { color: var(--color-text); }

/* Footer */
.site-footer {
    background: var(--brand-dark);
    border-top: 1px solid var(--brand-dark);
    margin-top: 2rem;
}
.site-footer a { color: var(--on-dark); }
.site-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    color: var(--on-dark-muted);
    font-size: 0.8rem;
    text-align: center;
}

/* Two-column member detail layout */
.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}
.detail-fields-1col {
    display: block;
}
.detail-fields-1col > div {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    padding: 0.4rem 0;
}
.detail-fields-1col dt { color: var(--color-muted); min-width: 10rem; flex-shrink: 0; }
.detail-fields-1col dd { margin: 0; }
.is-hidden { display: none; }

/* Right-click column filter context menu */
.context-menu {
    display: none;
    position: absolute;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    z-index: 40;
    width: 14rem;
    padding: 0.5rem;
}
.context-menu.is-open { display: block; }
.context-menu-search {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}
.context-menu-bulk {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.context-menu-bulk button {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-accent);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
}
.context-menu-list {
    max-height: 12rem;
    overflow-y: auto;
    border-top: 1px solid var(--color-border);
    padding-top: 0.3rem;
}
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.2rem;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}
.context-menu-item:hover { background: var(--color-row-hover); }
.member-table thead th.has-filter { color: var(--color-accent); }
.member-table thead th.has-filter::before { content: "\1F50D "; font-size: 0.7em; }

.list-hint {
    color: var(--color-muted);
    font-size: 0.8rem;
    margin: -0.75rem 0 0.75rem;
}

/* Active filters bar */
.active-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.active-filters-bar.is-empty { display: none; margin-bottom: 0; }

.merge-mode-bar:not(.is-hidden) {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    background: var(--color-header-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.2rem 0.3rem 0.2rem 0.7rem;
    font-size: 0.8rem;
    color: var(--color-text);
}
.filter-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-muted);
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.3rem;
}
.filter-chip-remove:hover { color: var(--color-danger); }

/* Version history modal */
.version-history { margin: 0; }
.version-history > div {
    border-bottom: 1px solid var(--color-border);
    padding: 0.6rem 0;
}
.version-history > div:last-child { border-bottom: none; }
.version-history dt { font-weight: 600; margin-bottom: 0.2rem; }
.version-history dd { margin: 0; color: var(--color-muted); font-size: 0.9rem; }

/* Login splash page */
.minimal-body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.minimal-content {
    width: 100%;
    max-width: 24rem;
    padding: 1.5rem;
}
.login-splash { text-align: center; }
.login-splash h1 { margin-bottom: 1.5rem; }
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}
.login-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--color-muted);
}
.login-form input,
.login-form textarea {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: vertical;
}
.login-form .btn { margin-top: 0.5rem; text-align: center; }

.password-field { position: relative; display: flex; }
.password-field input { flex: 1 1 auto; min-width: 0; padding-right: 2.4rem !important; }
.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0.2rem;
    color: var(--color-muted);
    cursor: pointer;
}
.password-toggle-btn:hover { color: var(--color-text); }
.password-toggle-btn .icon-eye-off { display: none; }
.password-toggle-btn.is-visible .icon-eye { display: none; }
.password-toggle-btn.is-visible .icon-eye-off { display: block; }

/* Home page */
.home-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 1.5rem;
    align-items: start;
}
.stats-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.stats-list li { border-bottom: 1px solid var(--color-border); }
.stats-list li:last-child { border-bottom: none; }
.stats-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    text-decoration: none;
    color: inherit;
}
.stats-list a:hover { background: var(--color-row-hover); }
.stats-list-label { color: var(--color-muted); }
.stats-list-value { font-size: 1.3rem; font-weight: 700; color: var(--color-accent); }
.recent-members-card h2 { margin-top: 0; }
.recent-members-list { list-style: none; padding: 0; margin: 0; }
.recent-members-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border);
}
.recent-members-list li:last-child { border-bottom: none; }
.recent-members-date { color: var(--color-muted); font-size: 0.85rem; white-space: nowrap; }

/* Surnames page */
#surname-search {
    display: block;
    width: 100%;
    max-width: 24rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}
.surname-member-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.surname-member-list li { padding: 0.15rem 0; }
.surname-row.is-hidden { display: none; }

@media (max-width: 900px) {
    .detail-layout { grid-template-columns: 1fr; }
    .home-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .detail-fields { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .list-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-actions { margin-left: 0; }
    .date-parts { flex-wrap: wrap; }
    .pages-nav { flex-wrap: wrap; }
    .pagination-bar { flex-direction: column; align-items: stretch; }
}

@media print {
    .site-header, .pages-nav, .site-footer, .list-toolbar, .flash-messages,
    .pagination-bar, .columns-panel, .list-hint, .active-filters-bar,
    .modal-overlay, .no-print { display: none !important; }
    .profile-edit-block, .history-edit-block { display: none !important; }
    .profile-view-block, .history-view-block { display: block !important; }
    .card { background: #fff; }
    body { background: #fff; }
}

.renewal-letter-body {
    white-space: pre-wrap;
    font-family: inherit;
    line-height: 1.6;
}

/* Files: list + viewer side by side */
.files-layout {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}
.files-layout.has-viewer {
    grid-template-columns: 11rem minmax(16rem, 23rem) 1fr;
}
.folder-pane h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.folder-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.folder-item {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    font: inherit;
    padding: 0.4rem 0.6rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}
.folder-item:hover { background: var(--brand-tint); }
.folder-item.is-active { background: var(--brand); border-color: var(--brand-dark); color: #fff; font-weight: 600; }
.folder-item.is-drop-target { outline: 2px dashed var(--brand); outline-offset: 1px; background: var(--brand-tint); color: var(--color-text); }
.folder-count { color: inherit; opacity: 0.75; font-size: 0.85em; }
#files-table tr[draggable="true"] { cursor: grab; }
#files-table tr.is-dragging { opacity: 0.45; }
.folder-manage-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.5rem 0; }
.folder-manage-row .inline-form { display: flex; gap: 0.4rem; align-items: center; }
.content:has(.files-layout.has-viewer) { max-width: 1600px; }
.files-layout.has-viewer .col-type { display: none; }
.files-viewer-pane { position: sticky; top: 7.5rem; }
.viewer-card .viewer-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 14rem);
    min-height: 24rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
#files-table tr.is-selected td { background: var(--brand-tint); }
.file-actions-cell { text-align: right; white-space: nowrap; }
.file-info-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0.2rem;
    margin-left: 0.3rem;
    vertical-align: middle;
    line-height: 0;
    border-radius: 999px;
}
.file-info-btn:hover { color: var(--brand); background: var(--brand-tint); }
@media (max-width: 900px) {
    .files-layout, .files-layout.has-viewer { grid-template-columns: 1fr; }
    .files-viewer-pane { position: static; }
}

.pre-wrap { white-space: pre-wrap; }

.logo-preview { max-width: 16rem; max-height: 8rem; border: 1px solid var(--color-border); padding: 0.4rem; background: #fff; }

.files-bulk-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--brand-tint);
    border: 1px solid var(--brand);
    border-radius: var(--radius);
}
.col-select { width: 2rem; text-align: center; }

/* Merge comparison: same = green, different = red (plus a text marker, not color alone) */
.merge-same td:not(:first-child) { background: #e1f1e5; }
.merge-diff td:not(:first-child) { background: #f8dcdc; }
.merge-marker { font-weight: 600; white-space: nowrap; }
.merge-same .merge-marker { color: #1d6a35; }
.merge-diff .merge-marker { color: #8a1f1f; }
.merge-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; margin: 0.5rem 0 0.75rem; font-size: 0.9rem; }
.merge-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.merge-legend .legend-swatch.is-same { background: #e1f1e5; border-color: #1d6a35; }
.merge-legend .legend-swatch.is-diff { background: #f8dcdc; border-color: #8a1f1f; }

/* Contact list: toolbar right group, inline edit mode, full screen */
.toolbar-right { margin-left: auto; display: flex; gap: 0.5rem; }
.columns-panel.is-open { max-height: 70vh; overflow-y: auto; }
.inline-edit-bar:not(.is-hidden) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--brand-tint);
    border: 1px solid var(--brand);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
}
.inline-edit-actions { display: flex; gap: 0.5rem; }
body.edit-mode-active .cell-editable { outline: 1px dashed color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: -2px; cursor: text; }
body.edit-mode-active .cell-editable.cell-bool { cursor: pointer; }
body.edit-mode-active .member-row:hover { background: transparent; }
.cell-dirty { box-shadow: inset 0 0 0 2px #e0b100; background: #fff6cf; }
.cell-input { width: 100%; min-width: 5rem; font: inherit; padding: 0.15rem 0.3rem; box-sizing: border-box; }
tr.row-error td { background: #f8dcdc; }
#contacts-panel:fullscreen,
#contacts-panel:-webkit-full-screen {
    background: var(--color-bg);
    overflow: auto;
    padding: 1rem 1.5rem;
    width: 100%;
    height: 100%;
}
#contacts-panel:fullscreen .member-table thead th,
#contacts-panel:-webkit-full-screen .member-table thead th { position: sticky; top: 0; z-index: 2; }
#contacts-panel:fullscreen .member-table { width: 100%; }
body.table-wide .content,
body.table-wide .site-header-inner,
body.table-wide .pages-nav { max-width: none; }
@media print { .toolbar-right, .inline-edit-bar { display: none !important; } }

/* Pencil edit buttons on contact page boxes */
.icon-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0.3rem;
    line-height: 0;
    border-radius: var(--radius);
}
.icon-btn:hover { color: var(--brand); background: var(--brand-tint); border-color: var(--brand); }
.icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.detail-left .card + .card, .detail-right .card + .card { margin-top: 1rem; }

/* v1.12.6: current-member rows, columns popup, Home layout, two-column Add Record form */
.row-current { background: #e3f3e0; }
.row-current:hover { background: #d3ebce; }
.legend-swatch.is-current { background: #e3f3e0; border-color: #8cc084; }
.columns-modal-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem 1.25rem;
    max-height: 55vh;
    overflow-y: auto;
    padding: 0.25rem 0;
    margin-bottom: 1rem;
}
.columns-modal-list .columns-panel-item { margin-bottom: 0; }
.modal-box-wide .form-actions { justify-content: space-between; }
.stats-list li.stats-sub { display: flex; justify-content: space-between; padding: 0.25rem 1rem 0.25rem 2rem; color: var(--color-muted); font-size: 0.9rem; }
.recent-members-column { display: flex; flex-direction: column; gap: 1rem; }

.form-two-col .form-grid { grid-template-columns: 1fr; gap: 0.6rem; }
.form-two-col .form-grid label:not(.checkbox-label) {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    column-gap: 1rem;
    align-items: center;
    flex-direction: initial;
}
.form-two-col .form-grid label.is-hidden { display: none; }
.form-two-col .form-grid label.span-2 { grid-column: auto; }
.form-two-col .form-grid .checkbox-label { margin-left: 13rem; }
.form-two-col .form-grid label textarea { align-self: start; }
@media (max-width: 700px) {
    .columns-modal-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-two-col .form-grid label:not(.checkbox-label) { grid-template-columns: 1fr; }
    .form-two-col .form-grid .checkbox-label { margin-left: 0; }
}

/* v1.12.7 */
.modal-box.modal-box-columns { max-width: min(72rem, 94vw); width: 94vw; }
.columns-modal-list { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); max-height: 60vh; }
.membership-edit-table .membership-year-input { width: 6rem; }
.membership-edit-table td select + select { margin-top: 0.3rem; display: block; }
.membership-edit-table .membership-spouse-select.is-hidden { display: none; }
.stats-list li.stats-more a { color: var(--brand); font-weight: 600; }

/* v1.12.9 */
.page-jump { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 0.75rem; font-size: 0.9rem; }
.page-jump-input { width: 5rem; padding: 0.35rem 0.5rem; font: inherit; }
.pagination-controls { flex-wrap: wrap; }
.name-warning { color: #8a5a00; background: #fff4d6; border: 1px solid #e0b100; border-radius: 3px; padding: 0 0.35rem; font-size: 0.8rem; margin-top: 0.15rem; display: inline-block; }

/* v1.12.10 */
.row-shared td { color: var(--color-muted); font-style: italic; }
.shared-tag { font-style: normal; font-size: 0.78rem; background: var(--brand-tint); border: 1px solid var(--brand); border-radius: 999px; padding: 0 0.45rem; white-space: nowrap; }
.field-hint { display: block; font-size: 0.75rem; color: var(--color-muted); font-weight: normal; }
tr.row-name-matched td { background: #fff4d6; }

/* v1.12.11 */
.bulk-results { list-style: none; margin: 0.4rem 0; padding: 0; max-height: 14rem; overflow-y: auto; }
.bulk-results li button { display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 4px; padding: 0.4rem 0.6rem; font: inherit; cursor: pointer; color: inherit; }
.bulk-results li button:hover, .bulk-results li button:focus { background: var(--brand-tint); border-color: var(--brand); }
.bulk-table { width: 100%; border-collapse: collapse; margin-bottom: 0.5rem; }
.bulk-table th { text-align: left; font-size: 0.8rem; font-weight: normal; color: var(--color-muted); }
.bulk-table td { padding: 0.15rem 0.25rem 0.15rem 0; }
.bulk-table input, .bulk-table select { width: 100%; box-sizing: border-box; }
.bulk-errors { color: #b00020; margin: 0.5rem 0; padding-left: 1.1rem; }
.bulk-errors:empty { display: none; }
.bulk-success { color: #1b6e2d; font-weight: bold; }
.bulk-warn { color: #8a5a00; }
.duplicate-toolbar { margin-bottom: 0.75rem; }
.duplicate-key { text-transform: capitalize; word-break: break-word; }
.duplicate-merge-link.is-disabled { opacity: 0.45; pointer-events: none; }
.context-menu-blank { border-bottom: 1px solid var(--color-border, #ddd); padding-bottom: 0.35rem; margin-bottom: 0.35rem; }
.context-menu-blank-btn.is-active { background: var(--brand-tint); border-color: var(--brand); font-weight: bold; }

/* v1.12.12 - bulk entry grid */
.modal-box.modal-box-xl { width: min(1150px, 96vw); max-width: 96vw; max-height: 92vh; overflow-y: auto; }
.bulk-hint kbd { border: 1px solid var(--color-border, #bbb); border-radius: 3px; padding: 0 0.3rem; background: var(--brand-tint); font-size: 0.8rem; }
.bulk-grid-wrap { overflow-x: auto; }
.bulk-grid { width: 100%; min-width: 880px; border-collapse: collapse; }
.bulk-grid th { text-align: left; font-size: 0.8rem; font-weight: normal; color: var(--color-muted); padding: 0 0.25rem 0.2rem 0; white-space: nowrap; }
.bulk-grid td { padding: 0.12rem 0.25rem 0.12rem 0; vertical-align: middle; }
.bulk-grid input, .bulk-grid select { width: 100%; box-sizing: border-box; }
.bulk-grid .bulk-num { color: var(--color-muted); font-size: 0.8rem; width: 1.6rem; }
.bulk-grid .bulk-col-contact { min-width: 15rem; }
.bulk-grid .bulk-col-kind { width: 8.5rem; }
.bulk-grid .bulk-col-year { width: 5.2rem; }
.bulk-grid .bulk-col-type { width: 8rem; }
.bulk-grid .bulk-col-family { min-width: 11rem; }
.bulk-grid .bulk-col-date { width: 9.5rem; }
.bulk-grid .bulk-col-amount { width: 6.5rem; }
.bulk-grid .bulk-col-actions { white-space: nowrap; width: 1%; }
.bulk-grid input:disabled, .bulk-grid select:disabled { background: #eee; opacity: 0.55; }
.bulk-grid tr.bulk-row-warn td { background: #fff4d6; }
.bulk-grid tr.bulk-row-error td { background: #fde3e3; }
.bulk-grid input.bulk-unpicked { border-color: #b00020; }
.bulk-grid td.bulk-cell-note { font-size: 0.75rem; color: #8a5a00; }
.bulk-suggestions { position: fixed; z-index: 60; display: none; list-style: none; margin: 0; padding: 0.2rem; background: var(--color-surface, #fff); border: 1px solid var(--brand); border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.2); max-height: 15rem; overflow-y: auto; min-width: 16rem; }
.bulk-suggestions.is-open { display: block; }
.bulk-suggestions li { padding: 0.3rem 0.5rem; cursor: pointer; border-radius: 3px; }
.bulk-suggestions li.is-active, .bulk-suggestions li:hover { background: var(--brand-tint); }
.bulk-suggestions li.is-empty { cursor: default; color: var(--color-muted); }
.bulk-toolbar { display: flex; gap: 0.75rem; align-items: center; margin: 0.5rem 0; }
.bulk-status { font-size: 0.85rem; color: var(--color-muted); }
.bulk-success ul { margin: 0.25rem 0 0.5rem 1.1rem; padding: 0; }
.history-row-duplicate { padding: 0 0.45rem; }

/* v1.12.13 - contact page: boxes stand out from the background, tabs attach to their panel */
.detail-tabs {
    gap: 0.25rem;
    margin-bottom: 0;
    padding-left: 0.6rem;
    border-bottom: 0;
    position: relative;
    z-index: 1;
}
.detail-tabs .detail-tab-btn {
    background: color-mix(in srgb, var(--brand) 16%, #fff);
    border: 1px solid color-mix(in srgb, var(--brand) 35%, #fff);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--color-text);
    padding: 0.55rem 1.15rem;
    margin-top: 0.25rem;
}
.detail-tabs .detail-tab-btn:hover { background: color-mix(in srgb, var(--brand) 24%, #fff); }
.detail-tabs .detail-tab-btn.is-active {
    background: color-mix(in srgb, var(--brand) 9%, #f4f1ea);
    border-top: 3px solid var(--color-accent);
    margin-top: 0;
    margin-bottom: -1px;
    padding-bottom: 0.62rem;
    font-weight: 600;
}
.detail-tab-panel {
    background: color-mix(in srgb, var(--brand) 9%, #f4f1ea);
    border: 1px solid color-mix(in srgb, var(--brand) 35%, #fff);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    padding: 1.1rem;
    margin-bottom: 1.5rem;
}
.detail-tab-panel .card,
.detail-header-card {
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--brand) 32%, #fff);
    box-shadow: 0 1px 4px rgba(60, 40, 15, 0.16);
}
@media print {
    .detail-tab-panel { background: none; border: 0; padding: 0; }
    .detail-tab-panel .card, .detail-header-card { box-shadow: none; }
}

/* v1.12.14 - family member picker on Family memberships */
.family-cell { white-space: nowrap; min-width: 11rem; }
.family-picker.is-hidden { display: none; }
.family-picker .family-search { width: 100%; box-sizing: border-box; }
.family-chip { display: inline-flex; align-items: center; gap: 0.25rem; }
.family-chip.is-hidden, .family-search.is-hidden, .family-na.is-hidden { display: none; }
.family-chip-clear { background: none; border: 0; padding: 0 0.15rem; cursor: pointer; color: inherit; font-size: 1rem; line-height: 1; }
.family-chip-clear:hover { color: var(--color-danger); }
.membership-edit-table .membership-spouse-select { display: none; }
.member-table td.paid-yes { color: #1b7a2e; font-weight: 700; }
.member-table td.paid-no { color: #b3261e; font-weight: 700; }
.year-checks { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; max-height: 9rem; overflow-y: auto; margin-bottom: 0.4rem; }
.report-form .checkbox-label { margin-bottom: 0.25rem; }
.flash-warning { background: #fff4d6; border-color: #ecd38a; }

/* v1.12.15 - on-screen membership history */
.history-table .e { width: 100%; box-sizing: border-box; }
.history-table .e.is-hidden, .history-table .v.is-hidden { display: none; }
.history-table tr.history-derived td { color: var(--color-muted); background: #f3f1ec; }
.history-table tr.history-new td { background: #eef4ea; }
.history-table.is-editing td.hcell { min-width: 7rem; }
.history-table tr.bulk-row-warn td { background: #fff4d6; }
.history-table tr.bulk-row-error td { background: #fde3e3; }
.detail-tabs a.detail-tab-btn { text-decoration: none; display: inline-block; }

/* v1.12.17 - narrow Amount boxes, deleting a membership year */
input.amount-input {
    width: 50px !important; max-width: 50px !important; min-width: 0;
    padding: 0.25rem 0.2rem; text-align: right;
    -moz-appearance: textfield; appearance: textfield;
}
input.amount-input::-webkit-outer-spin-button,
input.amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bulk-grid .bulk-col-amount { width: 4.5rem; }
.history-table tr.history-deleting td { background: #fde3e3; text-decoration: line-through; color: #8a3a3a; }
.history-table tr.history-deleting td.hdel { text-decoration: none; }
.history-table .hdel.is-hidden, .history-table th.hdel.is-hidden { display: none; }

/* v1.12.18 - years covered, family picker in tables, report names stay on one line */
input.years-input { width: 42px !important; max-width: 42px !important; padding: 0.25rem 0.2rem; text-align: center; }
.history-table td.name-cell, .history-table th:nth-child(2) { white-space: nowrap; }
.history-table .fam-cell .family-picker { min-width: 11rem; }
.history-table tr.history-new td { vertical-align: top; }
.table-scroll { overflow-x: auto; }
.bulk-grid .bulk-col-years { width: 3.2rem; }
.modal-box.modal-box-wide { width: min(960px, 94vw); max-width: 94vw; max-height: 90vh; overflow-y: auto; }

.history-table input.membership-year-input { width: 5rem; }
.history-table td.name-cell { white-space: nowrap; }
