:root {
    --app-bg: #f5f7f8;
    --surface: #ffffff;
    --surface-muted: #eef3f3;
    --border: #dbe3e6;
    --border-strong: #c4d0d5;
    --text: #17202a;
    --muted: #64737d;
    --accent: #1f9d72;
    --accent-strong: #147a59;
    --accent-soft: #e7f5ef;
    --warning: #b7791f;
    --danger: #b42318;
    --info: #396f87;
    --shadow: 0 12px 30px rgba(23, 32, 42, 0.08);
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--app-bg);
    color: var(--text);
    font-size: 15px;
    letter-spacing: 0;
}

body {
    overflow-y: scroll;
}

a,
.btn-link {
    color: var(--accent-strong);
}

a:hover,
.btn-link:hover {
    color: #0e5f45;
}

h1,
h2,
h3,
h4,
h5 {
    color: var(--text);
    letter-spacing: 0;
}

h1:focus,
h2:focus,
h3:focus {
    outline: none;
}

h1:focus-visible,
h2:focus-visible,
h3:focus-visible {
    border-radius: 6px;
    box-shadow: 0 0 0 0.2rem rgba(31, 157, 114, 0.14);
}

h1 {
    margin: 0 0 1rem;
    font-size: 1.65rem;
    font-weight: 760;
}

h2 {
    margin: 0 0 1rem;
    font-size: 1.35rem;
    font-weight: 720;
}

h3 {
    margin: 0 0 1rem;
    font-size: 1.22rem;
    font-weight: 720;
}

h4 {
    font-size: 1.02rem;
    font-weight: 720;
}

p {
    color: var(--muted);
}

.content > h1:first-child,
.content > h2:first-child,
.content > h3:first-child {
    margin: 0 0 1.15rem;
    padding: 0 0 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}

.content > h1:first-child + h2,
.content > h1:first-child + h3 {
    margin: -0.85rem 0 1.15rem;
    color: var(--muted);
    font-size: 1rem;
    font-weight: 650;
}

.btn {
    --bs-btn-border-radius: 8px;
    min-height: 2.35rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.48rem 0.9rem;
    box-shadow: none;
}

.btn-primary {
    color: #ffffff;
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-primary:hover,
.btn-primary:focus {
    color: #ffffff;
    background: #0e694c;
    border-color: #0e694c;
}

.btn-success {
    color: #ffffff;
    background: #1f8f68;
    border-color: #1f8f68;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
select:focus,
input:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(31, 157, 114, 0.16);
}

.form-container,
.form-wrapper,
.my-custom-form,
.review-card,
.period-table,
.report-section,
.table-responsive {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.form-container,
.form-wrapper,
.my-custom-form {
    width: 100%;
    margin: 0 0 1.5rem;
    padding: 1.45rem;
}

.form-group {
    margin-bottom: 1rem;
}

label,
.form-label {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.35rem;
    color: #34434e;
    font-size: 0.86rem;
    font-weight: 720;
    line-height: 1.25;
}

.form-control,
.form-select,
select,
textarea,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="email"] {
    width: 100%;
    min-height: 2.45rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-size: 0.94rem;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
    min-height: 6rem;
}

select:hover,
.form-control:hover,
input:hover,
textarea:hover {
    border-color: #aebdc4;
}

input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent-strong);
}

.checkbox-group {
    display: grid;
    gap: 0.35rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    margin: 0;
    color: var(--text);
    font-weight: 520;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    color: var(--text);
    font-weight: 520;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.35rem 2rem;
    margin-bottom: 1.2rem;
    align-items: start;
}

.stats-grid .form-group {
    display: grid;
    grid-template-rows: minmax(2.55rem, auto) auto auto;
    align-content: start;
    gap: 0.45rem;
    margin: 0;
}

.stats-grid .form-label {
    display: flex;
    align-items: flex-end;
    min-height: 2.55rem;
    margin: 0;
}

.compact-input {
    display: block;
    width: min(100%, 13rem);
    max-width: 13rem;
    text-align: right;
}

.required-marker {
    color: var(--danger);
    font-size: 0.9rem;
    font-weight: 850;
    line-height: 1;
}

.permissions-page {
    color: #17202a;
}

.permissions-hero {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 249, 250, 0.94)),
        linear-gradient(135deg, rgba(42, 112, 132, 0.14), rgba(101, 130, 88, 0.12));
    border: 1px solid rgba(115, 132, 143, 0.2);
    border-radius: 18px;
    box-shadow: 0 20px 46px rgba(20, 35, 45, 0.08);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1.2rem 1.35rem;
}

