:root {
    --app-bg: #f5f7fb;
    --app-bg-strong: #eef3f8;
    --app-primary: #153e75;
    --app-primary-dark: #0f2d55;
    --app-success: #227a56;
    --app-accent: #c99a2e;
    --app-danger: #b42318;
    --app-text: #172033;
    --app-muted: #667085;
    --app-border: #d9e2ef;
    --app-border-strong: #bdc9d9;
    --app-card: #ffffff;
    --app-sidebar: #102f5a;
    --app-sidebar-soft: #173f73;
    --app-focus: rgba(201, 154, 46, 0.48);
    --surface-hover: #fbfcff;
    --shadow-sm: 0 8px 24px rgba(21, 62, 117, 0.08);
    --shadow-md: 0 20px 60px rgba(21, 62, 117, 0.12);
    --shadow-focus: 0 0 0 4px rgba(201, 154, 46, 0.18);
}

body {
    background: var(--app-bg);
    color: var(--app-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    margin: 0;
}

a,
button,
input,
select,
textarea,
summary {
    transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    box-shadow: var(--shadow-focus);
    outline: 3px solid var(--app-focus);
    outline-offset: 2px;
}

.skip-link {
    background: var(--app-primary);
    color: #fff;
    left: 16px;
    padding: 10px 14px;
    position: fixed;
    top: 12px;
    transform: translateY(-140%);
    z-index: 2000;
}

.skip-link:focus {
    transform: translateY(0);
}

.phase-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.phase-panel {
    width: min(100%, 720px);
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 32px;
}

.phase-kicker {
    color: var(--app-primary);
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.phase-panel h1 {
    margin: 10px 0 12px;
    font-size: clamp(1.75rem, 4vw, 2.4rem);
    line-height: 1.1;
}

.phase-panel p {
    color: var(--app-muted);
}

.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(21, 62, 117, 0.12), transparent 34rem),
        linear-gradient(135deg, rgba(21, 62, 117, 0.08), rgba(34, 122, 86, 0.06)),
        var(--app-bg);
}

.auth-panel {
    width: min(100%, 440px);
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 32px;
}

.auth-brand {
    align-items: center;
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
}

.auth-brand span:last-child {
    color: var(--app-text);
    font-weight: 800;
}

.auth-panel h1 {
    margin: 10px 0 10px;
    font-size: 2rem;
    line-height: 1.1;
}

.auth-panel p {
    color: var(--app-muted);
    margin-bottom: 24px;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-form label {
    color: var(--app-text);
    font-weight: 700;
    font-size: 0.92rem;
}

.auth-form-intro {
    margin: -2px 0 6px;
    color: #64748b;
    font-size: .94rem;
    line-height: 1.5;
}

.auth-secondary-link {
    display: block;
    margin-top: -4px;
    color: #475569;
    font-size: .9rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.auth-secondary-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.auth-form input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 13px 14px;
    font: inherit;
    color: var(--app-text);
    background: #fff;
}

.auth-form input:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 4px rgba(21, 62, 117, 0.12);
    outline: none;
}

.auth-form button {
    align-items: center;
    display: inline-flex;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
    border: 0;
    border-radius: 8px;
    background: var(--app-primary);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    min-height: 48px;
    padding: 14px 18px;
    touch-action: manipulation;
}

.auth-form button:hover {
    background: var(--app-primary-dark);
}

.alert {
    border-radius: 8px;
    margin: 16px 0;
    padding: 12px 14px;
    font-weight: 650;
}

.alert-danger {
    background: #fef3f2;
    border: 1px solid #fecdca;
    color: var(--app-danger);
}

.alert-success {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: var(--app-success);
}

.dashboard-panel {
    width: min(100%, 920px);
}

.top-row {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.logout-link {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-primary);
    font-weight: 800;
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 12px;
    text-decoration: none;
    touch-action: manipulation;
    white-space: nowrap;
}

.session-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 24px 0;
}

.session-grid article {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 16px;
}

.session-grid span {
    color: var(--app-muted);
    display: block;
    font-size: 0.86rem;
    margin-bottom: 8px;
}

.session-grid strong {
    overflow-wrap: anywhere;
}

.dashboard-panel h2 {
    font-size: 1rem;
    margin: 8px 0 12px;
}

.permission-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.permission-list span {
    background: #eef4ff;
    border: 1px solid #c7d7fe;
    border-radius: 999px;
    color: var(--app-primary);
    font-size: 0.84rem;
    font-weight: 700;
    padding: 6px 10px;
}

.phase-note {
    border-top: 1px solid var(--app-border);
    margin-top: 24px;
    padding-top: 18px;
}

.app-shell {
    background: var(--app-bg);
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100dvh;
}

.app-sidebar {
    background: linear-gradient(180deg, var(--app-sidebar), #0d284d);
    color: #fff;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: 20px;
    position: sticky;
    top: 0;
}

.brand-block {
    margin-bottom: 22px;
}

.brand-mark {
    align-items: center;
    color: #fff;
    display: flex;
    gap: 12px;
    min-height: 48px;
    text-decoration: none;
}

.brand-mark:hover {
    color: #fff;
}

.brand-symbol {
    align-items: center;
    background: #fff;
    border-radius: 8px;
    color: var(--app-primary);
    display: inline-flex;
    flex: 0 0 44px;
    font-weight: 900;
    height: 44px;
    justify-content: center;
    letter-spacing: 0;
    width: 44px;
}

.brand-mark strong,
.brand-mark small {
    display: block;
}

.brand-mark strong {
    font-size: 0.98rem;
    line-height: 1.2;
}

.brand-mark small {
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.82rem;
    margin-top: 2px;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.nav-item-link {
    align-items: center;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.78);
    display: flex;
    gap: 12px;
    min-height: 46px;
    padding: 10px 12px;
    text-decoration: none;
    touch-action: manipulation;
}

.nav-item-link:hover,
.nav-item-link.is-active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.nav-item-link.is-active {
    box-shadow: inset 3px 0 0 var(--app-accent);
}

.nav-item-link.is-disabled {
    color: rgba(255, 255, 255, 0.38);
    cursor: not-allowed;
}

.nav-item-link i {
    font-size: 1.08rem;
    width: 22px;
}

.sidebar-footer {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    margin-top: auto;
    padding: 14px;
}

.sidebar-footer span,
.sidebar-footer strong {
    display: block;
}

.sidebar-footer span {
    color: rgba(255, 255, 255, 0.66);
    font-size: 0.82rem;
}

.sidebar-footer strong {
    color: #fff;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.sidebar-backdrop {
    display: none;
}

.app-main {
    min-width: 0;
}

.app-topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--app-border);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 72px;
    padding: 12px 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.icon-button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-primary);
    display: inline-flex;
    flex: 0 0 44px;
    height: 44px;
    justify-content: center;
    text-decoration: none;
    touch-action: manipulation;
    width: 44px;
}

.icon-button:hover {
    background: #eef4ff;
    border-color: #c7d7fe;
    color: var(--app-primary-dark);
}

.sidebar-toggle {
    display: none;
}

.topbar-title {
    display: grid;
    margin-right: auto;
}

.topbar-title span,
.page-heading span,
.section-header span {
    color: var(--app-muted);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar-title strong {
    color: var(--app-text);
    font-size: 1rem;
}

.topbar-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

.user-chip {
    align-items: center;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 999px;
    display: flex;
    gap: 10px;
    min-height: 44px;
    padding: 5px 12px 5px 5px;
}

.user-chip span {
    align-items: center;
    background: #e6f4ef;
    border-radius: 999px;
    color: var(--app-success);
    display: inline-flex;
    font-weight: 900;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.user-chip strong {
    color: var(--app-text);
    font-size: 0.9rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content-shell {
    padding: 28px;
}

.page-heading {
    align-items: flex-end;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 22px;
}

.page-heading h1 {
    color: var(--app-text);
    font-size: clamp(1.8rem, 3vw, 2.45rem);
    line-height: 1.1;
    margin: 6px 0 8px;
}

.page-heading p {
    color: var(--app-muted);
    margin: 0;
    max-width: 760px;
}

.page-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.kpi-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
}

.kpi-card,
.panel-block {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.kpi-card {
    align-items: center;
    display: flex;
    gap: 14px;
    min-height: 132px;
    padding: 18px;
}

.kpi-icon {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    flex: 0 0 48px;
    height: 48px;
    justify-content: center;
    width: 48px;
}

.kpi-primary .kpi-icon {
    background: #e8f0ff;
    color: var(--app-primary);
}

.kpi-success .kpi-icon {
    background: #e6f4ef;
    color: var(--app-success);
}

.kpi-gold .kpi-icon {
    background: #fff6df;
    color: #8a5b00;
}

.kpi-danger .kpi-icon {
    background: #fef3f2;
    color: var(--app-danger);
}

.kpi-card span,
.kpi-card small {
    color: var(--app-muted);
    display: block;
}

.kpi-card strong {
    color: var(--app-text);
    display: block;
    font-size: 2rem;
    line-height: 1;
    margin: 4px 0;
}

.dashboard-grid,
.wide-grid {
    display: grid;
    gap: 16px;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
    margin-bottom: 16px;
}

.wide-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.panel-block {
    padding: 20px;
}

.section-header {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    color: var(--app-text);
    font-size: 1.1rem;
    margin: 4px 0 0;
}

.quick-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.empty-state {
    background: var(--app-bg-strong);
    border: 1px dashed var(--app-border-strong);
    border-radius: 8px;
    color: var(--app-muted);
    grid-column: 1 / -1;
    margin: 0;
    overflow-wrap: anywhere;
    padding: 16px;
}

.structure-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.structure-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.campaign-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    margin-bottom: 16px;
}

.form-grid-two {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-three {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid-two > div,
.form-grid-three > div {
    display: grid;
    gap: 8px;
}

.info-panel {
    background: var(--app-bg-strong);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-muted);
    display: grid;
    gap: 10px;
    padding: 16px;
}

.info-panel p {
    margin: 0;
}

.management-stack {
    display: grid;
    gap: 16px;
}

.stack-form {
    display: grid;
    gap: 12px;
}

.stack-form label,
.inline-edit-form label {
    color: var(--app-text);
    font-size: 0.9rem;
    font-weight: 800;
}

.stack-form input[type="text"],
.stack-form input[type="date"],
.stack-form input[type="number"],
.stack-form input[type="tel"],
.stack-form input[type="search"],
.stack-form select,
.stack-form textarea,
.inline-edit-form input[type="text"],
.inline-edit-form input[type="date"],
.inline-edit-form select {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-text);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

.stack-form textarea {
    min-height: 96px;
    resize: vertical;
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus,
.inline-edit-form input:focus,
.inline-edit-form select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 4px rgba(21, 62, 117, 0.12);
    outline: none;
}

.switch-row,
.compact-check {
    align-items: center;
    display: inline-flex;
    gap: 8px;
    min-height: 44px;
}

.switch-row input,
.compact-check input {
    accent-color: var(--app-primary);
    height: 18px;
    width: 18px;
}

.primary-button {
    align-items: center;
    background: var(--app-primary);
    border: 0;
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    gap: 10px;
    justify-content: center;
    min-height: 48px;
    padding: 12px 16px;
    position: relative;
    touch-action: manipulation;
}

.primary-button:hover {
    background: var(--app-primary-dark);
}

.primary-button.is-loading,
.secondary-button.is-loading {
    cursor: wait;
    opacity: 0.78;
    pointer-events: none;
}

.primary-button.is-loading i,
.secondary-button.is-loading i {
    animation: button-busy 720ms linear infinite;
}

.responsive-table {
    overflow-x: auto;
}

.data-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 900px;
    width: 100%;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--app-border);
    padding: 12px;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--app-muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.data-table td {
    color: var(--app-text);
    font-weight: 650;
}

.data-table tbody tr:hover {
    background: var(--surface-hover);
}

.state-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 800;
    padding: 5px 10px;
    white-space: nowrap;
}

.state-badge.is-active {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: var(--app-success);
}

.state-badge.is-inactive {
    background: #f2f4f7;
    border: 1px solid #d0d5dd;
    color: var(--app-muted);
}

.inline-edit-form {
    align-items: center;
    display: grid;
    gap: 8px;
    min-width: 420px;
}

.inline-edit-form.is-simple {
    grid-template-columns: minmax(180px, 1fr) minmax(120px, auto) 44px;
}

.inline-edit-form.is-composed {
    grid-template-columns: minmax(180px, 0.8fr) minmax(180px, 1fr) minmax(120px, auto) 44px;
}

.campaign-edit-form {
    grid-template-columns: minmax(180px, 1fr) 150px 150px minmax(160px, 0.8fr) minmax(110px, auto) 44px;
    min-width: 880px;
}

.icon-save-button {
    align-items: center;
    background: var(--app-success);
    border: 0;
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    height: 44px;
    justify-content: center;
    touch-action: manipulation;
    width: 44px;
}

.icon-save-button:hover {
    background: #1b6146;
}

.mini-action-form {
    margin-top: 8px;
}

.secondary-button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-primary);
    display: inline-flex;
    gap: 8px;
    min-height: 40px;
    padding: 8px 12px;
    position: relative;
    touch-action: manipulation;
}

.secondary-button:hover {
    background: #eef4ff;
    border-color: #c7d7fe;
}

@keyframes button-busy {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.people-form {
    margin-bottom: 4px;
}

.people-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
    margin-top: 16px;
}

.search-form {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: 90px minmax(220px, 1fr) auto;
    margin-bottom: 14px;
}

.search-form label {
    color: var(--app-text);
    font-weight: 800;
    min-height: 44px;
    padding-top: 10px;
}

.search-form input {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-text);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
}

