:root {
    --bg: #f5f5f7;
    --surface: rgba(255, 255, 255, .88);
    --surface-solid: #fff;
    --surface-muted: #f5f5f7;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --line: rgba(0, 0, 0, .09);
    --line-strong: rgba(0, 0, 0, .16);
    --blue: #0071e3;
    --blue-hover: #0077ed;
    --blue-soft: #e8f2ff;
    --green: #248a3d;
    --green-soft: #eaf7ed;
    --orange: #c65d00;
    --orange-soft: #fff4e8;
    --red: #d70015;
    --red-soft: #fff0f1;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 3px 12px rgba(0, 0, 0, .04);
    --shadow: 0 2px 5px rgba(0, 0, 0, .04), 0 14px 34px rgba(0, 0, 0, .06);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    color-scheme: light;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: radial-gradient(circle at 92% 2%, rgba(0, 113, 227, .055), transparent 28rem), var(--bg);
    font: 15px/1.47 var(--font);
    letter-spacing: -.01em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { color: var(--text); background: rgba(0, 113, 227, .2); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(0, 113, 227, .35);
    outline-offset: 2px;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
    margin-bottom: .5rem;
    color: var(--text);
    font-size: clamp(2.25rem, 4.5vw, 4rem);
    font-weight: 700;
    line-height: 1.03;
    letter-spacing: -.055em;
}
h2 { margin-bottom: .7rem; color: var(--text); font-size: 1.2rem; font-weight: 650; line-height: 1.2; letter-spacing: -.025em; }
h3 { color: var(--text); font-size: 1rem; font-weight: 650; }
strong { font-weight: 650; }
small, .muted { color: var(--text-secondary); }
small { display: block; font-size: .82rem; }
code {
    display: inline-block;
    max-width: 100%;
    padding: .18rem .42rem;
    overflow-wrap: anywhere;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: #3a3a3c;
    background: var(--surface-muted);
    font: .78rem/1.35 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    letter-spacing: 0;
}
address { color: var(--text-secondary); font-style: normal; line-height: 1.65; }

/* Application shell */
body.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
    height: 100vh;
    padding: 1.35rem 1rem 1.1rem;
    overflow-y: auto;
    color: var(--text);
    background: rgba(249, 249, 251, .82);
    border-right: 1px solid var(--line);
    box-shadow: 8px 0 34px rgba(0, 0, 0, .025);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
}
.brand { display: flex; align-items: center; gap: .8rem; padding: .25rem .45rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: 1.02rem; letter-spacing: -.025em; }
.brand small { margin-top: -.08rem; color: var(--text-secondary); font-size: .76rem; }
.brand-mark {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    overflow: hidden;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(145deg, #343437, #111113);
    box-shadow: 0 5px 14px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(255, 255, 255, .14);
    font-size: 1.2rem;
    font-weight: 700;
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.context-card {
    display: flex;
    flex-direction: column;
    gap: .18rem;
    margin-inline: .25rem;
    padding: .95rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .78);
    box-shadow: var(--shadow-sm);
}
.context-card small, .context-card span { color: var(--text-secondary); }
.context-card strong { font-size: .98rem; }
.context-card a { margin-top: .4rem; font-size: .82rem; font-weight: 600; }
.main-nav { display: flex; flex-direction: column; gap: .18rem; }
.main-nav a {
    padding: .58rem .75rem;
    border-radius: 9px;
    color: #3a3a3c;
    font-size: .91rem;
    font-weight: 520;
}
.main-nav a:hover { color: var(--text); background: rgba(0, 0, 0, .045); text-decoration: none; }
.main-nav a.active { color: #064d96; background: var(--blue-soft); font-weight: 650; }
.main-nav .nav-subitem { padding-left: 1.55rem; color: var(--text-secondary); font-size: .84rem; }
.nav-heading {
    margin: .95rem .75rem .3rem;
    color: var(--text-tertiary);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-top: auto;
    padding: 1rem .75rem .25rem;
    border-top: 1px solid var(--line);
    color: var(--text-secondary);
    font-size: .84rem;
}
.sidebar-footer a { width: fit-content; font-weight: 600; }
.main-content { width: 100%; max-width: 1560px; min-width: 0; margin-inline: auto; padding: clamp(1.5rem, 4vw, 4.25rem); }
.skip-link {
    position: fixed;
    top: -100px;
    left: 1rem;
    z-index: 100;
    padding: .65rem .9rem;
    border-radius: 10px;
    color: #fff;
    background: var(--blue);
    box-shadow: var(--shadow);
}
.skip-link:focus { top: 1rem; }

/* Headers and surfaces */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: clamp(1.6rem, 3vw, 2.7rem); }
.page-header > div:first-child { min-width: 0; }
.page-header p { max-width: 760px; margin-bottom: 0; color: var(--text-secondary); font-size: 1rem; line-height: 1.55; }
.eyebrow {
    display: block;
    margin-bottom: .65rem;
    color: var(--blue);
    font-size: .71rem;
    font-weight: 720;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.card, .metric, .table-wrap, .empty-state {
    border: 1px solid rgba(0, 0, 0, .075);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}
.card { padding: clamp(1.25rem, 2.3vw, 1.8rem); }
.card p:last-child, .empty-state p:last-child { margin-bottom: 0; }
.card-grid, .metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.card-grid > .card, .metric, .lodge-card, .contact-card { transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease; }
.card-grid > .card:hover, .metric:hover, .lodge-card:hover, .contact-card:hover {
    border-color: rgba(0, 0, 0, .12);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card-heading h2 { margin: .45rem 0 .25rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.metric { display: flex; min-height: 164px; flex-direction: column; padding: 1.4rem; }
.metric > span { color: var(--text-secondary); font-size: .86rem; font-weight: 600; }
.metric > strong { margin-top: .2rem; color: var(--text); font-size: clamp(2.35rem, 5vw, 3.35rem); font-weight: 680; line-height: 1; letter-spacing: -.055em; }
.metric a { width: fit-content; margin-top: auto; padding-top: 1rem; font-size: .88rem; font-weight: 600; }
.callout { display: grid; grid-template-columns: minmax(220px, .85fr) minmax(0, 1.65fr); align-items: center; gap: 2rem; margin-top: 1rem; }
.callout p { color: var(--text-secondary); line-height: 1.65; }
.empty-state { padding: clamp(2.2rem, 6vw, 4.5rem); color: var(--text-secondary); text-align: center; }

/* Buttons and badges */
.actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: .58rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: 980px;
    color: var(--text);
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .025);
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.button:hover { border-color: rgba(0, 0, 0, .24); background: #fff; text-decoration: none; }
.button:active { transform: scale(.985); }
.button-primary { border-color: var(--blue); color: #fff; background: var(--blue); box-shadow: 0 3px 10px rgba(0, 113, 227, .2); }
.button-primary:hover { border-color: var(--blue-hover); color: #fff; background: var(--blue-hover); }
.button-link-danger { border-color: rgba(215, 0, 21, .28); color: var(--red); background: var(--red-soft); }
.button-link-danger:hover { border-color: var(--red); color: #fff; background: var(--red); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.badge, .member-total {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    padding: .3rem .58rem;
    border-radius: 980px;
    color: #3a3a3c;
    background: #ededf0;
    font-size: .69rem;
    font-weight: 700;
    letter-spacing: .025em;
    line-height: 1.1;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-active, .badge-import-create { color: #17682d; background: var(--green-soft); }
.badge-suspended, .badge-archived, .badge-import-unchanged, .badge-closed { color: #636366; background: #ededf0; }
.badge-draft, .badge-import-update { color: #075aa8; background: var(--blue-soft); }
.badge-import-error { color: #a50012; background: var(--red-soft); }
.badge-due, .badge-invited { color: #9a4b00; background: var(--orange-soft); }
.badge-partial { color: #075aa8; background: var(--blue-soft); }
.badge-paid { color: #17682d; background: var(--green-soft); }
.badge-cancelled, .badge-revoked { color: #636366; background: #ededf0; }
.title-with-count { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.title-with-count h1, .title-with-count .member-total { margin-bottom: .5rem; }
.member-total { color: #075aa8; background: var(--blue-soft); }

/* Tables */
.table-wrap { overflow-x: auto; background: rgba(255, 255, 255, .94); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: .95rem 1.1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th {
    color: var(--text-tertiary);
    background: rgba(250, 250, 252, .92);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
}
td { color: #3a3a3c; }
td small { margin-top: .18rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 140ms ease; }
tbody tr:hover { background: rgba(0, 113, 227, .025); }

/* Forms */
.form-card { width: 100%; max-width: 900px; }
.form-card > form > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
.form-card .mb-3 { margin-bottom: 0 !important; }
.form-label, label { display: block; margin-bottom: .42rem; color: #3a3a3c; font-size: .83rem; font-weight: 600; }
.form-control, .form-select,
input[type="email"], input[type="password"], input[type="text"], input[type="url"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="search"], input[type="file"],
select, textarea {
    width: 100%;
    min-height: 43px;
    padding: .67rem .78rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: rgba(255, 255, 255, .92);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .025);
    font: inherit;
    font-size: .93rem;
    -webkit-appearance: none;
    appearance: none;
}
select {
    padding-right: 2.2rem;
    background-image: linear-gradient(45deg, transparent 50%, #6e6e73 50%), linear-gradient(135deg, #6e6e73 50%, transparent 50%);
    background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
textarea { min-height: 122px; resize: vertical; }
input[type="file"] { padding: .5rem; color: var(--text-secondary); }
input[type="file"]::file-selector-button {
    margin-right: .75rem;
    padding: .48rem .75rem;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    background: #ededf0;
    font: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}
input::placeholder, textarea::placeholder { color: #a1a1a6; }
.form-control:hover, .form-select:hover, input:hover, select:hover, textarea:hover { border-color: rgba(0, 0, 0, .28); }
.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--blue);
    outline: 0;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, .13);
}
.form-check { display: flex; align-items: center; gap: .55rem; min-height: 43px; }
.form-check-input, input[type="checkbox"], input[type="radio"] {
    width: 19px;
    min-width: 19px;
    height: 19px;
    min-height: 19px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line-strong);
    accent-color: var(--blue);
    -webkit-appearance: auto;
    appearance: auto;
}
.form-check-label { margin: 0; }
.form-text { margin-top: .35rem; color: var(--text-secondary); font-size: .78rem; }
.invalid-feedback, .form-error-message, form li { color: var(--red); }
.form-card button { margin-top: 1.2rem; }
.member-form, .document-form { max-width: 1160px; }
.form-section { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(0, 2.3fr); gap: 2rem; }
.section-heading p { margin-bottom: 0; color: var(--text-secondary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-wide { grid-column: 1 / -1; }
.form-submit { display: flex; justify-content: flex-end; padding-top: .25rem; }
.form-divider { grid-column: 1 / -1; margin: .35rem 0; border: 0; border-top: 1px solid var(--line); }

/* Notices */
.alert, .notice { padding: .85rem 1rem; border: 1px solid rgba(36, 138, 61, .18); border-radius: 12px; color: #17682d; background: var(--green-soft); font-size: .91rem; }
.alert { margin-bottom: 1rem; }
.alert-error { border-color: rgba(215, 0, 21, .18); color: #a50012; background: var(--red-soft); }
.notice { margin: 0 0 1.25rem; border-color: rgba(198, 93, 0, .15); color: #784600; background: var(--orange-soft); }

/* Detail views */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.details { margin: 0; }
.details > div { display: grid; grid-template-columns: minmax(130px, .72fr) minmax(0, 1.28fr); gap: 1rem; padding: .72rem 0; border-bottom: 1px solid var(--line); }
.details > div:last-child { border-bottom: 0; }
.details dt { color: var(--text-secondary); font-weight: 550; }
.details dd { margin: 0; color: var(--text); }
.member-private { margin-top: 1rem; }
.private-notes { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.filter-bar {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) minmax(180px, 1fr) auto;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .74);
    box-shadow: var(--shadow-sm);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}
.filter-actions { display: flex; gap: .5rem; }
.assignment-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.assignment { display: flex; flex-direction: column; gap: .18rem; padding: .95rem; border: 1px solid rgba(0, 0, 0, .055); border-radius: 13px; background: var(--surface-muted); }
.assignment span { color: var(--text-secondary); font-size: .8rem; }
.assignment a { width: fit-content; margin-top: .45rem; font-size: .82rem; font-weight: 600; }
.contact-card, .lodge-card { display: flex; flex-direction: column; }
.contact-card > a:last-child { width: fit-content; margin-top: auto; }
.lodge-card form { margin-top: auto; }
.lodge-card .button { width: 100%; }
.role-list, .check-list { padding-left: 1.15rem; color: var(--text-secondary); line-height: 1.75; }
.role-list { min-height: 3.2rem; }
.contact-card .role-list { min-height: 0; }

/* Imports */
.import-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(270px, .75fr); gap: 1rem; }
.import-history { margin-top: 2rem; }
.import-history-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto; align-items: center; gap: 1rem; }
.import-counts { display: flex; gap: .75rem; flex-wrap: wrap; color: var(--text-secondary); font-size: .82rem; }
.import-settings { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(150px, .4fr) auto; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.import-settings .button { margin: 0; }
.import-actions { justify-content: flex-end; }
.import-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 1rem; }
.import-metrics .metric { min-height: 130px; }
.import-metrics .metric > strong { font-size: 2.2rem; }
.metric-success { border-color: rgba(36, 138, 61, .2); }
.metric-error { border-color: rgba(215, 0, 21, .18); }
.import-error, .import-warning { display: block; margin-top: .28rem; font-size: .79rem; }
.import-error { color: var(--red); font-weight: 650; }
.import-warning { color: var(--orange); }
.import-row-error { background: rgba(255, 240, 241, .62); }
.import-confirm { display: flex; align-items: flex-start; justify-content: flex-end; gap: .75rem; margin-top: 1rem; }
.import-confirm form { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }

/* Logo and documents */
.logo-settings { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 1.5rem; align-items: center; margin-bottom: 1.5rem; }
.lodge-logo-preview { display: grid; place-items: center; width: 140px; height: 140px; overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: #fff; box-shadow: var(--shadow-sm); }
.lodge-logo-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.lodge-logo-placeholder { color: var(--text-tertiary); font-size: 2.4rem; font-weight: 650; }
.document-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.document-card { display: flex; flex-direction: column; min-height: 220px; }
.document-card .actions { margin-top: auto; padding-top: 1rem; }
.document-meta { display: flex; gap: .65rem; align-items: center; margin-bottom: .8rem; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem 1rem; }
.legal-copy { padding: 1.2rem; border-radius: var(--radius); color: #3a3a3c; background: var(--surface-muted); font-size: .9rem; line-height: 1.6; }
.legal-copy h3 { margin-top: 1.1rem; }
.legal-copy h3:first-child { margin-top: 0; }
.preserve-lines { white-space: pre-line; }
.document-copy-field textarea { min-height: 420px; }

/* Access control and finance */
.role-reference, .delivery-history, .finance-schedule-section { margin-top: 1.5rem; }
.role-reference { display: grid; grid-template-columns: minmax(190px, .7fr) minmax(0, 2.3fr); gap: 2rem; }
.role-permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.role-permission-grid > div { padding: .9rem; border-radius: 13px; background: var(--surface-muted); }
.role-permission-grid p { margin: .28rem 0 0; color: var(--text-secondary); font-size: .82rem; }
.credential-card { max-width: 760px; }
.temporary-password { display: block; width: fit-content; margin: 1rem 0; padding: .8rem 1rem; font-size: 1.15rem; user-select: all; }
.section-tabs { display: flex; width: fit-content; gap: .25rem; margin: -1rem 0 1.5rem; padding: .25rem; border: 1px solid var(--line); border-radius: 980px; background: rgba(255,255,255,.75); }
.section-tabs a { padding: .48rem .85rem; border-radius: 980px; color: var(--text-secondary); font-size: .84rem; font-weight: 600; }
.section-tabs a:hover { color: var(--text); text-decoration: none; }
.section-tabs a.active { color: #fff; background: var(--text); }
.finance-metrics { margin-bottom: 1rem; }
.finance-metrics .metric { min-height: 132px; }
.finance-metrics .metric > strong { font-size: clamp(1.65rem, 3.5vw, 2.45rem); }
.finance-filters { grid-template-columns: minmax(180px, .7fr) minmax(180px, .7fr) auto; }
.finance-schedule-section + .finance-schedule-section { margin-top: 2.3rem; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.schedule-card { min-height: 280px; }
.schedule-total { display: block; margin: .5rem 0 1rem; font-size: 2.35rem; letter-spacing: -.05em; }
.share-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; margin-bottom: 1rem; }
.share-bar span { padding: .65rem .55rem; border-radius: 10px; font-size: .75rem; font-weight: 650; text-align: center; }
.share-lodge { color: #075aa8; background: var(--blue-soft); }
.share-province { color: #17682d; background: var(--green-soft); }
.share-obedience { color: #6e4a00; background: #fff7dc; }
.schedule-card .actions { margin-top: auto; }
.schedule-card form { margin: 0; }
.recipient-grid > div, .role-choice-grid > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem 1rem; }
.recipient-grid label { font-weight: 500; }

/* Destructive actions */
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; border-color: rgba(215, 0, 21, .18); background: rgba(255, 250, 250, .9); }
.danger-zone h2 { margin-bottom: .3rem; color: var(--red); }
.danger-zone p { margin: 0; color: var(--text-secondary); }
.delete-confirmation, .error-panel { width: 100%; max-width: 760px; }
.delete-confirmation form { margin-top: 1.25rem; }
.error-panel { padding: clamp(1.5rem, 5vw, 3rem); }
.error-panel p { color: var(--text-secondary); line-height: 1.65; }

/* Public pages */
body.public-shell {
    background: radial-gradient(circle at 14% 18%, rgba(0, 113, 227, .18), transparent 28rem), radial-gradient(circle at 90% 82%, rgba(90, 200, 250, .16), transparent 32rem), linear-gradient(145deg, #f5f5f7 0%, #eef4fb 50%, #f8f8fa 100%);
}
.public-shell .main-content { display: grid; min-height: 100vh; place-items: center; }
.login-panel { display: grid; width: min(1050px, 100%); grid-template-columns: minmax(0, 1.05fr) minmax(340px, .75fr); align-items: center; gap: clamp(2.5rem, 7vw, 6.5rem); }
.login-intro { color: var(--text); }
.login-intro h1 { max-width: 700px; font-size: clamp(3.2rem, 7vw, 6.4rem); }
.login-intro p { max-width: 620px; color: var(--text-secondary); font-size: clamp(1.05rem, 2vw, 1.35rem); line-height: 1.55; letter-spacing: -.02em; }
.login-form { display: flex; flex-direction: column; gap: .65rem; padding: clamp(1.5rem, 4vw, 2.2rem); border-color: rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .72); box-shadow: 0 20px 60px rgba(32, 52, 72, .12); -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px); }
.login-form h2 { margin-bottom: .5rem; font-size: 1.65rem; letter-spacing: -.04em; }
.login-form .button { width: 100%; margin-top: .65rem; }
.form-note { margin: .45rem 0 0; color: var(--text-secondary); font-size: .78rem; line-height: 1.5; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

/* Printable forms */
.print-only { display: none; }
.print-sheet { max-width: 1050px; margin: 0 auto 1rem; padding: 2rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-sm); }
.print-header { display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); text-align: center; }
.print-header-logo { width: 78px; height: 78px; object-fit: contain; }
.print-header-logo-small { width: 48px; height: 48px; }
.print-code { display: grid; justify-items: center; gap: .35rem; }
.print-title { margin: 0; font-size: 1.65rem; letter-spacing: -.035em; }
.print-section { margin-top: 1.4rem; }
.print-section-title { padding-bottom: .35rem; border-bottom: 2px solid var(--text); font-size: 1rem; letter-spacing: .02em; text-transform: uppercase; }
.print-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1.5rem; }
.print-field { min-height: 2.1rem; padding-bottom: .25rem; border-bottom: 1px solid #bbb; }
.print-field span { display: block; color: var(--text-secondary); font-size: .68rem; font-weight: 650; text-transform: uppercase; }
.print-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.5rem; }
.print-signature { min-height: 105px; padding: .7rem; border: 1px solid #aaa; font-size: .75rem; }
.print-footer { margin-top: 1.3rem; padding-top: .5rem; border-top: 1px solid #bbb; color: #666; font-size: .65rem; text-align: center; }

/* Responsive */
@media (max-width: 1100px) {
    .card-grid, .metric-grid, .assignment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .import-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    body.app-shell { display: block; }
    .sidebar { position: relative; height: auto; padding: 1rem; border-right: 0; border-bottom: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .035); }
    .main-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nav-heading { grid-column: 1 / -1; }
    .sidebar-footer { margin-top: 0; }
    .filter-bar, .form-section, .import-layout, .import-settings, .role-reference { grid-template-columns: 1fr; }
    .import-history-row { grid-template-columns: 1fr auto; }
    .login-panel { width: min(520px, 100%); grid-template-columns: 1fr; }
    .login-intro { text-align: center; }
    .login-intro h1, .login-intro p { margin-inline: auto; }
}

@media (max-width: 620px) {
    body { font-size: 14px; }
    .main-content { padding: 1.1rem; }
    h1 { font-size: clamp(2rem, 12vw, 3.1rem); }
    .page-header, .card-heading, .danger-zone { align-items: stretch; flex-direction: column; }
    .page-header .button, .page-header > .actions, .page-header > .actions .button, .danger-zone .button, .delete-confirmation .button { width: 100%; }
    .card-grid, .metric-grid, .assignment-grid, .detail-grid, .form-grid, .callout, .form-card > form > div, .import-history-row, .import-metrics, .document-grid, .check-grid, .print-fields, .print-signatures, .role-permission-grid, .recipient-grid > div, .role-choice-grid > div, .share-bar { grid-template-columns: 1fr; }
    .main-nav { grid-template-columns: 1fr; }
    .filter-actions, .filter-actions .button, .actions.import-actions, .actions.import-actions .button { width: 100%; }
    .filter-actions { flex-direction: column; }
    .details > div { grid-template-columns: 1fr; gap: .18rem; }
    .import-confirm { flex-direction: column; }
    .import-confirm form, .import-confirm .button { width: 100%; }
    .logo-settings { grid-template-columns: 1fr; }
    th, td { padding: .8rem; }
    .card, .metric, .table-wrap, .empty-state { border-radius: var(--radius); }
}

@media print {
    @page { size: A4; margin: 12mm; }
    body, body.app-shell, body.public-shell { display: block; color: #000; background: #fff; font-size: 9.5pt; }
    .sidebar, .page-header, .alert, .no-print, .button { display: none !important; }
    .main-content { max-width: none; margin: 0; padding: 0; }
    .print-only { display: block; }
    .print-sheet { max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; break-after: page; }
    .print-sheet:last-child { break-after: auto; }
    .print-section { break-inside: avoid; }
    .legal-copy { padding: .6rem; font-size: 7.7pt; line-height: 1.32; break-inside: auto; }
    .legal-copy p { margin-bottom: .45rem; }
    .print-footer { font-size: 6.5pt; }
    a { color: #000; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