.permissions-kicker {
    color: #60707b;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.permissions-hero h1,
.permissions-detail-header h2 {
    color: #16232b;
    font-size: 1.75rem;
    letter-spacing: 0;
    margin: 0.1rem 0 0.25rem;
}

.permissions-hero p,
.permissions-detail-header p {
    color: #60707b;
    margin: 0;
    max-width: 760px;
}

.permissions-status {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(115, 132, 143, 0.18);
    border-radius: 14px;
    display: grid;
    justify-items: center;
    min-width: 140px;
    padding: 0.85rem 1rem;
}

.permissions-status strong {
    color: #1c697d;
    font-size: 1.9rem;
    line-height: 1;
}

.permissions-status span,
.permissions-toolbar-actions span {
    color: #60707b;
    font-size: 0.84rem;
}

.permissions-toolbar {
    align-items: end;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.permissions-role-add {
    max-width: 520px;
    width: 100%;
}

.permissions-role-add-row,
.permissions-toolbar-actions {
    align-items: center;
    display: flex;
    gap: 0.65rem;
}

.permissions-toolbar-actions {
    justify-content: flex-end;
}

.permissions-layout {
    align-items: start;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(230px, 300px) 1fr;
}

.permissions-role-list {
    background: #f8fafb;
    border: 1px solid rgba(115, 132, 143, 0.22);
    border-radius: 14px;
    display: grid;
    gap: 0.35rem;
    padding: 0.45rem;
}

.permissions-role-button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 10px;
    color: #17202a;
    display: flex;
    gap: 0.65rem;
    justify-content: space-between;
    padding: 0.7rem 0.75rem;
    text-align: left;
    width: 100%;
}

.permissions-role-button:hover {
    background: #eef4f5;
}

.permissions-role-button.is-selected {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(20, 35, 45, 0.08);
}

.permissions-role-button strong,
.permission-copy strong {
    display: block;
    font-size: 0.94rem;
}

.permissions-role-button small,
.permission-copy small {
    color: #60707b;
    display: block;
    font-size: 0.78rem;
    line-height: 1.35;
    margin-top: 0.15rem;
}

.permissions-role-button em {
    align-items: center;
    background: #dfeaed;
    border-radius: 999px;
    color: #285665;
    display: inline-flex;
    font-size: 0.78rem;
    font-style: normal;
    font-weight: 800;
    height: 1.65rem;
    justify-content: center;
    min-width: 1.65rem;
}

.permissions-detail {
    background: #ffffff;
    border: 1px solid rgba(115, 132, 143, 0.22);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(20, 35, 45, 0.07);
    min-height: 520px;
    padding: 1rem;
}

.permissions-detail-header {
    align-items: start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

.permissions-lock-note {
    background: #f4f7ef;
    border: 1px solid rgba(101, 130, 88, 0.24);
    border-radius: 10px;
    color: #405640;
    font-size: 0.88rem;
    margin-bottom: 0.9rem;
    padding: 0.75rem 0.85rem;
}

.permissions-section {
    border-top: 1px solid rgba(115, 132, 143, 0.16);
    padding: 0.95rem 0 0.15rem;
}

.permissions-section-title {
    color: #60707b;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 0.6rem;
    text-transform: uppercase;
}

.permissions-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.permission-toggle {
    align-items: center;
    background: #f8fafb;
    border: 1px solid rgba(115, 132, 143, 0.18);
    border-radius: 12px;
    cursor: pointer;
    display: grid;
    gap: 0.7rem;
    grid-template-columns: auto 1fr;
    min-height: 92px;
    padding: 0.8rem;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.permission-toggle:hover {
    background: #f1f6f7;
    transform: translateY(-1px);
}

.permission-toggle input {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.permission-toggle.is-on {
    background: #f2f8f5;
    border-color: rgba(42, 132, 89, 0.28);
}

.permission-toggle.is-locked {
    cursor: default;
}

.permission-toggle.is-locked:hover {
    transform: none;
}

.permission-switch {
    background: #c7d1d6;
    border-radius: 999px;
    display: inline-flex;
    height: 1.65rem;
    padding: 0.18rem;
    width: 2.9rem;
}

.permission-switch::after {
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(20, 35, 45, 0.22);
    content: "";
    height: 1.29rem;
    transform: translateX(0);
    transition: transform 160ms ease;
    width: 1.29rem;
}

.permission-toggle.is-on .permission-switch {
    background: #2a8459;
}

.permission-toggle.is-on .permission-switch::after {
    transform: translateX(1.25rem);
}

.permission-copy {
    min-width: 0;
}

.retention-layout {
    align-items: start;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.retention-panel {
    background: #ffffff;
    border: 1px solid rgba(115, 132, 143, 0.22);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(20, 35, 45, 0.07);
    padding: 1rem;
}

.retention-policy-list,
.retention-recovery-list {
    display: grid;
    gap: 0.65rem;
}

.retention-recovery-toolbar {
    align-items: end;
    border-bottom: 1px solid rgba(115, 132, 143, 0.18);
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(150px, 190px) 1fr;
    margin-bottom: 0.9rem;
    padding-bottom: 0.9rem;
}

.retention-date-filter {
    min-width: 0;
}

.retention-recovery-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.retention-list-limit-note {
    background: #eef5f1;
    border: 1px solid rgba(42, 132, 89, 0.18);
    border-radius: 10px;
    color: #2b5f47;
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.75rem;
}

.retention-policy-row {
    align-items: center;
    background: #f8fafb;
    border: 1px solid rgba(115, 132, 143, 0.18);
    border-radius: 12px;
    display: grid;
    gap: 0.8rem;
    grid-template-columns: minmax(260px, 1fr) minmax(160px, 210px);
    padding: 0.75rem;
}

.retention-policy-row .permission-toggle {
    background: transparent;
    border: 0;
    min-height: auto;
    padding: 0;
}

.retention-policy-row .permission-toggle:hover {
    background: transparent;
    transform: none;
}

.retention-period-field {
    min-width: 0;
}

.retention-months-input {
    align-items: center;
    display: flex;
    gap: 0.5rem;
}

.retention-months-input input {
    max-width: 100px;
}

.retention-months-input span,
.retention-recovery-item small {
    color: #60707b;
    font-size: 0.84rem;
}

.retention-recovery-item {
    align-items: center;
    background: #f8fafb;
    border: 1px solid rgba(115, 132, 143, 0.18);
    border-radius: 12px;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 0.8rem;
}

.retention-recovery-item strong,
.retention-recovery-item small {
    display: block;
}

.legal-search-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    width: 100%;
}

.legal-search-page .permissions-toolbar {
    align-items: stretch;
    flex-direction: column;
}

.legal-search-page .permissions-toolbar-actions {
    align-self: flex-end;
}

.legal-search-field-wide {
    grid-column: span 2;
}

.legal-search-options {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    margin-top: 0.85rem;
}

.legal-result-list {
    display: grid;
    gap: 0.65rem;
}

.audit-page .search-input {
    margin: 0;
}

article.content:has(.audit-page) {
    width: min(100%, 1500px);
}

.audit-page {
    width: 100%;
}

.audit-toolbar,
.audit-retention-panel {
    background: #ffffff;
    border: 1px solid #dbe4ea;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(14, 34, 51, 0.05);
    margin-bottom: 1rem;
    padding: 1rem;
}

.audit-filter-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.audit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.audit-retention-panel {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

.audit-retention-panel strong,
.audit-retention-panel span,
.audit-retention-panel small {
    display: block;
}

.audit-retention-panel span,
.audit-retention-panel small {
    color: var(--muted);
}

.audit-retention-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.audit-retention-controls input {
    width: 110px;
}

.audit-table-wrap {
    background: #ffffff;
    border: 1px solid #dbe4ea;
    border-radius: 8px;
    overflow-x: auto;
}

.audit-table {
    border-collapse: collapse;
    min-width: 0;
    width: 100%;
}

.audit-table th {
    background: #f5f8fa;
    color: #4c5d69;
    font-size: 0.74rem;
    letter-spacing: 0;
    padding: 0.75rem;
    text-align: left;
    text-transform: uppercase;
}

.audit-table td {
    border-top: 1px solid #e7edf1;
    padding: 0.75rem;
    vertical-align: top;
}

.audit-table .audit-time-column {
    min-width: 160px;
    width: 160px;
}

.audit-table td strong,
.audit-table td small {
    display: block;
}

.audit-table td.audit-time-column strong,
.audit-table td.audit-time-column small {
    white-space: nowrap;
}

.audit-table td small {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 0.18rem;
}

.audit-category {
    background: #eef4f7;
    border: 1px solid #d8e4ea;
    border-radius: 999px;
    color: #29465a;
    display: inline-block;
    font-size: 0.78rem;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
}

@media (max-width: 860px) {
    .permissions-hero,
    .permissions-toolbar,
    .permissions-toolbar-actions,
    .permissions-role-add-row,
    .permissions-detail-header {
        align-items: stretch;
        flex-direction: column;
    }

    .permissions-layout {
        grid-template-columns: 1fr;
    }

    .retention-layout,
    .retention-policy-row {
        grid-template-columns: 1fr;
    }

    .legal-search-grid {
        grid-template-columns: 1fr;
    }

    .legal-search-field-wide {
        grid-column: auto;
    }

    .retention-recovery-item {
        align-items: stretch;
        flex-direction: column;
    }

    .retention-recovery-toolbar {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .retention-recovery-actions {
        justify-content: flex-start;
    }
}

/* Letter workflow */

.letter-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(15, 24, 31, 0.42);
    backdrop-filter: blur(14px);
}

.letter-choice-modal {
    width: min(100%, 760px);
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.64);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 24px 80px rgba(16, 28, 36, 0.26);
}

.letter-choice-kicker {
    margin-bottom: 0.25rem;
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.letter-choice-modal h2,
.letter-workspace h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.24rem;
    font-weight: 780;
}

.letter-choice-modal p {
    margin: 0.25rem 0 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.letter-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.letter-choice-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 5rem;
    padding: 0.85rem;
    border: 1px solid #d8e3e4;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.letter-choice-card:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 28px rgba(31, 157, 114, 0.15);
    transform: translateY(-1px);
}

.letter-choice-card--none {
    background: #fbfbfa;
}

.letter-choice-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.45rem;
    height: 2.45rem;
    flex-shrink: 0;
    border-radius: 8px;
    background: #edf7f3;
    color: var(--accent-strong);
}

.letter-choice-card--none .letter-choice-icon {
    background: #f4f1ec;
    color: #846b45;
}

.letter-choice-card strong {
    display: block;
    margin-bottom: 0.12rem;
    font-size: 0.95rem;
    font-weight: 760;
}

.letter-choice-card small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 560;
}

.letter-choice-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.letter-workspace {
    position: relative;
    padding: 1.15rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 4px 18px rgba(23, 32, 42, 0.07);
}

.letter-workspace.is-submitting {
    overflow: hidden;
}

.letter-saving-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(2px);
    color: var(--text);
    text-align: left;
}

.letter-saving-overlay span:last-child,
.form-submit-status-card span:last-child {
    display: grid;
    gap: 0.16rem;
}

.letter-saving-overlay strong,
.form-submit-status-card strong {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 780;
}

.letter-saving-overlay small,
.form-submit-status-card small {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
}

.letter-workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.95rem;
    border-bottom: 1px solid var(--border);
}