.people-table {
    min-width: 760px;
}

.profile-panel {
    align-self: start;
}

.empty-profile {
    color: var(--app-muted);
    display: grid;
    justify-items: start;
    min-height: 220px;
    place-content: center;
}

.empty-profile i {
    color: var(--app-primary);
    font-size: 2rem;
    margin-bottom: 12px;
}

.empty-profile h2 {
    color: var(--app-text);
    font-size: 1.2rem;
}

.profile-meta {
    margin-bottom: 18px;
}

.profile-edit-form {
    border-top: 1px solid var(--app-border);
    margin-top: 18px;
    padding-top: 18px;
}

.history-block {
    border-top: 1px solid var(--app-border);
    display: grid;
    gap: 10px;
    margin-top: 20px;
    padding-top: 18px;
}

.history-block h3 {
    font-size: 1rem;
    margin: 0;
}

.study-entry-panel {
    margin-bottom: 16px;
}

.study-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
}

.teacher-grid {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
}

.teacher-grid > div:not(.teacher-divider) {
    display: grid;
    gap: 8px;
}

.teacher-divider {
    align-items: center;
    background: var(--app-bg-strong);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-muted);
    display: inline-flex;
    font-weight: 900;
    height: 44px;
    justify-content: center;
    text-transform: uppercase;
}

.form-note {
    align-items: flex-start;
    background: #eef4ff;
    border: 1px solid #c7d7fe;
    border-radius: 8px;
    color: var(--app-primary);
    display: flex;
    gap: 10px;
    padding: 12px;
}

.form-note i {
    font-size: 1.1rem;
    margin-top: 2px;
}

.study-side-panel {
    align-self: start;
}

.person-picker {
    border-top: 1px solid var(--app-border);
    display: grid;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
}

.person-picker a {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-text);
    display: grid;
    gap: 2px;
    min-height: 58px;
    padding: 10px 12px;
    text-decoration: none;
    touch-action: manipulation;
}

.person-picker a:hover,
.person-picker a.is-selected {
    background: #eef4ff;
    border-color: #c7d7fe;
}

.person-picker span {
    font-weight: 850;
}

.person-picker small,
.table-subtext {
    color: var(--app-muted);
    display: block;
    font-size: 0.82rem;
    font-weight: 650;
    margin-top: 2px;
}

.study-table {
    min-width: 920px;
}

.study-table a {
    color: var(--app-primary);
    font-weight: 850;
    text-decoration: none;
}

.kpi-date {
    font-size: 1.25rem;
}

.qr-filter-bar {
    margin-bottom: 16px;
}

.qr-filter-bar .search-form {
    margin-bottom: 0;
}

.qr-action-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.qr-code-pill {
    background: #101828;
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-size: 1.1rem;
    font-weight: 900;
    justify-content: center;
    letter-spacing: 0;
    min-width: 72px;
    padding: 7px 10px;
}

.qr-status-available {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: var(--app-success) !important;
}

.qr-status-assigned {
    background: #eef4ff;
    border: 1px solid #c7d7fe;
    color: var(--app-primary) !important;
}

.qr-status-lost,
.qr-status-replaced,
.qr-status-cancelled {
    background: #fef3f2;
    border: 1px solid #fecdca;
    color: var(--app-danger) !important;
}

.qr-table {
    min-width: 980px;
}

.qr-status-form {
    grid-template-columns: minmax(150px, 1fr) 44px;
    min-width: 220px;
}

.attendance-hero {
    align-items: center;
    background: linear-gradient(135deg, var(--app-primary), var(--app-success));
    color: #fff;
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.attendance-hero span,
.attendance-hero p {
    color: rgba(255, 255, 255, 0.78);
}

.attendance-hero h2 {
    color: #fff;
    font-size: clamp(1.35rem, 3vw, 2rem);
    margin: 4px 0;
}

.attendance-hero p {
    margin: 0;
}

.attendance-hero strong {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    line-height: 1;
}

.attendance-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    margin-bottom: 16px;
}

.attendance-scan-panel {
    border-color: #c7d7fe;
}

.qr-scan-input {
    font-size: clamp(1.5rem, 8vw, 3rem) !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
    min-height: 76px !important;
    text-align: center;
}

.attendance-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
}

.person-attendance-list,
.attendance-feed {
    display: grid;
    gap: 10px;
}

.person-attendance-item,
.attendance-feed article {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.person-attendance-item {
    grid-template-columns: minmax(0, 1fr) auto;
}

.person-attendance-item strong,
.attendance-feed strong {
    display: block;
    font-weight: 900;
}

.person-attendance-item span,
.attendance-feed span {
    color: var(--app-muted);
    display: block;
    font-size: 0.86rem;
    font-weight: 650;
    margin-top: 3px;
}

.attendance-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.attendance-actions form {
    margin: 0;
}

.attendance-feed article {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
}

.attendance-feed time {
    background: var(--app-bg-strong);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-primary);
    font-weight: 900;
    padding: 8px 10px;
}

.appeal-hero {
    align-items: center;
    background: linear-gradient(135deg, #153e75, #8a5b00);
    color: #fff;
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.appeal-hero span,
.appeal-hero p {
    color: rgba(255, 255, 255, 0.78);
}

.appeal-hero h2 {
    color: #fff;
    font-size: clamp(1.35rem, 3vw, 2rem);
    margin: 4px 0;
}

.appeal-hero p {
    margin: 0;
}

.appeal-hero strong {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    line-height: 1;
}

.appeal-action-grid,
.appeal-layout {
    display: grid;
    gap: 16px;
}

.appeal-action-grid {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    margin-bottom: 16px;
}

.appeal-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
}

.appeal-search-form {
    border-bottom: 1px solid var(--app-border);
    margin-bottom: 16px;
    padding-bottom: 16px;
}

.appeal-person-list,
.appeal-feed {
    display: grid;
    gap: 10px;
}

.appeal-person-item,
.appeal-feed article {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.appeal-person-item strong,
.appeal-feed strong {
    display: block;
    font-weight: 900;
}

.appeal-person-item span,
.appeal-feed span {
    color: var(--app-muted);
    display: block;
    font-size: 0.86rem;
    font-weight: 650;
    margin-top: 3px;
}

.appeal-inline-form {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(160px, 0.8fr) minmax(180px, 1fr) auto;
}

.appeal-inline-form input,
.appeal-inline-form select {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-text);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

.appeal-feed article {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
}

.appeal-feed time {
    background: #fff6df;
    border: 1px solid #f3d89b;
    border-radius: 8px;
    color: #8a5b00;
    font-weight: 900;
    padding: 8px 10px;
}

.baptism-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
    margin-bottom: 16px;
}

.baptism-person-list {
    border-top: 1px solid var(--app-border);
    display: grid;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
}

.baptism-person-list article {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 2px;
    padding: 12px;
}

.baptism-person-list article.is-complete {
    background: #ecfdf3;
    border-color: #abefc6;
}

.baptism-person-list strong {
    font-weight: 900;
}

.baptism-person-list span,
.baptism-person-list small {
    color: var(--app-muted);
    font-size: 0.84rem;
    font-weight: 650;
}

.baptism-table {
    min-width: 1120px;
}

.baptism-edit-form {
    grid-template-columns: 150px minmax(180px, 0.8fr) minmax(180px, 0.8fr) minmax(180px, 1fr) 44px;
    min-width: 780px;
}

.history-item {
    background: var(--app-bg-strong);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 3px;
    padding: 10px 12px;
}

.history-item span {
    color: var(--app-muted);
    font-size: 0.9rem;
}

.state-badge.status-pre_registered {
    background: #fff6df;
    border: 1px solid #fedf89;
    color: #8a5b00;
}

.state-badge.status-in_bible_studies {
    background: #eef4ff;
    border: 1px solid #c7d7fe;
    color: var(--app-primary);
}

.state-badge.status-baptized {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: var(--app-success);
}

.quick-action {
    align-items: center;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-text);
    display: flex;
    gap: 12px;
    justify-content: flex-start;
    min-height: 58px;
    padding: 12px 14px;
    text-align: left;
    text-decoration: none;
    touch-action: manipulation;
}

.quick-action:not(:disabled):hover {
    border-color: var(--app-primary);
    box-shadow: 0 10px 24px rgba(21, 62, 117, 0.08);
    transform: translateY(-1px);
}

.quick-action:disabled {
    color: var(--app-muted);
    cursor: not-allowed;
    opacity: 0.55;
}

.quick-action i {
    color: var(--app-primary);
    font-size: 1.1rem;
}

.scope-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.scope-list div {
    border-bottom: 1px solid var(--app-border);
    display: grid;
    gap: 4px;
    padding-bottom: 10px;
}

.scope-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.scope-list dt {
    color: var(--app-muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.scope-list dd {
    color: var(--app-text);
    font-weight: 800;
    margin: 0;
    overflow-wrap: anywhere;
}

.status-badge {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    border-radius: 999px;
    color: var(--app-success) !important;
    padding: 5px 10px;
}

.chart-placeholder {
    align-items: end;
    background:
        linear-gradient(var(--app-border) 1px, transparent 1px),
        linear-gradient(90deg, var(--app-border) 1px, transparent 1px),
        #fbfcff;
    background-size: 100% 54px, 72px 100%;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: flex;
    min-height: 260px;
    padding: 22px;
}

.chart-bars {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(7, minmax(18px, 1fr));
    height: 210px;
    width: 100%;
}

.chart-bars span {
    background: linear-gradient(180deg, var(--app-primary), var(--app-success));
    border-radius: 8px 8px 4px 4px;
    min-height: 28px;
}

.dashboard-context,
.live-status-bar {
    align-items: center;
    background: linear-gradient(135deg, var(--app-primary), #1a655d);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    color: #fff;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 18px 20px;
}

.dashboard-context span,
.dashboard-context small,
.live-status-bar span,
.live-status-bar small {
    color: rgba(255, 255, 255, 0.78);
    display: block;
}

.dashboard-context strong,
.live-status-bar strong {
    display: block;
    font-size: 1.25rem;
    line-height: 1.2;
    margin: 2px 0;
}

.secondary-link {
    align-items: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-weight: 800;
    gap: 8px;
    min-height: 44px;
    padding: 10px 14px;
    text-decoration: none;
    white-space: nowrap;
}

.secondary-link:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.dashboard-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-chart-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 16px 0;
}

.chart-card-wide {
    grid-column: 1 / -1;
}

.chart-canvas {
    min-height: 280px;
}

.chart-unavailable {
    align-items: center;
    background: var(--app-bg-strong);
    border: 1px dashed var(--app-border-strong);
    border-radius: 8px;
    color: var(--app-muted);
    display: flex;
    justify-content: center;
    padding: 18px;
}

.dashboard-detail-grid {
    margin-top: 16px;
}

.dashboard-worker-table {
    min-width: 760px;
}

.live-hero-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}

.live-hero-card {
    background: var(--app-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    color: #fff;
    min-height: 210px;
    padding: 24px;
}

.live-hero-card.accent {
    background: #1b6d61;
}

.live-hero-card span,
.live-hero-card small {
    color: rgba(255, 255, 255, 0.78);
    display: block;
}

.live-hero-card strong {
    display: block;
    font-size: clamp(3.25rem, 8vw, 6rem);
    letter-spacing: 0;
    line-height: 1;
    margin: 18px 0;
}

.live-dashboard-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.live-side-stack {
    display: grid;
    gap: 16px;
}

.live-feed {
    display: grid;
    gap: 10px;
}

.live-feed article {
    align-items: center;
    background: #fbfcff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    padding: 12px;
}

.compact-feed article {
    grid-template-columns: 56px minmax(0, 1fr);
}

.feed-time {
    color: var(--app-primary);
    font-variant-numeric: tabular-nums;
    font-weight: 900;
}

.live-feed strong,
.rank-item strong {
    color: var(--app-text);
    display: block;
}

.live-feed small {
    color: var(--app-muted);
    display: block;
    overflow-wrap: anywhere;
}

.method-pill {
    background: #eef4ff;
    border: 1px solid #c7d7fe;
    border-radius: 999px;
    color: var(--app-primary);
    font-size: 0.78rem;
    font-weight: 900;
    padding: 5px 9px;
    white-space: nowrap;
}

.rank-list {
    display: grid;
    gap: 12px;
}

.rank-item {
    display: grid;
    gap: 7px;
}

.rank-item div {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.rank-item div span {
    color: var(--app-muted);
    font-weight: 900;
}

.rank-item > span {
    background: linear-gradient(90deg, var(--app-primary), var(--app-success));
    border-radius: 999px;
    display: block;
    height: 8px;
}

.reports-hero {
    align-items: center;
    background: #fff;
    border: 1px solid var(--app-border);
    border-left: 6px solid var(--app-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 18px 20px;
}

.reports-hero span,
.reports-hero small {
    color: var(--app-muted);
    display: block;
}

.reports-hero strong {
    color: var(--app-text);
    display: block;
    font-size: 1.22rem;
    line-height: 1.2;
    margin: 3px 0;
}

.reports-export-note {
    align-items: center;
    background: #fff6df;
    border: 1px solid #fedf89;
    border-radius: 999px;
    color: #8a5b00 !important;
    display: inline-flex !important;
    flex: 0 0 auto;
    font-weight: 900;
    gap: 8px;
    line-height: 1.2;
    padding: 8px 12px;
    white-space: normal;
}

.reports-filter-panel {
    margin-bottom: 16px;
}

.reports-filter-form,
.reports-export-form {
    display: grid;
    gap: 12px;
}

.reports-date-row {
    align-items: end;
}

.reports-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

.reports-export-panel {
    margin-bottom: 16px;
}

.reports-export-form {
    align-items: end;
    grid-template-columns: minmax(180px, 260px) auto;
    max-width: 520px;
}

.reports-export-help {
    color: var(--app-muted);
    margin: 12px 0 0;
}

.report-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.report-results-panel {
    margin-top: 16px;
}

.reports-table {
    min-width: 1100px;
}

.audit-hero {
    align-items: center;
    background: linear-gradient(135deg, #102f5a, #164e63);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    color: #fff;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 18px 20px;
}

.audit-hero span,
.audit-hero small {
    color: rgba(255, 255, 255, 0.78);
    display: block;
}

.audit-hero strong {
    display: block;
    font-size: 1.25rem;
    line-height: 1.2;
    margin: 3px 0;
}

.audit-note {
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: #fff !important;
    display: inline-flex !important;
    flex: 0 0 auto;
    font-weight: 900;
    gap: 8px;
    padding: 8px 12px;
}

.audit-filter-panel {
    margin-bottom: 16px;
}

.audit-filter-form {
    display: grid;
    gap: 12px;
}

.audit-date-row {
    align-items: end;
}

.audit-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

.audit-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.audit-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    margin-top: 16px;
}

.audit-table {
    min-width: 1180px;
}

.audit-action-badge {
    background: #eef4ff;
    border: 1px solid #c7d7fe;
    border-radius: 999px;
    color: var(--app-primary);
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 900;
    padding: 5px 10px;
    white-space: nowrap;
}

.audit-details summary {
    border-radius: 8px;
    color: var(--app-primary);
    cursor: pointer;
    font-weight: 900;
    min-height: 40px;
    padding: 8px 0;
}

.audit-details div {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.audit-details pre {
    background: #0f172a;
    border-radius: 8px;
    color: #e5e7eb;
    font-size: 0.78rem;
    margin: 0;
    max-width: 520px;
    overflow-x: auto;
    padding: 12px;
    white-space: pre-wrap;
}

.audit-rank-list {
    display: grid;
    gap: 10px;
}

.audit-rank-list article {
    background: #fbfcff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

.audit-rank-list strong {
    color: var(--app-text);
}

.audit-rank-list span,
.audit-rank-list small {
    color: var(--app-muted);
}

.settings-hero {
    align-items: center;
    background: linear-gradient(135deg, var(--app-primary), #155e75);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    color: #fff;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 18px 20px;
}

.settings-hero span,
.settings-hero small {
    color: rgba(255, 255, 255, 0.78);
    display: block;
}

.settings-hero strong {
    display: block;
    font-size: 1.25rem;
    line-height: 1.2;
    margin: 3px 0;
}

.settings-note {
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: #fff !important;
    display: inline-flex !important;
    flex: 0 0 auto;
    font-weight: 900;
    gap: 8px;
    padding: 8px 12px;
}

.settings-panel {
    margin-bottom: 16px;
}

.settings-form small {
    color: var(--app-muted);
    display: block;
    margin-top: 6px;
}

.settings-rule-card {
    align-items: center;
    background: #fbfcff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 16px;
}

.settings-rule-card span {
    color: var(--app-primary);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.settings-rule-card h3 {
    color: var(--app-text);
    font-size: 1.05rem;
    margin: 4px 0;
}

.settings-rule-card p {
    color: var(--app-muted);
    margin: 0;
}

.toggle-row {
    align-items: center;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: inline-flex;
    flex: 0 0 auto;
    gap: 10px;
    min-height: 48px;
    padding: 10px 12px;
}

.toggle-row input {
    accent-color: var(--app-primary);
    height: 20px;
    width: 20px;
}

.toggle-row span {
    color: var(--app-text);
    font-weight: 900;
    text-transform: none;
}

.settings-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-summary-card {
    display: grid;
    gap: 6px;
}

.settings-summary-card span,
.settings-summary-card small {
    color: var(--app-muted);
}

.settings-summary-card strong {
    color: var(--app-text);
    overflow-wrap: anywhere;
}

.users-hero {
    align-items: center;
    background: linear-gradient(135deg, var(--app-primary), #1b6d61);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    color: #fff;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 18px 20px;
}

.users-hero span,
.users-hero small {
    color: rgba(255, 255, 255, 0.78);
    display: block;
}

.users-hero strong {
    display: block;
    font-size: 1.25rem;
    line-height: 1.2;
    margin: 3px 0;
}

.users-note {
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: #fff !important;
    display: inline-flex !important;
    flex: 0 0 auto;
    font-weight: 900;
    gap: 8px;
    padding: 8px 12px;
}

.users-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.users-panel {
    margin-bottom: 16px;
}

.form-inline-note {
    align-items: center;
    background: #fbfcff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    color: var(--app-muted);
    display: flex;
    gap: 10px;
    min-height: 48px;
    padding: 12px;
}

.users-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    margin-bottom: 16px;
}

.users-table {
    min-width: 1100px;
}

.inline-admin-details {
    margin-top: 10px;
}

.inline-admin-details summary {
    border-radius: 8px;
    color: var(--app-primary);
    cursor: pointer;
    font-weight: 900;
    min-height: 40px;
    padding: 8px 0;
}

.inline-admin-form {
    background: #fbfcff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
}

.compact-role-form {
    background: #fbfcff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px;
}

.role-list {
    display: grid;
    gap: 10px;
}

.role-list article {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 5px;
    padding: 12px;
}

.role-list strong {
    color: var(--app-text);
}

.role-list span {
    color: var(--app-muted);
}

.permission-matrix-panel {
    margin-top: 16px;
}

.permission-role-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission-role-card {
    background: #fbfcff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.permission-role-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.permission-role-header strong {
    color: var(--app-text);
}

.permission-role-header span {
    color: var(--app-muted);
    font-weight: 800;
}

.permission-checkbox-list {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.permission-checkbox-list label {
    align-items: center;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    min-height: 42px;
    padding: 8px 10px;
}

.permission-checkbox-list input {
    accent-color: var(--app-primary);
    flex: 0 0 auto;
    height: 18px;
    width: 18px;
}

.permission-checkbox-list span {
    color: var(--app-text);
    font-size: 0.88rem;
    font-weight: 750;
    overflow-wrap: anywhere;
}

@media (max-width: 720px) {
    .phase-panel,
    .auth-panel {
        padding: 24px;
    }

    .top-row {
        display: grid;
    }

    .session-grid {
        grid-template-columns: 1fr;
    }

    .logout-link {
        text-align: center;
    }
}

@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        box-shadow: 24px 0 60px rgba(16, 47, 90, 0.22);
        height: 100dvh;
        left: 0;
        max-width: 320px;
        position: fixed;
        top: 0;
        transform: translateX(-105%);
        transition: transform 220ms ease;
        width: min(84vw, 320px);
        z-index: 1000;
    }

    .app-shell.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        background: rgba(15, 23, 42, 0.42);
        display: none;
        inset: 0;
        position: fixed;
        z-index: 900;
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .dashboard-grid,
    .wide-grid,
    .structure-grid,
    .campaign-layout,
    .people-layout,
    .study-layout,
    .qr-action-grid,
    .attendance-grid,
    .attendance-layout,
    .appeal-action-grid,
    .appeal-layout,
    .baptism-layout,
    .dashboard-chart-grid,
    .live-dashboard-grid,
    .reports-hero,
    .audit-hero,
    .audit-layout,
    .settings-hero,
    .settings-grid,
    .users-hero,
    .users-layout,
    .permission-role-grid {
        grid-template-columns: 1fr;
    }

    .reports-hero,
    .audit-hero,
    .settings-hero,
    .users-hero {
        align-items: flex-start;
        display: grid;
    }

    .settings-rule-card {
        align-items: flex-start;
        display: grid;
    }
}

@media (max-width: 880px) {
    .kpi-grid,
    .structure-summary,
    .dashboard-kpi-grid,
    .live-hero-grid,
    .report-kpi-grid,
    .audit-kpi-grid,
    .users-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-heading {
        align-items: flex-start;
        display: grid;
    }

    .page-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 620px) {
    .app-topbar,
    .content-shell {
        padding-left: 16px;
        padding-right: 16px;
    }

    .topbar-title {
        display: none;
    }

    .user-chip strong {
        display: none;
    }

    .kpi-grid,
    .structure-summary,
    .dashboard-kpi-grid,
    .live-hero-grid,
    .report-kpi-grid,
    .audit-kpi-grid,
    .users-kpi-grid,
    .quick-actions,
    .form-grid-two,
    .form-grid-three,
    .teacher-grid,
    .search-form {
        grid-template-columns: 1fr;
    }

    .teacher-divider {
        height: 36px;
    }

    .search-form label {
        min-height: auto;
        padding-top: 0;
    }

    .panel-block,
    .kpi-card {
        padding: 16px;
    }

    .chart-placeholder {
        min-height: 220px;
    }

    .dashboard-context,
    .live-status-bar {
        align-items: flex-start;
        display: grid;
    }

    .reports-actions {
        align-items: stretch;
        display: grid;
    }

    .reports-export-form {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .audit-actions {
        align-items: stretch;
        display: grid;
    }

    .page-actions,
    .topbar-actions {
        align-items: stretch;
    }

    .page-actions .primary-button,
    .page-actions .secondary-button,
    .reports-actions .primary-button,
    .reports-actions .secondary-button,
    .audit-actions .primary-button,
    .audit-actions .secondary-button {
        width: 100%;
    }

    .reports-export-note,
    .audit-note,
    .users-note {
        border-radius: 8px;
        width: 100%;
    }

    .responsive-table {
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .permission-checkbox-list {
        grid-template-columns: 1fr;
    }

    .attendance-hero,
    .appeal-hero,
    .person-attendance-item,
    .attendance-feed article,
    .appeal-feed article,
    .live-feed article,
    .compact-feed article {
        grid-template-columns: 1fr;
    }

    .attendance-hero,
    .appeal-hero {
        align-items: flex-start;
        display: grid;
    }

    .appeal-inline-form {
        grid-template-columns: 1fr;
    }

    .attendance-actions {
        justify-content: stretch;
    }

    .attendance-actions form,
    .attendance-actions button {
        width: 100%;
    }
}

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

/* Phase 21: sober Flowly-inspired system layer */
:root {
    --app-bg: #f3f7fb;
    --app-bg-strong: #eaf2fb;
    --app-primary: #0877e8;
    --app-primary-dark: #075fb8;
    --app-success: #1f8a5b;
    --app-accent: #8a6d1d;
    --app-danger: #b42318;
    --app-text: #161b26;
    --app-muted: #667085;
    --app-border: #e4e9f1;
    --app-border-strong: #cfd8e6;
    --app-card: #ffffff;
    --app-sidebar: #ffffff;
    --app-sidebar-soft: #f5f9fd;
    --app-focus: rgba(8, 119, 232, 0.38);
    --surface-hover: #f8fbff;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 16px 40px rgba(16, 24, 40, 0.08);
    --shadow-focus: 0 0 0 4px rgba(8, 119, 232, 0.14);
}

body {
    background:
        linear-gradient(180deg, rgba(213, 232, 249, 0.6), rgba(243, 247, 251, 0) 320px),
        var(--app-bg);
    color: var(--app-text);
}

.app-shell {
    background: transparent;
    grid-template-columns: 260px minmax(0, 1fr);
}

.app-sidebar {
    background: rgba(255, 255, 255, 0.9);
    border-right: 1px solid var(--app-border);
    box-shadow: none;
    color: var(--app-text);
    padding: 26px 18px;
}

.brand-block {
    margin-bottom: 28px;
}

.brand-mark,
.brand-mark:hover {
    color: var(--app-text);
}

.brand-symbol {
    background: #ecf5ff;
    color: var(--app-primary);
}

.brand-mark small,
.sidebar-footer span,
.topbar-title span,
.page-heading span,
.section-header span {
    color: var(--app-muted);
    text-transform: none;
}

.sidebar-nav {
    gap: 6px;
}

.nav-item-link {
    background: transparent;
    border: 0;
    color: #8a94a6;
    font-weight: 650;
    min-height: 46px;
    padding: 11px 12px;
}

.nav-item-link i {
    color: currentColor;
}

.nav-item-link:hover {
    background: #f2f7fd;
    color: var(--app-text);
    transform: none;
}

.nav-item-link.is-active {
    background: #eef6ff;
    box-shadow: inset 4px 0 0 var(--app-primary);
    color: var(--app-text);
}

.sidebar-footer {
    background: #f7fafd;
    border: 1px solid var(--app-border);
    color: var(--app-muted);
}

.sidebar-footer strong {
    color: var(--app-text);
}

.app-topbar {
    background: rgba(243, 247, 251, 0.86);
    backdrop-filter: blur(14px);
    border-bottom: 0;
    min-height: 70px;
    padding: 16px 32px 8px;
}

.topbar-title strong {
    font-weight: 700;
}

.user-chip,
.icon-button {
    border-color: transparent;
    box-shadow: var(--shadow-sm);
}

.user-chip span {
    background: #eef6ff;
    color: var(--app-primary);
}

.content-shell {
    padding: 18px 32px 36px;
}

.page-heading {
    align-items: center;
    margin-bottom: 18px;
}

.page-heading h1 {
    font-size: clamp(1.9rem, 3vw, 2.65rem);
    font-weight: 720;
    letter-spacing: 0;
    margin: 4px 0 0;
}

.page-heading p,
.topbar-title span,
.section-header span,
.kpi-card small,
.reports-export-help,
.form-note {
    display: none;
}

.page-actions {
    gap: 8px;
}

.panel-block,
.kpi-card,
.live-hero-card,
.settings-summary-card,
.permission-role-card,
.role-list article,
.empty-profile {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.panel-block {
    padding: 20px;
}

.panel-block:hover,
.kpi-card:hover {
    box-shadow: var(--shadow-sm);
}

.section-header {
    align-items: center;
    margin-bottom: 14px;
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 720;
    margin: 0;
}

.kpi-grid {
    gap: 12px;
    margin-bottom: 16px;
}

.kpi-card {
    align-items: center;
    display: flex;
    gap: 12px;
    min-height: 100px;
    padding: 18px;
}

.kpi-icon {
    background: #eef6ff;
    border: 0;
    color: var(--app-primary);
    height: 44px;
    width: 44px;
}

.kpi-card span {
    color: var(--app-muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.kpi-card strong {
    color: var(--app-text);
    font-size: 1.7rem;
    font-weight: 760;
    line-height: 1.1;
}

.kpi-success .kpi-icon,
.state-badge.is-active {
    background: #ecfdf3;
    color: var(--app-success);
}

.kpi-gold .kpi-icon {
    background: #fffaeb;
    color: var(--app-accent);
}

.kpi-danger .kpi-icon,
.state-badge.is-inactive {
    background: #fef3f2;
    color: var(--app-danger);
}

.primary-button,
.secondary-button,
.icon-save-button,
.auth-form button {
    border-radius: 10px;
    box-shadow: none;
    font-weight: 700;
    text-decoration: none;
}

.primary-button {
    background: var(--app-primary);
}

.primary-button:hover {
    background: var(--app-primary-dark);
}

.secondary-button {
    background: #fff;
    border-color: var(--app-border);
    color: var(--app-text);
}

.secondary-button:hover {
    background: #f6faff;
    border-color: #cfe4fb;
    color: var(--app-primary-dark);
}

.stack-form,
.reports-filter-form,
.reports-export-form,
.audit-filter-form {
    gap: 14px;
}

.stack-form label,
.inline-edit-form label,
.search-form label {
    color: #344054;
    font-size: 0.86rem;
    font-weight: 650;
}

.stack-form input[type="text"],
.stack-form input[type="date"],
.stack-form input[type="number"],
.stack-form input[type="tel"],
.stack-form input[type="search"],
.stack-form input[type="email"],
.stack-form input[type="password"],
.stack-form input[type="time"],
.stack-form select,
.stack-form textarea,
.inline-edit-form input[type="text"],
.inline-edit-form input[type="date"],
.inline-edit-form select,
.search-form input,
.search-form select,
.reports-filter-form input,
.reports-filter-form select,
.reports-export-form select,
.audit-filter-form input,
.audit-filter-form select {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    min-height: 44px;
}

.data-table {
    min-width: 820px;
}

.data-table th {
    background: #f7fafd;
    border-bottom: 1px solid var(--app-border);
    color: #667085;
    font-size: 0.74rem;
    letter-spacing: 0;
    text-transform: none;
}

.data-table td {
    border-bottom: 1px solid #edf1f7;
    font-weight: 500;
}

.data-table tbody tr:hover {
    background: #f9fcff;
}

.state-badge,
.status-badge,
.qr-code-pill {
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.reports-hero,
.audit-hero,
.settings-hero,
.users-hero,
.attendance-hero,
.appeal-hero {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--app-text);
    margin: 0 0 14px;
    padding: 0;
}

.reports-hero strong,
.audit-hero strong,
.settings-hero strong,
.users-hero strong {
    color: var(--app-text);
    font-size: 1.05rem;
}

.reports-hero small,
.audit-hero small,
.settings-hero small,
.users-hero small,
.audit-note,
.settings-note,
.users-note,
.reports-export-note,
.info-panel {
    display: none !important;
}

.dashboard-chart-grid,
.dashboard-grid,
.wide-grid,
.users-layout,
.audit-layout,
.settings-grid,
.qr-action-grid,
.campaign-layout,
.structure-grid {
    gap: 16px;
}

.users-layout,
.audit-layout {
    grid-template-columns: minmax(0, 1fr);
}

.role-list {
    max-height: 520px;
    overflow: auto;
}

.permission-role-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.permission-checkbox-list {
    max-height: 300px;
    overflow: auto;
}

.inline-admin-details summary {
    color: var(--app-primary);
    padding: 6px 0;
}

.inline-admin-form,
.compact-role-form,
.compact-role-form,
.permission-role-card {
    background: #fff;
}

.auth-shell {
    background:
        linear-gradient(160deg, rgba(8, 119, 232, 0.12), rgba(243, 247, 251, 0.2)),
        var(--app-bg);
}

.auth-panel {
    border-radius: 18px;
    box-shadow: var(--shadow-md);
}

.panel-modal-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.ux-modal-panel {
    display: none;
}

.ux-modal-panel.is-open {
    display: block;
    inset: 50% auto auto 50%;
    max-height: min(86dvh, 780px);
    max-width: min(92vw, 760px);
    overflow: auto;
    position: fixed;
    transform: translate(-50%, -50%);
    width: 100%;
    z-index: 1200;
}

.ux-modal-panel.is-open.panel-block,
.ux-modal-panel.is-open article,
.ux-modal-panel.is-open section {
    box-shadow: 0 24px 80px rgba(16, 24, 40, 0.18);
}

.panel-modal-backdrop {
    background: rgba(15, 23, 42, 0.42);
    border: 0;
    inset: 0;
    position: fixed;
    z-index: 1100;
}

.panel-modal-open {
    overflow: hidden;
}

.modal-close-row {
    display: flex;
    justify-content: flex-end;
    margin: -4px -4px 8px 0;
}

.modal-close-row .icon-button {
    box-shadow: none;
}

.admin-action-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.admin-action-row .secondary-button,
.admin-action-row .primary-button {
    min-height: 42px;
}

.settings-grid,
.structure-grid,
.campaign-layout,
.qr-action-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.auxiliary-panel,
.settings-grid,
.dashboard-grid > .panel-block:nth-child(2),
.dashboard-chart-grid .chart-card:nth-of-type(n+3) {
    display: none;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
}

.dashboard-chart-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.dashboard-detail-grid {
    grid-template-columns: minmax(0, 1fr);
}

.quick-actions {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.quick-action {
    background: #fff;
    border: 1px solid var(--app-border);
    box-shadow: none;
    color: var(--app-text);
    min-height: 70px;
}

.quick-action i {
    background: #eef6ff;
    border-radius: 10px;
    color: var(--app-primary);
    display: inline-flex;
    height: 36px;
    width: 36px;
    align-items: center;
    justify-content: center;
}

@media (max-width: 1080px) {
    .app-sidebar {
        background: #fff;
    }
}

@media (max-width: 720px) {
    .app-topbar,
    .content-shell {
        padding-left: 16px;
        padding-right: 16px;
    }

    .page-heading {
        align-items: flex-start;
        display: grid;
    }

    .page-actions,
    .admin-action-row,
    .panel-modal-actions {
        align-items: stretch;
        display: grid;
        width: 100%;
    }

    .page-actions .primary-button,
    .page-actions .secondary-button,
    .admin-action-row .primary-button,
    .admin-action-row .secondary-button,
    .panel-modal-actions .primary-button,
    .panel-modal-actions .secondary-button {
        width: 100%;
    }

    .ux-modal-panel.is-open {
        inset: auto 0 0;
        max-height: 92dvh;
        max-width: none;
        transform: none;
        width: 100%;
    }
}

/* Phase 22: mobile UX, toasts and profile sheet */
.toast-stack {
    display: grid;
    gap: 10px;
    position: fixed;
    right: 18px;
    top: 18px;
    width: min(420px, calc(100vw - 32px));
    z-index: 1500;
}

.app-toast {
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--app-border);
    border-left: 4px solid var(--app-success);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(16, 24, 40, 0.16);
    color: var(--app-text);
    display: grid;
    gap: 10px;
    grid-template-columns: 22px minmax(0, 1fr) 32px;
    padding: 14px;
    transition: opacity 180ms ease, transform 180ms ease;
}

.app-toast.is-error {
    border-left-color: var(--app-danger);
}

.app-toast > i {
    color: var(--app-success);
    font-size: 1.1rem;
    margin-top: 2px;
}

.app-toast.is-error > i {
    color: var(--app-danger);
}

.app-toast span {
    font-weight: 650;
    line-height: 1.35;
}

.app-toast button {
    align-items: center;
    background: #f7fafd;
    border: 0;
    border-radius: 8px;
    color: var(--app-muted);
    display: inline-flex;
    height: 32px;
    justify-content: center;
    width: 32px;
}

.app-toast.is-hiding {
    opacity: 0;
    transform: translateY(-8px);
}

.person-profile-modal {
    display: none;
}

.person-profile-modal.is-open {
    display: block;
    left: 50%;
    max-height: min(88dvh, 820px);
    max-width: min(94vw, 920px);
    overflow: auto;
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    z-index: 1200;
}

.person-profile-modal.is-open::before {
    background: rgba(15, 23, 42, 0.44);
    content: "";
    inset: -100vmax;
    position: fixed;
    z-index: -1;
}

.profile-summary {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 18px;
}

.profile-summary div {
    background: #f7fafd;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    padding: 12px;
}

.profile-summary dt {
    color: var(--app-muted);
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-summary dd {
    color: var(--app-text);
    font-weight: 720;
    margin: 0;
    overflow-wrap: anywhere;
}

.profile-edit-details {
    border-top: 1px solid var(--app-border);
    padding-top: 12px;
}

.profile-edit-details summary {
    color: var(--app-primary);
    cursor: pointer;
    font-weight: 800;
    list-style: none;
    min-height: 44px;
    padding: 10px 0;
}

.profile-edit-details summary::-webkit-details-marker {
    display: none;
}

.profile-edit-form {
    margin-top: 8px;
}

@media (max-width: 760px) {
    body {
        background: var(--app-bg);
    }

    .toast-stack {
        left: 12px;
        right: 12px;
        top: 12px;
        width: auto;
    }

    .app-toast {
        border-radius: 12px;
        grid-template-columns: 20px minmax(0, 1fr) 30px;
        padding: 12px;
    }

    .app-shell {
        min-width: 0;
    }

    .app-topbar {
        gap: 10px;
        min-height: 60px;
        padding-bottom: 10px;
        padding-top: 10px;
    }

    .content-shell {
        padding-top: 12px;
    }

    .page-heading h1 {
        font-size: 1.65rem;
    }

    .kpi-grid,
    .dashboard-kpi-grid,
    .report-kpi-grid,
    .audit-kpi-grid,
    .users-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-card {
        align-items: flex-start;
        min-height: 92px;
        padding: 14px;
    }

    .kpi-icon {
        height: 36px;
        width: 36px;
    }

    .kpi-card strong {
        font-size: 1.35rem;
    }

    .panel-block {
        border-radius: 14px;
        padding: 16px;
    }

    .form-grid-two,
    .form-grid-three,
    .teacher-grid,
    .reports-date-row,
    .campaign-edit-form,
    .inline-edit-form,
    .inline-edit-form.is-simple,
    .inline-edit-form.is-composed {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .stack-form input,
    .stack-form select,
    .stack-form textarea,
    .search-form input,
    .search-form select {
        font-size: 16px;
    }

    .primary-button,
    .secondary-button,
    .icon-save-button {
        min-height: 46px;
    }

    .responsive-table {
        margin-left: 0;
        margin-right: 0;
        overflow: visible;
        padding: 0;
    }

    .data-table {
        min-width: 0;
    }

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tbody {
        display: grid;
        gap: 10px;
    }

    .data-table tr {
        background: #fff;
        border: 1px solid var(--app-border);
        border-radius: 14px;
        box-shadow: var(--shadow-sm);
        padding: 8px 12px;
    }

    .data-table td {
        align-items: flex-start;
        border-bottom: 1px solid #edf1f7;
        display: flex;
        gap: 12px;
        justify-content: space-between;
        padding: 10px 0;
        text-align: right;
    }

    .data-table td:last-child {
        border-bottom: 0;
    }

    .data-table td::before {
        color: var(--app-muted);
        content: attr(data-label);
        flex: 0 0 38%;
        font-size: 0.78rem;
        font-weight: 750;
        text-align: left;
    }

    .data-table td > * {
        max-width: 62%;
    }

    .data-table td .secondary-button,
    .data-table td .primary-button,
    .data-table td form {
        max-width: none;
        width: 100%;
    }

    .people-layout,
    .study-layout,
    .attendance-layout,
    .appeal-layout,
    .baptism-layout,
    .dashboard-chart-grid,
    .dashboard-detail-grid {
        grid-template-columns: 1fr;
    }

    .person-profile-modal.is-open,
    .ux-modal-panel.is-open {
        border-radius: 18px 18px 0 0;
        bottom: 0;
        left: 0;
        max-height: 90dvh;
        max-width: none;
        right: 0;
        top: auto;
        transform: none;
        width: 100%;
    }

    .profile-summary {
        grid-template-columns: 1fr 1fr;
    }

    .profile-edit-details[open] .profile-edit-form {
        display: grid;
    }
}

/* Brand and UX cleanup */
.brand-logo,
.topbar-logo,
.auth-logo {
    aspect-ratio: 1 / 1;
    display: block;
    flex: 0 0 auto;
    object-fit: contain;
}

.brand-logo {
    border-radius: 12px;
    height: 44px;
    width: 44px;
}

.topbar-logo {
    border-radius: 10px;
    height: 34px;
    width: 34px;
}

.app-topbar-brand {
    align-items: center;
    display: flex !important;
    gap: 10px;
    min-width: 0;
}

.app-topbar-brand strong {
    color: var(--app-text);
    font-size: 0.95rem;
    max-width: min(32vw, 280px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark strong {
    overflow-wrap: anywhere;
}

.page-heading span,
.page-heading p {
    display: none !important;
}

.page-heading {
    margin-bottom: 16px !important;
}

.page-heading h1 {
    font-size: clamp(1.72rem, 3vw, 2.28rem) !important;
    margin: 0 !important;
}

.operational-hero {
    border-left: 0 !important;
    gap: 14px !important;
    overflow: hidden;
    padding: 18px 22px !important;
    position: relative;
}

.operational-hero::before {
    background: var(--app-primary);
    border-radius: 999px;
    bottom: 18px;
    content: "";
    left: 14px;
    position: absolute;
    top: 18px;
    width: 4px;
}

.operational-hero > div {
    min-width: 0;
    padding-left: 14px;
}

.operational-hero h2,
.operational-hero p {
    overflow-wrap: anywhere;
}

.person-attendance-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.person-attendance-item {
    align-items: center;
    display: grid !important;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.attendance-actions {
    display: flex;
    justify-content: flex-end;
}

.attendance-actions form,
.attendance-actions .secondary-button {
    width: 100%;
}

.auth-shell {
    background:
        radial-gradient(circle at 20% 12%, rgba(8, 119, 232, 0.14), transparent 26rem),
        linear-gradient(180deg, #f6f9fc, #edf4fb);
}

.auth-panel {
    border-radius: 22px !important;
    padding: 34px !important;
}

.auth-brand {
    display: grid;
    gap: 12px;
    justify-items: center;
    margin-bottom: 22px;
    text-align: center;
}

.auth-logo {
    border-radius: 18px;
    height: 72px;
    width: 72px;
}

.auth-brand span:last-child {
    color: var(--app-text);
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.25;
}

.auth-panel h1 {
    font-size: 1.8rem !important;
    margin: 0 0 20px !important;
    text-align: center;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 54px !important;
}

.password-toggle {
    align-items: center;
    background: transparent !important;
    border: 0 !important;
    border-radius: 10px !important;
    color: var(--app-primary) !important;
    cursor: pointer;
    display: inline-flex !important;
    height: 42px !important;
    justify-content: center;
    margin: 0 !important;
    min-height: 42px !important;
    padding: 0 !important;
    position: absolute !important;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 42px !important;
}

.password-toggle:hover {
    background: #eef6ff !important;
}

@media (max-width: 760px) {
    .app-topbar-brand strong {
        display: none;
    }

    .operational-hero {
        padding: 16px 18px !important;
    }

    .operational-hero::before {
        bottom: 16px;
        left: 10px;
        top: 16px;
    }

    .operational-hero > div {
        padding-left: 10px;
    }

    .person-attendance-item {
        grid-template-columns: 1fr;
    }

    .attendance-actions {
        justify-content: stretch;
    }

    .auth-shell {
        padding: 16px;
    }

    .auth-panel {
        padding: 26px 20px !important;
    }
}

/* Friendly person capture */
.friendly-person-form {
    gap: 16px;
}

.friendly-person-form label {
    color: #344054;
    font-size: 0.9rem;
    font-weight: 800;
}

.inline-check {
    align-items: center;
    background: #f8fbff;
    border: 1px solid #dce8f5;
    border-radius: 12px;
    color: #344054;
    cursor: pointer;
    display: flex;
    gap: 10px;
    min-height: 48px;
    padding: 10px 12px;
}

.inline-check input {
    accent-color: var(--app-primary);
    flex: 0 0 auto;
    height: 18px;
    width: 18px;
}

.inline-check span {
    font-weight: 800;
}

[data-location-fields].is-disabled {
    opacity: 0.55;
}

[data-location-fields].is-disabled select {
    cursor: not-allowed;
}

.js-enabled [data-table-filter] button[type="submit"] {
    display: none;
}

@media (max-width: 430px) {
    .kpi-grid,
    .dashboard-kpi-grid,
    .report-kpi-grid,
    .audit-kpi-grid,
    .users-kpi-grid,
    .profile-summary {
        grid-template-columns: 1fr;
    }

    .data-table td {
        display: grid;
        gap: 4px;
        text-align: left;
    }

    .data-table td::before,
    .data-table td > * {
        max-width: none;
    }
}

/* Phase 22 correction pass: real mobile layout fixes */
.people-layout {
    grid-template-columns: 1fr !important;
}

.people-layout > .panel-block {
    min-width: 0;
    width: 100%;
}

.people-table {
    min-width: 0;
    table-layout: fixed;
    width: 100%;
}

.people-table th,
.people-table td {
    overflow-wrap: anywhere;
}

.people-table th:nth-child(1),
.people-table td:nth-child(1) {
    width: 28%;
}

.people-table th:nth-child(2),
.people-table td:nth-child(2) {
    width: 15%;
}

.people-table th:nth-child(3),
.people-table td:nth-child(3) {
    width: 16%;
}

.people-table th:nth-child(4),
.people-table td:nth-child(4) {
    width: 16%;
}

.people-table th:nth-child(5),
.people-table td:nth-child(5) {
    width: 15%;
}

.people-table th:nth-child(6),
.people-table td:nth-child(6) {
    width: 10%;
}

.person-profile-modal.is-open {
    border-radius: 18px;
    padding: 22px;
}

.person-profile-modal .section-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--app-border);
    padding-bottom: 14px;
}

.person-profile-modal .section-header h2 {
    font-size: 1.35rem;
}

.history-block {
    border-top: 1px solid var(--app-border);
    margin-top: 16px;
    padding-top: 16px;
}

.history-block h3 {
    font-size: 1rem;
    font-weight: 750;
    margin: 0 0 10px;
}

.history-item {
    background: #f7fafd;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    display: grid;
    gap: 2px;
    margin-bottom: 8px;
    padding: 10px 12px;
}

.history-item span {
    color: var(--app-muted);
    font-size: 0.86rem;
}

@media (max-width: 900px) {
    .kpi-grid,
    .dashboard-kpi-grid,
    .report-kpi-grid,
    .audit-kpi-grid,
    .users-kpi-grid,
    .structure-summary {
        grid-template-columns: 1fr !important;
    }

    .kpi-card {
        align-items: center;
        display: grid;
        gap: 12px;
        grid-template-columns: 44px minmax(0, 1fr);
        min-height: auto;
        overflow: hidden;
    }

    .kpi-card span,
    .kpi-card strong {
        overflow-wrap: anywhere;
    }

    .kpi-card strong {
        font-size: 1.6rem;
    }

    .search-form {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .search-form label {
        min-height: auto;
        padding-top: 0;
    }
}

@media (max-width: 760px) {
    .topbar-actions {
        margin-left: auto;
    }

    .user-chip {
        border-radius: 14px;
        padding: 5px;
    }

    .user-chip span {
        height: 40px;
        width: 40px;
    }

    .people-table {
        table-layout: auto;
    }

    .people-table th,
    .people-table td {
        width: auto !important;
    }

    .data-table td {
        align-items: stretch;
    }

    .data-table td::before {
        flex: initial;
    }

    .data-table td > * {
        max-width: none;
    }

    .person-profile-modal.is-open {
        border-radius: 20px 20px 0 0;
        padding: 18px;
    }

    .person-profile-modal .section-header {
        display: grid;
        gap: 10px;
    }

    .profile-summary {
        grid-template-columns: 1fr;
    }

    .profile-edit-details summary {
        background: #eef6ff;
        border-radius: 12px;
        color: var(--app-primary-dark);
        padding: 12px 14px;
    }
}

/* Emergency UX correction: width, mobile and person profile */
.app-main,
.content-shell,
.people-layout,
.people-layout > article {
    max-width: none !important;
    min-width: 0 !important;
    width: 100% !important;
}

.people-layout {
    display: block !important;
}

.people-layout > article.panel-block {
    margin-left: 0;
    margin-right: 0;
}

.people-layout > .profile-panel:not(.is-open) {
    display: none !important;
}

.people-layout .responsive-table {
    width: 100%;
}

.people-table {
    min-width: 0 !important;
    table-layout: auto;
    width: 100% !important;
}

.people-table td,
.people-table th {
    width: auto !important;
}

.person-profile-modal.is-open {
    background: #fff !important;
    border: 0 !important;
    border-radius: 18px !important;
    box-shadow: 0 28px 90px rgba(15, 23, 42, 0.22) !important;
    display: block !important;
    left: 50% !important;
    max-height: min(88dvh, 820px) !important;
    max-width: min(920px, calc(100vw - 40px)) !important;
    overflow: auto !important;
    padding: 0 !important;
    position: fixed !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 100% !important;
    z-index: 1300 !important;
}

.person-profile-modal.is-open::before {
    background: rgba(15, 23, 42, 0.52) !important;
}

.person-profile-modal .modal-close-row {
    margin: 0;
    padding: 16px 18px 0;
}

.person-profile-modal > .section-header {
    background: linear-gradient(135deg, #0877e8, #075fb8);
    border: 0;
    color: #fff;
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 22px 24px;
}

.person-profile-modal > .section-header h2 {
    color: #fff;
    font-size: 1.55rem;
    margin: 0;
}

.person-profile-modal > .section-header .state-badge {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    justify-self: start;
}

.person-profile-modal .profile-summary,
.person-profile-modal .profile-edit-details,
.person-profile-modal .history-block {
    margin-left: 24px;
    margin-right: 24px;
}

.person-profile-modal .profile-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 22px;
}

.person-profile-modal .profile-summary div {
    background: #fff;
    border: 1px solid #dce8f5;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.person-profile-modal .profile-edit-details {
    border-top: 0;
    margin-top: 12px;
    padding-top: 0;
}

.person-profile-modal .profile-edit-details summary {
    align-items: center;
    background: #eef6ff;
    border: 1px solid #cfe4fb;
    border-radius: 12px;
    color: #075fb8;
    display: flex;
    min-height: 48px;
    padding: 12px 14px;
}

.person-profile-modal .profile-edit-form {
    background: #f8fbff;
    border: 1px solid #dce8f5;
    border-radius: 14px;
    margin-top: 12px;
    padding: 16px;
}

.person-profile-modal .history-block {
    border-top: 1px solid #e4e9f1;
    margin-bottom: 24px;
    padding-top: 18px;
}

@media (max-width: 760px) {
    html,
    body {
        overflow-x: hidden;
        width: 100%;
    }

    .app-shell {
        display: block !important;
        width: 100% !important;
    }

    .app-main,
    .content-shell {
        padding-left: 12px !important;
        padding-right: 12px !important;
        width: 100% !important;
    }

    .page-heading {
        margin-bottom: 14px;
    }

    .page-heading h1 {
        font-size: 1.85rem !important;
        line-height: 1.08;
    }

    .panel-block,
    .kpi-card {
        border-radius: 14px !important;
        padding: 14px !important;
        width: 100% !important;
    }

    .kpi-grid {
        grid-template-columns: 1fr !important;
        width: 100%;
    }

    .kpi-card {
        grid-template-columns: 42px minmax(0, 1fr) !important;
    }

    .kpi-card span {
        font-size: 0.9rem;
        line-height: 1.25;
    }

    .stack-form,
    .people-form,
    .search-form {
        width: 100%;
    }

    .stack-form > *,
    .search-form > * {
        min-width: 0;
    }

    .responsive-table {
        overflow: visible !important;
        width: 100%;
    }

    .data-table,
    .people-table {
        width: 100% !important;
    }

    .person-profile-modal.is-open {
        border-radius: 0 !important;
        inset: 0 !important;
        max-height: none !important;
        max-width: none !important;
        min-height: 100dvh;
        padding: 0 !important;
        transform: none !important;
        width: 100% !important;
    }

    .person-profile-modal .modal-close-row {
        background: #0877e8;
        padding: 12px;
    }

    .person-profile-modal .modal-close-row .icon-button {
        margin-left: auto;
    }

    .person-profile-modal > .section-header {
        border-radius: 0 0 18px 18px;
        padding: 18px 16px 22px;
    }

    .person-profile-modal > .section-header h2 {
        font-size: 1.35rem;
        line-height: 1.2;
    }

    .person-profile-modal .profile-summary,
    .person-profile-modal .profile-edit-details,
    .person-profile-modal .history-block {
        margin-left: 14px;
        margin-right: 14px;
    }

    .person-profile-modal .profile-summary {
        grid-template-columns: 1fr !important;
        margin-top: 16px;
    }
}

/* Phase 23: hard responsive correction after legacy layout layers */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    min-width: 0;
}

.app-shell,
.app-main,
.content-shell {
    max-width: 100vw;
    min-width: 0 !important;
}

.app-main {
    overflow-x: clip;
    width: 100%;
}

.content-shell {
    margin: 0;
    max-width: none !important;
    width: 100% !important;
}

.content-shell > * {
    max-width: 100%;
}

.kpi-grid,
.dashboard-kpi-grid,
.report-kpi-grid,
.audit-kpi-grid,
.users-kpi-grid,
.structure-summary,
.live-hero-grid {
    display: grid !important;
    gap: 14px !important;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)) !important;
    width: 100% !important;
}

.kpi-card {
    align-items: center !important;
    display: grid !important;
    gap: 14px !important;
    grid-template-columns: 52px minmax(0, 1fr) !important;
    min-height: 112px !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

.kpi-card > div:not(.kpi-icon) {
    min-width: 0;
}

.kpi-card span,
.kpi-card strong,
.kpi-card small {
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal !important;
}

.kpi-card span {
    font-size: 0.95rem;
    line-height: 1.25;
}

.kpi-card strong {
    font-size: clamp(1.65rem, 6vw, 2rem) !important;
    line-height: 1.05 !important;
}

.form-grid-two,
.form-grid-three,
.teacher-grid,
.reports-export-form,
.search-form {
    min-width: 0 !important;
}

.form-grid-two > *,
.form-grid-three > *,
.teacher-grid > *,
.reports-export-form > *,
.search-form > * {
    min-width: 0 !important;
}

.people-layout {
    display: block !important;
    margin-top: 16px;
    max-width: none !important;
    width: 100% !important;
}

.people-layout > article.panel-block,
.people-layout > .panel-block {
    max-width: none !important;
    width: 100% !important;
}

.people-layout .section-header {
    align-items: flex-start;
}

.people-layout .responsive-table {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
    overflow-x: auto;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
}

.people-table {
    min-width: 0 !important;
    width: 100% !important;
}

.people-table td,
.people-table th {
    min-width: 0;
    overflow-wrap: anywhere;
    width: auto !important;
}

.person-profile-modal.is-open {
    background: #fff !important;
    border: 0 !important;
    border-radius: 18px !important;
    box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.54), 0 30px 90px rgba(15, 23, 42, 0.26) !important;
    display: flex !important;
    flex-direction: column !important;
    left: 50% !important;
    max-height: min(88dvh, 820px) !important;
    max-width: min(760px, calc(100vw - 32px)) !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: fixed !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 100% !important;
    z-index: 1300 !important;
}

.person-profile-modal.is-open::before {
    display: none !important;
}

.person-profile-modal .modal-close-row {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e4e9f1;
    display: flex;
    justify-content: flex-end;
    margin: 0 !important;
    min-height: 58px;
    padding: 10px 14px !important;
}

.person-profile-modal .modal-close-row .icon-button {
    background: #f7fafd;
    border-radius: 999px;
}

.person-profile-modal > .section-header {
    background: #fff !important;
    border-bottom: 1px solid #e4e9f1 !important;
    color: var(--app-text) !important;
    display: grid !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: 20px 24px !important;
}

.person-profile-modal > .section-header h2 {
    color: var(--app-text) !important;
    font-size: clamp(1.25rem, 4vw, 1.65rem) !important;
    line-height: 1.16 !important;
    margin: 0 !important;
    overflow-wrap: anywhere;
}

.person-profile-modal > .section-header .state-badge {
    background: #eef6ff !important;
    border: 1px solid #cfe4fb !important;
    color: #075fb8 !important;
    justify-self: start !important;
}

.person-profile-modal .profile-summary,
.person-profile-modal .profile-edit-details,
.person-profile-modal .history-block {
    margin-left: 24px !important;
    margin-right: 24px !important;
}

.person-profile-modal .profile-summary {
    background: #fff;
    border: 1px solid #e4e9f1;
    border-radius: 14px;
    display: grid;
    gap: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    margin-top: 20px !important;
    overflow: hidden;
}

.person-profile-modal .profile-summary div {
    background: #fff !important;
    border: 0 !important;
    border-bottom: 1px solid #e4e9f1 !important;
    border-right: 1px solid #e4e9f1 !important;
    box-shadow: none !important;
    min-width: 0;
    padding: 14px 16px !important;
}

.person-profile-modal .profile-summary div:nth-child(2n) {
    border-right: 0 !important;
}

.person-profile-modal .profile-summary div:nth-last-child(-n + 2) {
    border-bottom: 0 !important;
}

.person-profile-modal .profile-summary dt {
    color: #667085;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.person-profile-modal .profile-summary dd {
    color: var(--app-text);
    font-size: 0.98rem;
    font-weight: 700;
    margin: 0;
    overflow-wrap: anywhere;
}

.person-profile-modal .profile-edit-details,
.person-profile-modal .history-block {
    flex: 0 0 auto;
}

.person-profile-modal .profile-edit-details {
    margin-top: 16px !important;
}

.person-profile-modal .profile-edit-details summary {
    align-items: center;
    background: #f7fafd !important;
    border: 1px solid #dce8f5 !important;
    border-radius: 12px !important;
    color: var(--app-primary-dark) !important;
    cursor: pointer;
    display: flex;
    font-weight: 800;
    min-height: 48px;
    padding: 12px 14px !important;
}

.person-profile-modal .profile-edit-form {
    background: #fff !important;
    border: 1px solid #e4e9f1 !important;
    border-radius: 14px !important;
    margin-top: 12px !important;
    padding: 16px !important;
}

.person-profile-modal .history-block {
    border-top: 1px solid #e4e9f1 !important;
    margin-bottom: 24px !important;
    margin-top: 18px !important;
    overflow: visible;
    padding-top: 18px !important;
}

.person-profile-modal.is-open {
    overflow-y: auto !important;
}

@media (max-width: 1180px) {
    .content-shell {
        padding: 22px 20px 32px !important;
    }

    .page-heading {
        align-items: flex-start !important;
        display: grid !important;
    }

    .form-grid-two,
    .form-grid-three,
    .teacher-grid {
        grid-template-columns: 1fr !important;
    }

    .kpi-card small {
        display: none;
    }
}

@media (max-width: 760px) {
    .app-topbar {
        gap: 10px !important;
        min-height: 64px !important;
        padding: 10px 12px !important;
    }

    .topbar-title {
        display: none !important;
    }

    .topbar-actions {
        gap: 8px !important;
        margin-left: auto !important;
    }

    .icon-button {
        border-radius: 12px !important;
        flex-basis: 46px !important;
        height: 46px !important;
        min-height: 46px !important;
        min-width: 46px !important;
        width: 46px !important;
    }

    .user-chip {
        border-radius: 999px !important;
        min-height: 46px !important;
        min-width: 46px !important;
        padding: 4px !important;
        width: 46px !important;
    }

    .user-chip span {
        height: 36px !important;
        width: 36px !important;
    }

    .user-chip strong {
        display: none !important;
    }

    .content-shell {
        padding: 18px 14px 28px !important;
    }

    .page-heading {
        gap: 10px !important;
        margin-bottom: 18px !important;
    }

    .page-heading span {
        font-size: 0.78rem !important;
    }

    .page-heading h1 {
        font-size: clamp(2rem, 10vw, 2.45rem) !important;
        letter-spacing: 0 !important;
        line-height: 1.04 !important;
        margin: 4px 0 0 !important;
        overflow-wrap: anywhere;
    }

    .kpi-grid,
    .dashboard-kpi-grid,
    .report-kpi-grid,
    .audit-kpi-grid,
    .users-kpi-grid,
    .structure-summary,
    .live-hero-grid {
        grid-template-columns: 1fr !important;
    }

    .kpi-card,
    .panel-block {
        border-radius: 16px !important;
        padding: 18px !important;
    }

    .kpi-card {
        grid-template-columns: 52px minmax(0, 1fr) !important;
        min-height: 104px !important;
    }

    .kpi-card span {
        font-size: 1rem !important;
    }

    .kpi-card strong {
        font-size: 2rem !important;
    }

    .search-form {
        display: grid !important;
        gap: 10px !important;
        grid-template-columns: 1fr !important;
    }

    .search-form label {
        min-height: auto !important;
        padding-top: 0 !important;
    }

    .search-form .secondary-button,
    .primary-button,
    .secondary-button {
        justify-content: center;
        min-height: 46px;
        width: 100%;
    }

    .people-layout .responsive-table {
        overflow: visible !important;
    }

    .people-table,
    .people-table thead,
    .people-table tbody,
    .people-table tr,
    .people-table th,
    .people-table td {
        display: block !important;
        width: 100% !important;
    }

    .people-table thead {
        display: none !important;
    }

    .people-table tr {
        background: #fff;
        border: 1px solid #e4e9f1;
        border-radius: 14px;
        box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
        margin-bottom: 10px;
        overflow: hidden;
        padding: 10px 12px;
    }

    .people-table td {
        align-items: flex-start !important;
        border: 0 !important;
        display: grid !important;
        gap: 4px !important;
        grid-template-columns: 1fr !important;
        min-height: auto !important;
        padding: 8px 0 !important;
    }

    .people-table td::before {
        color: #667085;
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .people-table td:first-child {
        color: var(--app-text);
        font-size: 1rem;
        font-weight: 850;
    }

    .people-table td:first-child::before {
        display: none;
    }

    .person-profile-modal.is-open {
        border-radius: 0 !important;
        inset: 0 !important;
        max-height: none !important;
        max-width: none !important;
        min-height: 100dvh !important;
        top: 0 !important;
        transform: none !important;
        width: 100% !important;
    }

    .person-profile-modal.is-open::before {
        display: none !important;
    }

    .person-profile-modal .modal-close-row {
        min-height: 58px;
        padding: 10px 14px !important;
    }

    .person-profile-modal > .section-header {
        padding: 18px 16px !important;
    }

    .person-profile-modal .profile-summary,
    .person-profile-modal .profile-edit-details,
    .person-profile-modal .history-block {
        margin-left: 14px !important;
        margin-right: 14px !important;
    }

    .person-profile-modal .profile-summary {
        grid-template-columns: 1fr !important;
    }

    .person-profile-modal .profile-summary div {
        border-right: 0 !important;
    }

    .person-profile-modal .profile-summary div:nth-last-child(-n + 2) {
        border-bottom: 1px solid #e4e9f1 !important;
    }

    .person-profile-modal .profile-summary div:last-child {
        border-bottom: 0 !important;
    }
}

@media (max-width: 420px) {
    .content-shell {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .page-heading h1 {
        font-size: 2rem !important;
    }

    .kpi-card,
    .panel-block {
        padding: 16px !important;
    }
}

/* Operational QR flows: attendance and appeals */
.operational-hero {
    align-items: center !important;
    background:
        linear-gradient(90deg, rgba(14, 119, 242, 0.1), rgba(255, 255, 255, 0) 48%),
        #fff !important;
    border: 1px solid #dce8f5 !important;
    border-left: 5px solid var(--app-primary) !important;
    color: var(--app-text) !important;
    display: flex !important;
    gap: 18px !important;
    justify-content: space-between !important;
    margin-bottom: 16px;
}

.operational-hero span {
    color: var(--app-primary) !important;
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
}

.operational-hero h2 {
    color: var(--app-text) !important;
    font-size: clamp(1.15rem, 3vw, 1.5rem);
    line-height: 1.18;
    margin: 4px 0;
}

.operational-hero p {
    color: #667085 !important;
    font-weight: 650;
    margin: 0;
}

.operational-hero strong {
    background: #eef6ff;
    border: 1px solid #cfe4fb;
    border-radius: 999px;
    color: #075fb8 !important;
    flex: 0 0 auto;
    font-size: 0.95rem !important;
    font-weight: 850;
    padding: 10px 14px;
}

.qr-workflow-panel {
    display: grid;
    gap: 16px;
}

.qr-reader-shell {
    display: grid;
    gap: 12px;
}

.qr-reader-frame {
    align-items: center;
    aspect-ratio: 1 / 1;
    background: linear-gradient(180deg, #f7fbff, #eef6ff);
    border: 1px dashed #9ac8f7;
    border-radius: 18px;
    color: #075fb8;
    display: grid;
    justify-items: center;
    min-height: 340px;
    overflow: hidden;
    padding: 18px;
    text-align: center;
}

.qr-reader-frame > i {
    font-size: 2.6rem;
}

.qr-reader-frame > span {
    color: #42617f;
    font-weight: 800;
}

.qr-reader-frame.is-active {
    background: #0f172a;
    border-color: #0f172a;
    padding: 0;
}

.qr-reader-frame video {
    border-radius: 18px;
    object-fit: cover;
}

.qr-reader-frame img,
.qr-reader-frame button,
.qr-reader-frame select {
    max-width: 100%;
}

.qr-reader-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
}

.qr-reader-actions .primary-button.is-scanning {
    background: #0f172a;
    border-color: #0f172a;
}

.attendance-qr-form,
.qr-workflow-panel > .stack-form {
    background: #f8fbff;
    border: 1px solid #e4e9f1;
    border-radius: 14px;
    padding: 14px;
}

.qr-assign-field {
    display: grid;
    gap: 7px;
}

.qr-assign-field small {
    color: #667085;
    font-weight: 750;
}

.qr-is-free [data-qr-availability-message] {
    color: #12805c;
}

.qr-is-busy [data-qr-availability-message] {
    color: #b42318;
}

.qr-is-checking [data-qr-availability-message] {
    color: #075fb8;
}

.js-enabled [data-live-search] button[type="submit"] {
    display: none;
}

.person-attendance-list.is-loading,
.appeal-person-list.is-loading {
    opacity: 0.62;
}

.operation-result-modal {
    align-items: center;
    background: rgba(15, 23, 42, 0.52);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: fixed;
    z-index: 1800;
}

.operation-result-card {
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
    display: grid;
    gap: 10px;
    justify-items: center;
    max-width: 420px;
    padding: 28px 24px 24px;
    position: relative;
    text-align: center;
    width: min(100%, 420px);
}

.operation-result-card > .icon-button {
    position: absolute;
    right: 12px;
    top: 12px;
}

.operation-result-icon {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 2rem;
    height: 70px;
    justify-content: center;
    width: 70px;
}

.operation-result-modal.is-success .operation-result-icon {
    background: #e7f8ef;
    color: #11945a;
}

.operation-result-modal.is-error .operation-result-icon {
    background: #fff3f0;
    color: #c52b20;
}

.operation-result-card span {
    color: #667085;
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.operation-result-card strong {
    color: var(--app-text);
    font-size: clamp(1.35rem, 6vw, 1.9rem);
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.operation-result-card p {
    color: #475467;
    font-size: 1rem;
    margin: 0;
}

.appeal-decision-modal {
    align-items: center;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: fixed;
    z-index: 1850;
}

.appeal-decision-card {
    background: #fff;
    border: 1px solid #dce8f5;
    border-radius: 24px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
    display: grid;
    gap: 12px;
    max-width: 460px;
    padding: 28px 24px 24px;
    position: relative;
    text-align: left;
    width: min(100%, 460px);
}

.appeal-decision-card > .icon-button {
    position: absolute;
    right: 12px;
    top: 12px;
}

.appeal-decision-icon {
    align-items: center;
    background: #eef6ff;
    border-radius: 999px;
    color: #075fb8;
    display: inline-flex;
    font-size: 1.8rem;
    height: 58px;
    justify-content: center;
    width: 58px;
}

.appeal-decision-card > span {
    color: #667085;
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
}

.appeal-decision-card > strong {
    color: var(--app-text);
    font-size: clamp(1.45rem, 5vw, 2rem);
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.appeal-decision-card > p {
    color: #475467;
    font-weight: 700;
    margin: 0;
}

.attendance-qr-assignment-modal {
    align-items: center;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: fixed;
    z-index: 1850;
}

.attendance-qr-assignment-card {
    background: #fff;
    border: 1px solid #dce8f5;
    border-radius: 20px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
    display: grid;
    gap: 13px;
    max-width: 440px;
    padding: 28px 24px 24px;
    position: relative;
    text-align: left;
    width: min(100%, 440px);
}

.attendance-qr-assignment-card > .icon-button {
    position: absolute;
    right: 12px;
    top: 12px;
}

.attendance-qr-assignment-icon {
    align-items: center;
    background: #eef6ff;
    border-radius: 999px;
    color: #075fb8;
    display: inline-flex;
    font-size: 1.8rem;
    height: 58px;
    justify-content: center;
    width: 58px;
}

.attendance-qr-assignment-card > span {
    color: #667085;
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.attendance-qr-assignment-card > strong {
    color: var(--app-text);
    font-size: clamp(1.45rem, 5vw, 2rem);
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.attendance-qr-assignment-card > p {
    color: #475467;
    font-weight: 650;
    margin: 0;
}

/* Clean route/selection UX refinements */
.live-person-picker {
    display: grid;
    gap: 8px;
    position: relative;
}

.person-search-results {
    display: grid;
    gap: 8px;
    min-height: 0;
}

.person-search-results.is-loading {
    opacity: 0.72;
}

.person-search-results button {
    background: #fff;
    border: 1px solid #dbe5f1;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(16, 24, 40, 0.06);
    color: var(--app-text);
    display: grid;
    gap: 4px;
    padding: 13px 14px;
    text-align: left;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
    width: 100%;
}

.person-search-results button:hover,
.person-search-results button:focus-visible {
    border-color: #7bb6ef;
    box-shadow: 0 12px 28px rgba(21, 87, 159, 0.12);
    outline: none;
    transform: translateY(-1px);
}

.person-search-results button:disabled {
    background: #f7f9fc;
    box-shadow: none;
    color: #667085;
    cursor: not-allowed;
    transform: none;
}

.person-search-results strong {
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.2;
}

.person-search-results span {
    color: #667085;
    font-size: 0.86rem;
    font-weight: 650;
}

.table-action-button {
    min-height: 40px;
    padding-inline: 12px;
}

.compact-person-modal {
    max-width: 560px;
}

.compact-person-modal .section-header {
    align-items: flex-start;
    gap: 14px;
}

.live-hero-card {
    background: linear-gradient(135deg, #0f4f96, #1686dc);
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.live-hero-card.accent {
    background: linear-gradient(135deg, #11695d, #1aa585);
}

.live-hero-card span,
.live-hero-card small,
.live-hero-card strong {
    color: #fff;
}

.form-helper {
    color: #667085;
    display: block;
    font-size: 0.85rem;
    font-weight: 650;
    line-height: 1.45;
    margin-top: 6px;
}

.auth-toast-stack {
    left: auto;
    right: 18px;
    top: 18px;
}

/* Phase 23: scoped lists, hierarchy lookup and full-width records */
.study-layout,
.baptism-layout {
    display: block !important;
    max-width: none;
    min-width: 0;
    width: 100%;
}

.study-layout > .panel-block,
.baptism-layout > .panel-block,
.study-layout .responsive-table,
.baptism-layout .responsive-table {
    max-width: none;
    min-width: 0;
    width: 100%;
}

.study-table,
.baptism-table {
    min-width: 0;
    width: 100%;
}

.structure-search-field {
    display: grid;
    gap: 8px;
    min-width: 0;
    position: relative;
}

.structure-search-field label small {
    color: #667085;
    font-size: 0.8rem;
    font-weight: 650;
}

.structure-search-results {
    display: grid;
    gap: 6px;
}

.structure-search-results button {
    background: #fff;
    border: 1px solid #dbe5f1;
    border-radius: 10px;
    color: var(--app-text);
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    text-align: left;
    width: 100%;
}

.structure-search-results button:hover,
.structure-search-results button:focus-visible {
    background: #f5faff;
    border-color: #7bb6ef;
    outline: 2px solid #b7dcff;
    outline-offset: 1px;
}

.structure-search-results strong {
    font-size: 0.92rem;
    font-weight: 800;
}

.structure-search-results span {
    color: #667085;
    font-size: 0.8rem;
}

.current-user-field {
    display: grid;
    gap: 8px;
}

.current-user-value {
    align-items: center;
    background: #f3f8fe;
    border: 1px solid #cfe4fb;
    border-radius: 10px;
    color: #0b5fb6;
    display: flex;
    gap: 9px;
    min-height: 46px;
    padding: 10px 12px;
}

.current-user-value i {
    font-size: 1.05rem;
}

.pagination-bar {
    align-items: center;
    border-top: 1px solid #e4e9f1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 16px;
}

.pagination-bar > span {
    color: #667085;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
}

.compact-person-modal.ux-modal-panel.is-open {
    background: #fff !important;
    border: 1px solid #d5e1ee !important;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28) !important;
    max-width: min(760px, calc(100vw - 32px));
    opacity: 1 !important;
}

.compact-person-modal .profile-summary {
    background: #fff;
    border: 1px solid #dce8f5;
    border-radius: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 18px 0 0;
    overflow: hidden;
}

.compact-person-modal .profile-summary div {
    background: #fff;
    border-bottom: 1px solid #e4e9f1;
    border-right: 1px solid #e4e9f1;
    min-width: 0;
    padding: 13px 14px;
}

.compact-person-modal .profile-summary dt {
    color: #667085;
    font-size: 0.76rem;
    font-weight: 800;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.compact-person-modal .profile-summary dd {
    color: #1d2939;
    font-size: 0.94rem;
    font-weight: 700;
    margin: 0;
    overflow-wrap: anywhere;
}

.worker-assignment-panel {
    grid-column: 1 / -1;
}

.worker-assignment-list {
    display: grid;
    gap: 10px;
}

.worker-assignment-list section {
    background: #fff;
    border: 1px solid #dce8f5;
    border-radius: 10px;
    padding: 12px;
}

.worker-assignment-list section > strong {
    color: var(--app-text);
    display: block;
    margin-bottom: 8px;
}

.worker-assignment-list ul {
    display: grid;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.worker-assignment-list li {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.worker-assignment-list li small {
    color: #667085;
    font-weight: 650;
}

@media (max-width: 760px) {
    .operational-hero {
        align-items: flex-start !important;
        display: grid !important;
    }

    .operational-hero strong {
        justify-self: start;
    }

    .qr-reader-frame {
        aspect-ratio: 1 / 1;
        min-height: 300px;
    }

    .qr-reader-actions {
        grid-template-columns: 1fr;
    }

    .operation-result-modal {
        align-items: flex-end;
        padding: 12px;
    }

    .operation-result-card {
        border-radius: 20px;
        max-width: none;
        padding: 30px 18px 22px;
        width: 100%;
    }

    .appeal-decision-modal {
        align-items: flex-end;
        padding: 12px;
    }

    .appeal-decision-card {
        border-radius: 22px;
        max-width: none;
        width: 100%;
    }

    .attendance-qr-assignment-modal {
        align-items: flex-end;
        padding: 12px;
    }

    .attendance-qr-assignment-card {
        border-radius: 22px;
        max-width: none;
        width: 100%;
    }

    .person-search-results button {
        border-radius: 12px;
        padding: 12px;
    }

    .compact-person-modal {
        max-width: none;
    }

    .table-action-button {
        justify-content: center;
        width: 100%;
    }

    .pagination-bar {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .pagination-bar > span {
        grid-column: 1 / -1;
        order: -1;
    }

    .compact-person-modal .profile-summary {
        grid-template-columns: 1fr;
    }

    .compact-person-modal .profile-summary div {
        border-right: 0;
    }
}
/* Unified administrative forms and data views */
.people-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-modal {
    width: min(760px, calc(100vw - 32px));
    max-height: min(860px, calc(100dvh - 32px));
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
}

.modal-form,
.profile-edit-form {
    gap: 20px;
}

.modal-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 8px;
}

.user-scope-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

[data-user-district-field].is-unavailable {
    display: none;
}

.permission-role-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-items: start;
}

.permission-role-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    box-shadow: none;
}

.permission-checkbox-list label {
    min-height: 44px;
    border-bottom: 1px solid #eef2f7;
}

.data-table th > button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0;
    border: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.data-table th[aria-sort] > button {
    color: var(--primary, #2563eb);
}

.table-toolbar {
    display: flex;
    align-items: end;
    gap: 16px;
    margin-bottom: 18px;
}

.table-toolbar label {
    display: grid;
    gap: 7px;
    min-width: 220px;
    color: #475569;
    font-size: .875rem;
    font-weight: 700;
}

.table-search { flex: 1; }
.data-table-toolbar {
    padding: 0;
    border: 0;
    background: transparent;
}
.search-control { position: relative; }
.search-control > i { position: absolute; left: 14px; top: 50%; color: #64748b; transform: translateY(-50%); }
.search-control input { width: 100%; min-height: 48px; padding-left: 42px; border: 1px solid #d7e0eb; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.search-control input:focus { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); outline: 0; }
.filter-control { max-width: 260px; }
.filter-control select { min-height: 48px; border: 1px solid #d7e0eb; border-radius: 12px; background-color: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.reports-primary-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.reports-date-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 16px; }
.reports-date-row > div { display: grid; gap: 8px; }
.reports-date-row [hidden] { display: none !important; }
.reports-filter-panel { border-top: 3px solid #2563eb; }
.reports-filter-form { gap: 20px; }
.reports-filter-form select, .reports-filter-form input { border-radius: 10px; }
.row-number { width: 54px; color: #64748b; font-variant-numeric: tabular-nums; font-weight: 750; }
.danger-zone { border-color: #fecaca; background: #fffafa; }
.consent-check { display: flex !important; align-items: flex-start; gap: 10px; min-height: 44px; padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; color: #334155; line-height: 1.45; }
.consent-check input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; }
.consent-check a { color: #1d4ed8; font-weight: 750; text-decoration: underline; text-underline-offset: 2px; }
.is-context-fixed { display: none !important; }
.fixed-scope-note { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid #bfdbfe; border-radius: 8px; color: #1e3a8a; background: #eff6ff; }
.fixed-scope-note span { color: #64748b; }
.phone-link { display: inline-flex; align-items: center; gap: 7px; color: #1d4ed8; font-weight: 700; text-decoration: none; }
.phone-link:hover { text-decoration: underline; }
.danger-zone .section-header p { max-width: 760px; color: #7f1d1d; }
.danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 10px 16px; border: 1px solid #b91c1c; border-radius: 8px; color: #fff; background: #b91c1c; font: inherit; font-weight: 750; cursor: pointer; }
.danger-button:hover { background: #991b1b; }
.reset-system-modal { border-top: 4px solid #b91c1c; }
.report-chart-panel { margin-bottom: 16px; }

.profile-modal {
    width: min(860px, calc(100vw - 32px));
    max-height: min(900px, calc(100dvh - 32px));
    overflow-y: auto;
    background: #fff;
}

.profile-identity {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 4px 0 22px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.profile-avatar {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 50%;
    color: #1d4ed8;
    background: #dbeafe;
    font-weight: 800;
}

.profile-identity div { display: grid; gap: 3px; }
.profile-identity strong { color: #0f172a; font-size: 1.05rem; }
.profile-identity span { color: #64748b; }
.profile-actions { display: flex; justify-content: flex-end; margin-top: 20px; }

.teacher-choice-panel {
    align-items: start;
    gap: 16px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.teacher-grid.teacher-choice-panel {
    grid-template-columns: minmax(0, 1fr) minmax(220px, .75fr);
}

.teacher-grid.teacher-choice-panel [data-other-teacher-field] {
    grid-column: 1 / -1;
}

.teacher-choice-panel .teacher-other-toggle,
.teacher-choice-panel [data-other-teacher-field] {
    min-width: 0;
    width: 100%;
}

.teacher-choice-panel .compact-check {
    align-items: flex-start;
    white-space: normal;
    line-height: 1.45;
}

.structure-browser .structure-child-panel[hidden] { display: none; }
.structure-browser .text-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin-bottom: 8px;
    padding: 0;
    border: 0;
    color: #2563eb;
    background: transparent;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}
.structure-browser .text-button:hover { color: #1d4ed8; text-decoration: underline; }
.permissions-modal .permission-checkbox-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 52dvh; overflow-y: auto; }
.structure-browser .table-action-button { margin-left: 12px; }
.campaign-modal-layout { display: block; }

@media (max-width: 900px) {
    .people-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .table-toolbar { align-items: stretch; flex-direction: column; }
    .table-toolbar label { width: 100%; min-width: 0; }
}

@media (max-width: 600px) {
    .people-kpi-grid { grid-template-columns: 1fr; }
    .form-modal,
    .profile-modal {
        width: 100%;
        max-height: 92dvh;
        margin-top: auto;
        border-radius: 16px 16px 0 0;
    }
    .user-scope-grid,
    .profile-edit-form .form-grid-two,
    .profile-edit-form .form-grid-three { grid-template-columns: 1fr; }
    .modal-form-actions { flex-direction: column-reverse; }
    .modal-form-actions button { width: 100%; }
    .structure-browser .table-action-button { width: 100%; margin: 8px 0 0; }
    .reports-primary-filters, .reports-date-row { grid-template-columns: 1fr; }
}

.server-table-controls {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: auto minmax(220px, 1fr) auto;
    margin: 0 0 18px;
    padding: 14px;
    width: 100%;
}

.server-table-controls label { margin: 0; }
.server-table-controls .table-page-size { align-items: center; display: flex; flex-direction: row; gap: 8px; min-width: 0; color: var(--app-muted); font-size: .9rem; font-weight: 700; }
.server-table-controls .table-page-size select { appearance: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; color: var(--app-text); font: inherit; min-height: 44px; min-width: 76px; padding: 8px 28px 8px 10px; }
.server-table-controls .table-search { display: block; margin: 0; min-width: 0; width: 100%; }
.server-table-controls .search-control { display: block; position: relative; width: 100%; }
.server-table-controls .search-control input { background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-sizing: border-box; color: var(--app-text); font: inherit; min-height: 44px; padding: 10px 12px 10px 42px; width: 100%; }
.server-table-controls .search-control input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); outline: 0; }
.table-result-count { color: #475569; font-size: .9rem; font-weight: 700; white-space: nowrap; }
.server-table-pagination { align-items: center; display: flex; gap: 6px; justify-content: flex-end; margin-top: 16px; }
.table-page-button { border: 1px solid var(--app-border); border-radius: 8px; background: #fff; color: var(--app-text); cursor: pointer; font: inherit; font-weight: 750; min-height: 42px; min-width: 42px; padding: 8px; }
.table-page-button:hover { border-color: #93b4dc; background: #f8fbff; }
.table-page-button.is-active { border-color: var(--app-primary); background: var(--app-primary); color: #fff; }
[data-server-sort] { align-items: center; background: transparent; border: 0; color: inherit; cursor: pointer; display: inline-flex; font: inherit; font-weight: inherit; gap: 6px; padding: 0; text-align: left; }
[data-server-sort] i { color: #94a3b8; font-size: .8rem; }
#people-server-table,
#reports-server-table,
#associations-server-table,
#districts-server-table,
#churches-server-table { background: #fff; border: 1px solid var(--app-border); border-radius: 8px; box-shadow: var(--shadow-sm); max-width: none; min-width: 0; width: 100%; }
#people-server-table .responsive-table,
#reports-server-table .responsive-table,
#associations-server-table .responsive-table,
#districts-server-table .responsive-table,
#churches-server-table .responsive-table { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; max-width: 100%; overflow-x: auto; width: 100%; }
#people-server-table .data-table,
#reports-server-table .data-table,
#associations-server-table .data-table,
#districts-server-table .data-table,
#churches-server-table .data-table { background: #fff; margin: 0; width: 100%; }
.is-table-loading { min-height: 180px; opacity: .58; pointer-events: none; position: relative; }
.is-table-loading::after { animation: table-spin .7s linear infinite; border: 3px solid #dbe7f5; border-top-color: var(--app-primary); border-radius: 50%; content: ''; height: 32px; left: 50%; margin: -16px 0 0 -16px; position: absolute; top: 50%; width: 32px; z-index: 4; }
@keyframes table-spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
    .server-table-controls { align-items: stretch; grid-template-columns: 1fr 1fr; padding: 12px; }
    .server-table-controls .table-search { grid-column: 1 / -1; grid-row: 1; }
    .table-result-count { align-self: center; text-align: right; white-space: normal; }
    .server-table-pagination { justify-content: center; }
}

@media (max-width: 430px) {
    .server-table-controls { grid-template-columns: 1fr; }
    .server-table-controls .table-search { grid-column: 1; }
    .table-result-count { text-align: left; }
    .server-table-controls .table-page-size { justify-content: space-between; width: 100%; }
    .server-table-controls .table-page-size select { flex: 0 0 84px; }
}

/* Compact mobile records for every administrative data table */
@media (max-width: 760px) {
    .panel-block:has(> .server-table-controls) {
        padding: 16px !important;
    }

    .server-table-controls {
        background: #f8fafc;
        border-radius: 10px;
        gap: 12px;
        margin-bottom: 14px;
    }

    .server-table-controls .search-control input {
        min-height: 48px;
    }

    .responsive-table,
    #people-server-table .responsive-table,
    #reports-server-table .responsive-table,
    #associations-server-table .responsive-table,
    #districts-server-table .responsive-table,
    #churches-server-table .responsive-table {
        background: transparent;
        border: 0;
        border-radius: 0;
        overflow: visible;
    }

    .data-table,
    .data-table tbody {
        display: block !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .data-table thead {
        display: none !important;
    }

    .data-table tbody {
        display: grid !important;
        gap: 12px;
    }

    .data-table tbody tr {
        background: #fff;
        border: 1px solid #dce5ef;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(15, 23, 42, .045);
        display: grid !important;
        gap: 0;
        margin: 0 !important;
        overflow: hidden;
        padding: 12px 14px !important;
        width: 100% !important;
    }

    .data-table tbody td {
        align-items: flex-start !important;
        border: 0 !important;
        border-bottom: 1px solid #edf2f7 !important;
        display: grid !important;
        gap: 3px !important;
        grid-template-columns: minmax(88px, 34%) minmax(0, 1fr) !important;
        min-height: 0 !important;
        padding: 9px 0 !important;
        text-align: left !important;
        width: 100% !important;
    }

    .data-table tbody td:last-child {
        border-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    .data-table tbody td::before {
        color: #64748b;
        content: attr(data-label) !important;
        display: block !important;
        font-size: .76rem !important;
        font-weight: 750 !important;
        line-height: 1.4;
        max-width: none !important;
        text-align: left !important;
        text-transform: none !important;
    }

    .data-table tbody td > * {
        justify-self: start;
        max-width: 100% !important;
        min-width: 0;
    }

    .data-table tbody td:empty {
        display: none !important;
    }

    .data-table .row-number {
        color: #64748b;
        font-size: .8rem !important;
        font-weight: 750 !important;
        padding-top: 0 !important;
    }

    .data-table .state-badge {
        width: auto;
    }

    .data-table .table-action-button,
    .data-table td > .secondary-button,
    .data-table td > .primary-button {
        justify-content: center;
        margin-top: 2px;
        width: 100%;
    }

    .server-table-pagination {
        border-top: 1px solid #e2e8f0;
        margin-top: 14px;
        padding-top: 14px;
    }

    .people-table tbody tr {
        grid-template-columns: minmax(0, 1fr) auto !important;
        padding: 14px !important;
    }

    .people-table tbody td {
        grid-column: 1 / -1;
    }

    .people-table tbody td:nth-child(1) {
        align-self: start !important;
        border: 0 !important;
        display: block !important;
        grid-column: 2;
        grid-row: 1;
        padding: 2px 0 0 12px !important;
    }

    .people-table tbody td:nth-child(1)::before,
    .people-table tbody td:nth-child(2)::before {
        display: none !important;
    }

    .people-table tbody td:nth-child(2) {
        border: 0 !important;
        color: #0f172a;
        display: block !important;
        font-size: 1rem;
        font-weight: 800;
        grid-column: 1;
        grid-row: 1;
        line-height: 1.35;
        padding: 0 0 11px !important;
    }

    .people-table tbody td:nth-child(3),
    .people-table tbody td:nth-child(4),
    .people-table tbody td:nth-child(5),
    .people-table tbody td:nth-child(6) {
        grid-template-columns: 88px minmax(0, 1fr) !important;
    }

    .people-table tbody td:nth-child(7) {
        display: block !important;
        padding-top: 12px !important;
    }

    .people-table tbody td:nth-child(7)::before {
        display: none !important;
    }
}

@media (max-width: 430px) {
    .panel-block:has(> .server-table-controls) {
        padding: 14px !important;
    }

    .server-table-controls {
        padding: 12px;
    }

    .data-table tbody td {
        grid-template-columns: 82px minmax(0, 1fr) !important;
    }

    .people-table tbody td:nth-child(3),
    .people-table tbody td:nth-child(4),
    .people-table tbody td:nth-child(5),
    .people-table tbody td:nth-child(6) {
        grid-template-columns: 82px minmax(0, 1fr) !important;
    }
}

/* Person profile: clear hierarchy, compact details and persistent close action */
.compact-person-modal.profile-modal {
    background: #fff !important;
    border: 0 !important;
    border-radius: 16px !important;
    box-shadow: 0 28px 80px rgba(15, 23, 42, .24) !important;
    max-height: min(820px, calc(100dvh - 40px));
    max-width: 760px;
    overflow: auto;
    padding: 0 !important;
    width: min(760px, calc(100vw - 32px));
}

.profile-modal-header {
    align-items: center;
    background: #f8fbff;
    border-bottom: 1px solid #dbe5f1;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 26px 72px 24px 28px;
    position: relative;
}

.profile-modal-header .profile-identity {
    background: transparent;
    border: 0;
    display: flex;
    margin: 0;
    padding: 0;
}

.profile-modal-header .profile-avatar {
    background: #dbeafe;
    color: #1d4ed8;
    height: 64px;
    width: 64px;
    flex-basis: 64px;
    font-size: 1.2rem;
}

.profile-modal-header .profile-identity > div {
    align-content: center;
    gap: 3px;
}

.profile-eyebrow {
    color: #64748b !important;
    font-size: .72rem !important;
    font-weight: 800;
    text-transform: uppercase;
}

.profile-modal-header h2 {
    color: #0f172a;
    font-size: 1.35rem;
    line-height: 1.25;
    margin: 0;
    overflow-wrap: anywhere;
}

.profile-phone {
    align-items: center;
    color: #1d4ed8 !important;
    display: inline-flex !important;
    font-size: .9rem;
    font-weight: 700;
    gap: 7px;
    margin-top: 3px;
    text-decoration: none;
}

.profile-phone.is-empty {
    color: #64748b !important;
}

.profile-status {
    justify-self: end;
    white-space: nowrap;
}

.profile-modal-close {
    background: #fff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    position: absolute;
    right: 20px;
    top: 20px;
    z-index: 2;
}

.profile-section-heading {
    align-items: center;
    color: #334155;
    display: flex;
    gap: 9px;
    padding: 24px 28px 12px;
}

.profile-section-heading i {
    color: #2563eb;
    font-size: 1rem;
}

.profile-section-heading h3 {
    font-size: .95rem;
    font-weight: 800;
    margin: 0;
}

.compact-person-modal.profile-modal .profile-summary {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 28px 24px;
    overflow: hidden;
}

.compact-person-modal.profile-modal .profile-summary > div {
    background: #fff;
    border: 0;
    border-bottom: 1px solid #edf2f7;
    border-right: 1px solid #edf2f7;
    display: grid;
    gap: 4px;
    padding: 14px 16px;
}

.compact-person-modal.profile-modal .profile-summary > div:nth-child(even) {
    border-right: 0;
}

.compact-person-modal.profile-modal .profile-summary dt {
    color: #64748b;
    font-size: .7rem;
    font-weight: 800;
    margin: 0;
    text-transform: uppercase;
}

.compact-person-modal.profile-modal .profile-summary dd {
    color: #1e293b;
    font-size: .93rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
    overflow-wrap: anywhere;
}

.compact-person-modal.profile-modal .profile-actions {
    border-top: 1px solid #e2e8f0;
    margin: 0;
    padding: 18px 28px 24px;
}

.compact-person-modal.profile-modal .profile-actions .primary-button {
    margin-left: auto;
    width: auto;
}

.compact-person-modal.profile-modal .profile-edit-form {
    border-top: 1px solid #e2e8f0;
    padding: 24px 28px 28px;
}

@media (max-width: 600px) {
    .compact-person-modal.profile-modal {
        border-radius: 18px 18px 0 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        max-height: 94dvh !important;
        max-width: none !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
    }

    .profile-modal-header {
        align-items: start;
        gap: 14px;
        grid-template-columns: 1fr;
        padding: 22px 64px 20px 18px;
    }

    .profile-modal-header .profile-avatar {
        height: 52px;
        width: 52px;
        flex-basis: 52px;
        font-size: 1rem;
    }

    .profile-modal-header h2 {
        font-size: 1.15rem;
    }

    .profile-status {
        justify-self: start;
    }

    .profile-modal-close {
        right: 12px;
        top: 12px;
    }

    .profile-section-heading {
        padding: 20px 18px 10px;
    }

    .compact-person-modal.profile-modal .profile-summary {
        grid-template-columns: 1fr;
        margin: 0 18px 20px;
    }

    .compact-person-modal.profile-modal .profile-summary > div,
    .compact-person-modal.profile-modal .profile-summary > div:nth-child(even) {
        border-right: 0;
        grid-template-columns: minmax(104px, 38%) minmax(0, 1fr);
        padding: 12px 14px;
    }

    .compact-person-modal.profile-modal .profile-summary dt,
    .compact-person-modal.profile-modal .profile-summary dd {
        align-self: start;
    }

    .compact-person-modal.profile-modal .profile-actions {
        padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
    }

    .compact-person-modal.profile-modal .profile-actions .primary-button {
        width: 100%;
    }

    .compact-person-modal.profile-modal .profile-edit-form {
        padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
    }
}