.letter-fields-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.95rem 1rem;
}

.letter-field {
    min-width: 0;
}

.letter-field--wide {
    grid-column: 1 / -1;
}

.letter-textarea {
    min-height: 8rem;
    resize: vertical;
}

.letter-field-help {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 560;
    line-height: 1.4;
}

.letter-preview-file {
    display: block;
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 560;
}

.letter-preview-frame-shell {
    width: 100%;
    height: min(76vh, 780px);
    min-height: 34rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #eef2f1;
}

.letter-preview-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

.letter-preview-actions {
    justify-content: flex-end;
}

.letter-preview-error {
    margin-top: 1rem;
    margin-bottom: 0;
}

.form-submit-status-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid #cde8dc;
    border-radius: 8px;
    background: #f1faf6;
    box-shadow: 0 8px 26px rgba(23, 32, 42, 0.06);
}

.loading-spinner {
    width: 1.35rem;
    height: 1.35rem;
    display: inline-block;
    flex: 0 0 auto;
    border: 3px solid rgba(31, 157, 114, 0.18);
    border-top-color: var(--accent-strong);
    border-radius: 50%;
    animation: loading-spin 0.75s linear infinite;
}

.loading-spinner--button {
    width: 0.95rem;
    height: 0.95rem;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.36);
    border-top-color: #ffffff;
}

.btn-with-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.submit-panel-status {
    color: var(--muted);
    font-size: 0.88rem;
}

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.cqi-date-field {
    display: grid;
    gap: 0.25rem;
}

.cqi-date-help {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 520;
}

.my-custom-form {
    position: relative;
    overflow: hidden;
}

.my-custom-form::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 0.18rem;
    background: linear-gradient(90deg, var(--accent-strong), #62b99b);
}

.my-custom-form .form-group:first-child {
    margin-bottom: 1.7rem;
}

.my-custom-form textarea.form-control {
    min-height: 7.5rem;
}

@media (max-width: 980px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .letter-choice-grid,
    .letter-fields-grid {
        grid-template-columns: 1fr;
    }

    .letter-workspace-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .letter-choice-card {
        min-height: 4.6rem;
    }

    .letter-preview-frame-shell {
        height: 68vh;
        min-height: 26rem;
    }
}

.cqi-draft-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: -0.2rem 0 1rem;
    padding: 0.8rem 0.95rem;
    border: 1px solid #cde8dc;
    border-radius: 8px;
    background: #f3fbf7;
    color: var(--text);
}

.cqi-draft-panel.is-muted {
    background: var(--surface);
    border-color: var(--border);
}

.cqi-draft-copy {
    display: grid;
    gap: 0.1rem;
}

.cqi-draft-copy strong {
    color: var(--accent-strong);
    font-size: 0.9rem;
}

.cqi-draft-copy span {
    color: var(--muted);
    font-size: 0.84rem;
}

.cqi-draft-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cqi-draft-actions .btn {
    min-height: 2rem;
    padding: 0.32rem 0.7rem;
}

.selection-group {
    display: grid;
    gap: 0.6rem;
}

.selection-title {
    margin: 0;
    color: #34434e;
    font-size: 0.86rem;
    font-weight: 760;
}

.selection-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.selection-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.15rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #ffffff;
    color: var(--text);
    font-weight: 650;
}

.selection-chip-status {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0.08rem 0.38rem;
    border-radius: 999px;
    background: #edf0f1;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.global-report-facility-filter {
    width: fit-content;
    cursor: pointer;
}

.global-report-scope {
    margin-top: 1rem;
    margin-bottom: 0;
}

.facility-check-list {
    display: grid;
    gap: 0.55rem;
}

.facility-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.45rem;
    max-height: 15rem;
    overflow: auto;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafb;
}

.builder-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.builder-error {
    color: var(--danger);
    font-weight: 700;
}

.text-danger,
.validation-message {
    color: var(--danger) !important;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--accent);
}

.invalid {
    outline: 1px solid var(--danger);
}

.table,
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text);
}

.table {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.table th,
.table td,
table th,
table td {
    padding: 0.72rem 0.78rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th,
table th {
    color: #3a4954;
    background: #eef3f3;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

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

.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: #fafcfc;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: var(--accent-soft);
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.review-card {
    padding: 1rem;
}

.review-card h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.review-card p {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 0.9rem;
}

.review-card p:last-of-type {
    border-bottom: 0;
}

.submit-wrapper {
    margin-top: 1.25rem;
    display: flex;
    justify-content: flex-end;
}

.period-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.period-table {
    overflow: hidden;
}

.period-table h5 {
    margin: 0;
    padding: 0.75rem 1rem;
    background: #263431;
    color: #ffffff;
    font-size: 0.92rem;
}

.report-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: flex-end;
    margin: -0.25rem 0 1rem;
}

.report-info div {
    color: var(--muted);
}

.report-empty-state,
.report-empty-section {
    border: 1px solid #cfe0de;
    border-radius: 8px;
    background: #f8fbfb;
    color: var(--muted);
}

.report-empty-state {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    margin: 1rem 0 1.4rem;
    padding: 1rem;
    box-shadow: var(--shadow);
}

.report-empty-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 850;
}

.report-empty-state h3 {
    margin: 0 0 0.25rem;
    color: var(--text);
    font-size: 1rem;
}

.report-empty-state p {
    margin: 0;
    color: var(--muted);
}

.report-empty-section {
    padding: 0.9rem 1rem;
}

.report-section {
    margin-bottom: 1.25rem;
    padding: 1rem;
}

.report-section h4,
.section-header {
    margin: 0 0 0.85rem;
    padding: 0;
    background: transparent;
    color: var(--text);
    border-radius: 0;
}

.page-title {
    text-align: left;
    color: var(--text);
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.report-card,
.period-card,
.checkbox-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.report-card,
.period-card {
    padding: 1rem;
    overflow: hidden;
}

.report-card h4,
.period-card h5 {
    margin: 0 0 0.8rem;
    color: var(--text);
    font-weight: 760;
}

.checkbox-section {
    margin-bottom: 1rem;
    padding: 1rem;
}

.checkbox-section h4 {
    margin-bottom: 0.7rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.65rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-input {
    width: min(100%, 24rem);
    min-height: 2.4rem;
    margin: 0 0.5rem 1rem 0;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.92rem;
}

.jailstats-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 0.88rem;
}

.jailstats-table th,
.jailstats-table td {
    padding: 0.65rem 0.72rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.jailstats-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #eef3f3;
    color: #34434e;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.jailstats-table tr:nth-child(even) td {
    background: #fafcfc;
}

.jailstats-table tr:hover td {
    background: var(--accent-soft);
}

.actions-cell a {
    margin-right: 0.35rem;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.filter-field {
    display: grid;
    gap: 0.35rem;
}

.disabled-action {
    color: #7b878d;
    cursor: not-allowed;
}

/* Facilities Admin */

.facilities-page {
    display: grid;
    gap: 1rem;
}

article.content:has(.facilities-page) {
    width: min(100%, 1320px);
}

.facilities-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0 0 1rem;
    border-bottom: 1px solid var(--border);
}

.facilities-kicker {
    margin-bottom: 0.2rem;
    color: var(--accent-strong);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.facilities-hero h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.08;
}

.facilities-hero p {
    max-width: 52rem;
    margin: 0.35rem 0 0;
}

.facilities-create-action {
    flex: 0 0 auto;
}

.facilities-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 0.75rem;
}

.facilities-summary > div,
.facilities-policy,
.facilities-toolbar,
.facilities-table-shell {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.facilities-summary > div {
    padding: 0.85rem 0.95rem;
}

.facilities-summary span,
.facility-result-count label {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.facilities-summary strong,
.facility-result-count span {
    display: block;
    margin-top: 0.2rem;
    color: var(--text);
    font-size: 1.55rem;
    font-weight: 820;
    line-height: 1.05;
}

.facilities-policy {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.78rem 0.95rem;
    background: #f8fbfb;
}

.facilities-policy strong {
    color: var(--text);
    white-space: nowrap;
}

.facilities-policy span {
    color: var(--muted);
}

.facilities-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem;
}

.facility-search {
    display: grid;
    gap: 0.35rem;
    width: min(100%, 32rem);
}

.facility-search label {
    margin: 0;
}

.facility-result-count {
    min-width: 5.5rem;
    text-align: right;
}

.facilities-table-shell {
    overflow: hidden;
}

.facilities-table {
    width: 100%;
    margin: 0;
    min-width: 0;
    table-layout: fixed;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.facilities-table th,
.facilities-table td {
    padding: 0.65rem 0.5rem;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.facilities-table th {
    white-space: nowrap;
}

.facilities-table th:nth-child(1) { width: 18%; }
.facilities-table th:nth-child(2) { width: 22%; }
.facilities-table th:nth-child(3) { width: 10%; }
.facilities-table th:nth-child(4) { width: 13%; }
.facilities-table th:nth-child(5) { width: 18%; }
.facilities-table th:nth-child(6) { width: 11%; }
.facilities-table th:nth-child(7) { width: 8%; }

.facilities-table th:nth-child(3) .col-title-text,
.facilities-table th:nth-child(5) .col-title-text,
.facilities-table th:nth-child(6) .col-title-text,
.facilities-table th:nth-child(7) .col-title-text {
    overflow: visible;
    text-overflow: clip;
}

.facilities-table td:nth-child(3),
.facilities-table td:nth-child(6),
.facilities-table td:nth-child(7) {
    overflow-wrap: normal;
}

.facilities-table th button {
    color: inherit;
    font: inherit;
    text-transform: inherit;
}

.facility-cadence-control {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 10.5rem;
    padding: 0.18rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #f5f8f8;
}

.facility-cadence-option {
    min-height: 2rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 760;
    cursor: pointer;
}

.facility-cadence-option:hover {
    color: var(--accent-strong);
    background: #eaf5f0;
}

.facility-cadence-option.is-selected {
    background: var(--accent-strong);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(23, 32, 42, 0.16);
}

.facility-status-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.25rem 0.6rem 0.25rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8faf9;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 760;
    white-space: nowrap;
}

.facility-status-toggle input {
    margin: 0;
}

.facility-linked-name {
    display: inline-block;
    max-width: 15rem;
    color: var(--text);
    padding-inline: 0.25rem;
    font-size: 0.76rem;
    font-weight: 720;
}

.facility-linked-name--none {
    color: var(--muted);
    font-weight: 600;
}

.facility-table-name,
.facility-table-location,
.facility-table-meta {
    display: block;
}

.facility-table-name {
    line-height: 1.2;
}

.facility-table-meta {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

.facility-edit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.25rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 760;
    text-decoration: none;
    white-space: nowrap;
}

.facility-edit-link:hover {
    border-color: #b8d8cc;
    background: var(--accent-soft);
    color: #0e5f45;
}

dl.row {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

dl.row dt,
dl.row dd {
    margin: 0;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

dl.row dt {
    color: #34434e;
    background: #f8faf9;
    font-weight: 760;
}

/* ===== Nav Icons & Chevron ===== */

.nav-item-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.82;
    margin-right: 0.45rem;
    vertical-align: -0.15em;
}

.nav-link .nav-item-icon {
    opacity: 0.72;
    transition: opacity 0.15s;
}

.nav-link:hover .nav-item-icon,
.nav-link.active .nav-item-icon {
    opacity: 1;
}

.nav-section-toggle .nav-item-icon {
    opacity: 0.75;
}

.nav-chevron {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    margin-left: auto;
    opacity: 0.6;
    transition: transform 0.22s ease, opacity 0.15s;
}

.nav-chevron.is-expanded {
    transform: rotate(180deg);
    opacity: 1;
}

.nav-section-toggle {
    display: flex;
    align-items: center;
}

/* ===== Form Page Hero ===== */

.form-page-hero {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-strong) 0%, #1a8863 55%, #145f45 100%);
    border-radius: 10px;
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(20, 122, 89, 0.28);
}

.form-page-hero--minutes {
    background: linear-gradient(135deg, #1a4f7a 0%, #1e6b9e 55%, #174f76 100%);
    box-shadow: 0 4px 20px rgba(26, 79, 122, 0.28);
}

.form-page-hero--site-visit {
    background: linear-gradient(135deg, #35574f 0%, #517a6c 55%, #263f39 100%);
    box-shadow: 0 4px 20px rgba(53, 87, 79, 0.26);
}

.form-page-hero-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.6rem;
    height: 3.6rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.form-page-hero h1 {
    margin: 0 0 0.18rem;
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 760;
    letter-spacing: -0.01em;
}

.form-page-hero p {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.87rem;
    font-weight: 450;
}

/* ===== Document Forms ===== */

.form-section-header {
    margin: 1.35rem 0 0.75rem;
    padding: 0.48rem 0.75rem;
    background: var(--surface-muted);
    border-left: 3px solid var(--accent-strong);
    border-radius: 0 6px 6px 0;
    color: var(--text);
    font-size: 0.93rem;
    font-weight: 760;
}

.inline-check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.1rem;
    align-items: center;
}

.check-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 520;
    cursor: pointer;
    user-select: none;
}

.check-item input[type="checkbox"],
.check-item input[type="radio"] {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent-strong);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
    margin-bottom: 0.75rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem 1.5rem;
    margin-bottom: 0.75rem;
}

.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem 1rem;
}

.action-items-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.action-items-table th {
    background: var(--surface-muted);
    color: #3a4954;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.action-items-table td {
    padding: 0.3rem 0.45rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.action-items-table tr:last-child td {
    border-bottom: 0;
}

.action-items-table .form-control {
    min-height: 2rem;
    padding: 0.28rem 0.5rem;
    font-size: 0.88rem;
    border-radius: 6px;
}

.btn-add-row {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.72rem;
    border: 1.5px dashed var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.4;
}

.btn-add-row:hover {
    background: var(--accent-soft);
    border-color: var(--accent-strong);
    color: var(--accent-strong);
}

.btn-remove-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    border: 1px solid #f3c4c4;
    border-radius: 6px;
    background: #fff7f7;
    color: var(--danger);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
    padding: 0;
}

.btn-remove-row:hover {
    background: #ffe4e4;
    border-color: var(--danger);
}

.add-row-footer {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    background: var(--surface-muted);
}

.dynamic-item-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.dynamic-item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.85rem;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
}

.dynamic-item-label {
    font-size: 0.8rem;
    font-weight: 760;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.dynamic-item-card-body {
    padding: 0.85rem 0.85rem 0.35rem;
}

.site-visit-checklist {
    display: grid;
    gap: 0.65rem;
}

.site-visit-checklist-row {
    display: grid;
    grid-template-columns: minmax(13rem, 1.2fr) minmax(12rem, 0.9fr) minmax(16rem, 1.6fr);
    gap: 0.75rem;
    align-items: start;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfdfc;
}

.site-visit-checklist-label {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 720;
    line-height: 1.35;
}

.site-visit-checklist-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.8rem;
    min-height: 2rem;
    align-items: center;
}

.meeting-section-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.meeting-section-block .section-title-bar {
    padding: 0.5rem 0.85rem;
    background: #2d3e39;
    color: #e8f5f1;
    font-size: 0.82rem;
    font-weight: 760;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.meeting-section-block .section-body {
    padding: 0.85rem 0.85rem 0.35rem;
}

.submit-panel {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.draft-save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 550;
}

.draft-saving-pulse {
    font-size: 0.8rem;
    color: var(--accent-strong);
    font-weight: 650;
    animation: draft-pulse 1.2s ease-in-out infinite;
}

@keyframes draft-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

.success-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid #a3d9c3;
    border-radius: 8px;
    background: #f0faf6;
    color: var(--text);
    flex-wrap: wrap;
}

.success-banner strong {
    color: var(--accent-strong);
}

.alert-danger-panel {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    background: #fff5f5;
    color: var(--danger);
    font-size: 0.9rem;
}

/* ── Form Repository ── */

.form-repo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.85rem;
}

.form-repo-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(23, 32, 42, 0.06);
    padding: 1rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-repo-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(31, 157, 114, 0.12);
}

.form-repo-card.is-voided {
    border-color: #d8c8c8;
    background: #fbf8f8;
    opacity: 0.82;
}

.form-repo-card-type {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.71rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--accent-strong);
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

.form-repo-card-name {
    font-size: 0.92rem;
    font-weight: 720;
    color: var(--text);
    margin-bottom: 0.15rem;
    line-height: 1.35;
}

.form-repo-card-meta {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.7rem;
}

.repo-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.repo-void-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.42rem;
    border-radius: 999px;
    background: #f3d7d7;
    color: #8b2424;
    font-size: 0.66rem;
    font-weight: 850;
}

.repo-void-meta {
    display: block;
    margin-top: 0.3rem;
    color: #8b4b4b;
    font-weight: 650;
}

.repo-void-toggle {
    min-height: 2.35rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.repo-void-button {
    min-height: 2rem;
    padding: 0.32rem 0.72rem;
    color: #8b2424;
    border-color: #e4b8b8;
}

.repo-void-button:hover,
.repo-void-confirm {
    background: #8b2424;
    border-color: #8b2424;
    color: #ffffff;
}

.void-form-dialog {
    width: min(100%, 540px);
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.64);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 24px 80px rgba(16, 28, 36, 0.26);
}

.void-form-dialog h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 780;
}

.void-form-dialog p {
    margin: 0.35rem 0 1rem;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.35;
}

.void-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.repo-state-group {
    margin-bottom: 1.5rem;
}

.repo-state-group > summary,
.repo-facility-group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.repo-state-group > summary::-webkit-details-marker,
.repo-facility-group > summary::-webkit-details-marker {
    display: none;
}

.repo-state-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.85rem;
    padding: 0.6rem 0.9rem;
    background: var(--text);
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 760;
}

.repo-state-header::before,
.repo-facility-header::before {
    content: "";
    width: 0;
    height: 0;
    margin-right: 0.55rem;
    border-style: solid;
    border-width: 4px 0 4px 6px;
    border-color: transparent transparent transparent currentColor;
    transition: transform 0.16s ease;
}

.repo-state-group[open] > .repo-state-header::before,
.repo-facility-group[open] > .repo-facility-header::before {
    transform: rotate(90deg);
}

.repo-state-group:not([open]) > .repo-state-header,
.repo-facility-group:not([open]) > .repo-facility-header {
    margin-bottom: 0;
}

.repo-state-header:focus-visible,
.repo-facility-header:focus-visible {
    outline: 3px solid rgba(31, 157, 114, 0.22);
    outline-offset: 2px;
}

.repo-count-badge {
    margin-left: auto;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    color: #e8f5f1;
    font-size: 0.76rem;
    font-weight: 700;
}

.repo-count-badge--facility {
    background: var(--surface-muted);
    color: var(--muted);
}

.repo-facility-group {
    margin-bottom: 1rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border-strong);
}

.repo-facility-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
    font-weight: 720;
    color: var(--text);
}

.repo-form-group {
    margin-bottom: 0.85rem;
    padding-left: 0.75rem;
}

.repo-form-type-label {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

/* Admin Settings */

.settings-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1.1rem 1.25rem;
    border-radius: 8px;
    background: #123d4b;
    color: #ffffff;
}

.settings-hero h1 {
    margin: 0 0 0.2rem;
    color: #ffffff;
    font-size: 1.35rem;
}

.settings-hero p {
    margin: 0;
    color: #d8f0e8;
}

.settings-form {
    max-width: none;
}

.clinical-check-in-attempt-option {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.5rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid #cdd7dc;
    border-radius: 8px;
    background: #f7fafb;
    color: #17202a;
    font-weight: 650;
    cursor: pointer;
}

.clinical-check-in-attempt-option .form-check-input {
    margin: 0;
}

.settings-recipient-box {
    min-height: 12rem;
}

.settings-help {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.app-file-input {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    padding: 0.35rem;
}

.app-file-input::file-selector-button {
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    padding: 0.55rem 0.85rem;
    margin-right: 0.75rem;
    cursor: pointer;
}

.app-file-input:hover::file-selector-button {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.settings-preview {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.25rem;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: #dff5ea;
    color: #146c43;
    font-size: 0.84rem;
    font-weight: 700;
}

/* CQI Tracker */

.form-page-hero--tracker {
    background: linear-gradient(135deg, #123d4b, #1f9d72);
}

.form-page-hero--site-visit-tracker {
    background: linear-gradient(135deg, #102f3a, #247c78);
}

article.content:has(.tracker-page) {
    width: min(100%, 1500px);
}

article.content:has(.dashboard-plane) {
    width: min(100%, 1560px);
}

article.content:has(.onboarding-tracker-page) {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 1rem 1rem 2rem;
}

.tracker-page {
    width: 100%;
}

.tracker-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1.6fr) minmax(160px, 0.7fr) minmax(180px, 0.8fr) auto;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 0.9rem;
}

.tracker-toolbar-actions {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    padding-bottom: 1rem;
}

.tracker-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}

.tracker-summary > div {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.75rem 0.85rem;
}

.tracker-summary strong {
    display: block;
    font-size: 1.3rem;
    line-height: 1.1;
    color: var(--text);
}

.tracker-summary span {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tracker-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.tracker-table {
    width: 100%;
    min-width: 1040px;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.tracker-table--site-visits {
    min-width: 1220px;
}

.tracker-table th,
.tracker-table td {
    padding: 0.62rem 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.tracker-table th {
    background: #f6f8f9;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.tracker-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}

.tracker-sort-button:hover {
    color: var(--accent-strong);
}

.tracker-sort-indicator {
    color: var(--accent-strong);
    font-size: 0.65rem;
    font-weight: 900;
}

.tracker-table tbody tr:last-child td {
    border-bottom: 0;
}

.tracker-row--overdue {
    background: #fff7f7;
}

.tracker-row--critical {
    background: #fffaf0;
}

.tracker-subtext {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.74rem;
}

.tracker-comment-cell {
    min-width: 260px;
}

.tracker-rnm-cell {
    min-width: 170px;
}

.tracker-rnm-input {
    width: 100%;
    min-height: 2.1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
    color: var(--text);
    background: #ffffff;
}

.tracker-comment {
    width: 100%;
    min-height: 76px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem;
    color: var(--text);
    background: #ffffff;
}

.tracker-inline-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.4rem;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 700;
}

.due-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    border-radius: 999px;
    padding: 0.18rem 0.52rem;
    font-size: 0.76rem;
    font-weight: 800;
    background: #eef2f4;
    color: var(--muted);
}

.due-pill--overdue,
.due-pill--critical {
    background: #ffe2e2;
    color: #9f1f1f;
}

.due-pill--warning {
    background: #fff0ca;
    color: #7a4a00;
}

.due-pill--caution {
    background: #eaf5ff;
    color: #135a8a;
}

.due-pill--current {
    background: #dff5ea;
    color: #146c43;
}

.tracker-history-panel {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(23, 32, 42, 0.06);
}

.tracker-history-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(15, 24, 31, 0.42);
    backdrop-filter: blur(10px);
}

.tracker-history-panel--modal {
    display: flex;
    flex-direction: column;
    width: min(100%, 860px);
    max-height: calc(100vh - 2.5rem);
    margin-top: 0;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(16, 28, 36, 0.26);
}

.tracker-history-modal-body {
    min-height: 0;
    overflow-y: auto;
}

.tracker-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f6f8f9;
}

.tracker-history-header h2 {
    margin: 0 0 0.15rem;
    font-size: 1rem;
    color: var(--text);
}

.tracker-history-header span,
.tracker-history-empty {
    color: var(--muted);
    font-size: 0.82rem;
}

.tracker-history-empty {
    padding: 1rem;
}

.tracker-history-list {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
}

.tracker-history-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem;
    background: #ffffff;
}

.tracker-history-item-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.35rem;
}

.tracker-history-item-head strong {
    color: var(--text);
}

.tracker-history-item-head span,
.tracker-history-meta {
    color: var(--muted);
    font-size: 0.78rem;
}

.tracker-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.8rem;
    margin-bottom: 0.65rem;
}

.tracker-history-change {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.tracker-history-change label {
    margin-bottom: 0.2rem;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tracker-history-change p,
.tracker-history-comment {
    margin: 0;
    padding: 0.55rem;
    border-radius: 8px;
    background: #f6f8f9;
    color: var(--text);
    white-space: pre-wrap;
}

.tracker-history-comment {
    margin-top: 0.65rem;
}

@media (max-width: 860px) {
    .form-row-2,
    .form-row-3,
    .form-row-4,
    .site-visit-checklist-row,
    .tracker-toolbar,
    .tracker-summary,
    .tracker-history-change {
        grid-template-columns: 1fr;
    }

    .tracker-history-modal-backdrop {
        align-items: stretch;
        padding: 0.75rem;
    }

    .tracker-history-panel--modal {
        width: 100%;
        max-height: calc(100vh - 1.5rem);
    }

    .tracker-history-header {
        align-items: flex-start;
    }
}

/* ===== End Document Forms ===== */

.blazor-error-boundary {
    background: #fff4ed;
    border: 1px solid #fed7c3;
    border-radius: 8px;
    padding: 1rem;
    color: #7a2e13;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

@media (max-width: 700px) {
    html,
    body {
        font-size: 14px;
    }

    .form-container,
    .form-wrapper,
    .my-custom-form,
    .report-section {
        padding: 1rem;
    }

    .facilities-hero,
    .facilities-policy,
    .facilities-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

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

    .facility-result-count {
        text-align: left;
    }

    .facilities-table-shell {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

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

    .facilities-table {
        background: transparent;
    }

    .facilities-table thead {
        display: none;
    }

    .facilities-table tbody {
        display: grid;
        gap: 0.75rem;
    }

    .facilities-table tbody tr {
        padding: 0.5rem 0.75rem;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--surface);
        box-shadow: var(--shadow);
    }

    .facilities-table tbody td {
        display: grid;
        grid-template-columns: 7rem minmax(0, 1fr);
        align-items: center;
        gap: 0.65rem;
        padding: 0.45rem 0;
        border: 0;
    }

    .facilities-table tbody td::before {
        color: var(--muted);
        font-size: 0.68rem;
        font-weight: 800;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    .facilities-table tbody td:nth-child(1)::before { content: "Facility"; }
    .facilities-table tbody td:nth-child(2)::before { content: "Location"; }
    .facilities-table tbody td:nth-child(3)::before { content: "Region"; }
    .facilities-table tbody td:nth-child(4)::before { content: "Linked"; }
    .facilities-table tbody td:nth-child(5)::before { content: "CQI Schedule"; }
    .facilities-table tbody td:nth-child(6)::before { content: "Status"; }
    .facilities-table tbody td:nth-child(7)::before { content: "Actions"; }

    .facility-cadence-control {
        max-width: 11rem;
    }

    .submit-wrapper {
        justify-content: stretch;
    }

    .submit-wrapper .btn {
        width: 100%;
    }
}
/* Med Ops daily-focus hover card (appended to <body> so table scrolling cannot clip it). */
.medops-focus-tooltip {
    position: fixed;
    z-index: 1100;
    width: min(360px, calc(100vw - 24px));
    padding: 14px 16px 15px;
    border: 1px solid rgba(19, 72, 86, 0.2);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 16px 40px rgba(15, 38, 46, 0.18), 0 3px 10px rgba(15, 38, 46, 0.1);
    color: #18343d;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px) scale(0.985);
    transform-origin: bottom center;
    transition: opacity 120ms ease, transform 120ms ease;
    visibility: hidden;
}

.medops-focus-tooltip::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 11px;
    height: 11px;
    border-right: 1px solid rgba(19, 72, 86, 0.2);
    border-bottom: 1px solid rgba(19, 72, 86, 0.2);
    background: #ffffff;
    transform: translateX(-50%) rotate(45deg);
}

.medops-focus-tooltip.is-below {
    transform-origin: top center;
}

.medops-focus-tooltip.is-below::after {
    top: -6px;
    bottom: auto;
    border: 0;
    border-top: 1px solid rgba(19, 72, 86, 0.2);
    border-left: 1px solid rgba(19, 72, 86, 0.2);
}

.medops-focus-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

.medops-focus-tooltip__eyebrow {
    margin-bottom: 5px;
    color: #19708a;
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.medops-focus-tooltip__title {
    color: #123b47;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.3;
}

.medops-focus-tooltip__metadata {
    margin-top: 5px;
    color: #62757c;
    font-size: 0.74rem;
    line-height: 1.35;
}

.medops-focus-tooltip__activity {
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid #e6edef;
    color: #344f58;
    font-size: 0.79rem;
    line-height: 1.45;
}
