﻿/* =========================================================
   Diamond Billing Ã¢â¬â Custom Stylesheet
   ========================================================= */

:root {
    --db-primary:       #1a56db;
    --db-primary-dark:  #1042a8;
    --db-primary-light: #e8f0fe;
    --db-sidebar-bg:    #ffffff;
    --db-sidebar-w:     260px;
    --db-topbar-h:      60px;
    --db-text-muted:    #64748b;
    --db-border:        #e2e8f0;
    --db-surface:       #f8fafc;
    --db-card-shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --db-radius:        10px;
}

/* Ã¢ââ¬Ã¢ââ¬ Reset / Base Ã¢ââ¬Ã¢ââ¬ */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--db-surface);
    color: #1e293b;
    min-height: 100vh;
}

a { color: var(--db-primary); text-decoration: none; }
a:hover { color: var(--db-primary-dark); text-decoration: none; }

/* Ã¢ââ¬Ã¢ââ¬ Auth Pages (no sidebar) Ã¢ââ¬Ã¢ââ¬ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 2rem;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, .08);
    border: 1px solid #e2e8f0;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 2rem;
    font-weight: 700;
    font-size: 1.4rem;
    color: #0f172a;
}

.auth-logo .logo-gem {
    font-size: 1.8rem;
    line-height: 1;
}

.auth-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: .4rem;
    color: #0f172a;
}

.auth-card .subtitle {
    color: var(--db-text-muted);
    margin-bottom: 1.8rem;
    font-size: .9rem;
}

/* Auth card form labels & inputs Ã¢â¬â normal dark on white */
.auth-card .form-label {
    color: #374151;
}

.auth-card .form-control {
    background: #fff;
    border-color: var(--db-border);
    color: #1e293b;
}

.auth-card .form-control::placeholder {
    color: #94a3b8;
}

.auth-card .form-control:focus {
    background: #fff;
    border-color: var(--db-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
    color: #1e293b;
}

.auth-card .btn-primary {
    background: var(--db-primary);
    border-color: var(--db-primary);
    color: #fff;
    font-weight: 700;
}

.auth-card .btn-primary:hover {
    background: var(--db-primary-dark);
    border-color: var(--db-primary-dark);
    color: #fff;
}

.auth-card .text-danger {
    color: #dc2626 !important;
    font-size: .8rem;
}

.auth-card .db-alert.danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

/* Hide empty validation summary (no errors) Ã¢â¬â ASP.NET adds this class when ModelState is valid */
.auth-card .validation-summary-valid {
    display: none !important;
}

/* Flash popup dialog (global errors / success) */
.db-flash-dialog {
    border: none;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
}
.db-flash-dialog .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #0f172a;
}
.db-flash-message {
    color: #334155;
    font-size: .95rem;
    line-height: 1.45;
}
.db-flash-error .modal-header {
    border-left: 4px solid #dc2626;
    padding-left: 1rem;
}
.db-flash-success .modal-header {
    border-left: 4px solid #16a34a;
    padding-left: 1rem;
}
.db-flash-warning .modal-header {
    border-left: 4px solid #d97706;
    padding-left: 1rem;
}
.db-flash-info .modal-header {
    border-left: 4px solid #2563eb;
    padding-left: 1rem;
}

/* Centered confirm dialog (replaces native window.confirm) */
.db-confirm-dialog {
    border: none;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
}
.db-confirm-dialog .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #0f172a;
}
.db-confirm-message {
    color: #334155;
    font-size: .95rem;
    line-height: 1.45;
}
.db-confirm-dialog .modal-header {
    border-left: 4px solid #2563eb;
    padding-left: 1rem;
}
.db-confirm-danger .modal-header {
    border-left-color: #dc2626;
}

/* Keep confirm / flash dialogs above page content; never raise backdrop above the dialog */
#dbConfirmModal,
#dbFlashModal {
    z-index: 1100;
}


.auth-card .form-check-input {
    border-color: var(--db-border);
}

.auth-card .form-check-label {
    color: #374151;
}

/* Ã¢ââ¬Ã¢ââ¬ App Shell Ã¢ââ¬Ã¢ââ¬ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Ã¢ââ¬Ã¢ââ¬ Sidebar Ã¢ââ¬Ã¢ââ¬ */
.sidebar {
    width: var(--db-sidebar-w);
    background: var(--db-sidebar-bg);
    border-right: 1px solid var(--db-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--db-border);
    text-decoration: none;
}

.sidebar-brand .brand-gem {
    font-size: 1.6rem;
    line-height: 1;
}

.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--db-primary);
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    font-size: .7rem;
    color: var(--db-text-muted);
    font-weight: 400;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-section {
    padding: .4rem 1.5rem .2rem;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #94a3b8;
    margin-top: .6rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.5rem;
    color: #475569;
    font-size: .875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s ease;
    text-decoration: none;
}

.sidebar-link:hover {
    color: var(--db-primary);
    background: var(--db-primary-light);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--db-primary);
    background: var(--db-primary-light);
    border-left-color: var(--db-primary);
    font-weight: 600;
}

.sidebar-link .nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--db-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}

.sidebar-profile {
    position: relative;
    margin-bottom: .75rem;
}

.sidebar-user-btn {
    width: 100%;
    border: none;
    background: transparent;
    padding: .35rem .25rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    margin-bottom: 0;
}

.sidebar-user-btn:hover {
    background: #f1f5f9;
}

.profile-caret {
    margin-left: auto;
    color: #94a3b8;
    font-size: .75rem;
}

.profile-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + .4rem);
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    padding: .45rem;
    z-index: 40;
}

.profile-dropdown-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    padding: .35rem .55rem .2rem;
}

.profile-dropdown-item {
    display: block;
    padding: .55rem .65rem;
    border-radius: 7px;
    color: #0f172a;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
}

.profile-dropdown-item:hover,
.profile-dropdown-item.active {
    background: #eff6ff;
    color: #1d4ed8;
}

.invite-instructions {
    margin-top: .85rem;
    text-align: left;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: .9rem 1rem;
}

.invite-instructions-title {
    font-weight: 600;
    font-size: .9rem;
    color: #0f172a;
    margin-bottom: .35rem;
}

.invite-instructions ul {
    margin: 0;
    padding-left: 1.15rem;
    font-size: .84rem;
    color: #475569;
    line-height: 1.65;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--db-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info .user-name {
    font-size: .825rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.2;
}

.user-info .user-role {
    font-size: .72rem;
    color: var(--db-text-muted);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .45rem .75rem;
    background: #f8fafc;
    border: 1px solid var(--db-border);
    border-radius: 8px;
    color: #475569;
    font-size: .825rem;
    cursor: pointer;
    transition: all .15s;
}

.btn-logout:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
}

/* Ã¢ââ¬Ã¢ââ¬ Main Content Ã¢ââ¬Ã¢ââ¬ */
.main-content {
    margin-left: var(--db-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Ã¢ââ¬Ã¢ââ¬ Top Bar Ã¢ââ¬Ã¢ââ¬ */
.topbar {
    height: var(--db-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--db-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Page Content Ã¢ââ¬Ã¢ââ¬ */
.page-content {
    padding: 1.75rem;
    flex: 1;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: .25rem;
}

.page-header p {
    color: var(--db-text-muted);
    margin: 0;
    font-size: .9rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Cards Ã¢ââ¬Ã¢ââ¬ */
.db-card {
    background: #fff;
    border-radius: var(--db-radius);
    border: 1px solid var(--db-border);
    box-shadow: var(--db-card-shadow);
    overflow: hidden;
}

.db-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--db-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.db-card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
}

.db-card-body {
    padding: 1.25rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Stats Cards (Dashboard) Ã¢ââ¬Ã¢ââ¬ */
.stat-card {
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    padding: 1.25rem;
    box-shadow: var(--db-card-shadow);
    transition: box-shadow .2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: .85rem;
}

.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.purple { background: #ede9fe; }
.stat-icon.orange { background: #ffedd5; }

.stat-label {
    font-size: .78rem;
    color: var(--db-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: .25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

/* Ã¢ââ¬Ã¢ââ¬ Tables Ã¢ââ¬Ã¢ââ¬ */
.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.db-table thead tr {
    border-bottom: 2px solid var(--db-border);
}

.db-table thead th {
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--db-text-muted);
    white-space: nowrap;
    background: var(--db-surface);
}

.db-table tbody tr {
    border-bottom: 1px solid var(--db-border);
    transition: background .1s;
}

.db-table tbody tr:hover { background: var(--db-surface); }
.db-table tbody tr:last-child { border-bottom: none; }

.db-table td {
    padding: .85rem 1rem;
    color: #374151;
    vertical-align: middle;
}

/* Ã¢ââ¬Ã¢ââ¬ Badges Ã¢ââ¬Ã¢ââ¬ */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}

.badge-status.active   { background: #dcfce7; color: #166534; }
.badge-status.inactive { background: #fee2e2; color: #991b1b; }
.badge-status.owner    { background: #fef3c7; color: #92400e; }
.badge-status.admin    { background: #dbeafe; color: #1e40af; }
.badge-status.member   { background: #f3f4f6; color: #374151; }
.badge-status.yes      { background: #dcfce7; color: #166534; }
.badge-status.no       { background: #f3f4f6; color: #6b7280; }

.extraction-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600;
}
.extraction-badge.succeeded   { background: #dcfce7; color: #166534; }
.extraction-badge.pending      { background: #fef9c3; color: #854d0e; }
.extraction-badge.failed       { background: #fee2e2; color: #991b1b; }
.extraction-badge.manualreview { background: #ede9fe; color: #5b21b6; }

/* Ã¢ââ¬Ã¢ââ¬ Forms Ã¢ââ¬Ã¢ââ¬ */
.form-label {
    font-weight: 600;
    font-size: .825rem;
    color: #374151;
    margin-bottom: .35rem;
}

.form-control, .form-select {
    border: 1.5px solid var(--db-border);
    border-radius: 8px;
    padding: .55rem .85rem;
    font-size: .9rem;
    transition: border-color .15s, box-shadow .15s;
    background-color: #fff;
}

.form-control:focus, .form-select:focus {
    border-color: var(--db-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
    outline: none;
}

.form-check-input:checked {
    background-color: var(--db-primary);
    border-color: var(--db-primary);
}

/* Ã¢ââ¬Ã¢ââ¬ Buttons Ã¢ââ¬Ã¢ââ¬ */
.btn {
    font-weight: 600;
    font-size: .85rem;
    border-radius: 8px;
    padding: .5rem 1.1rem;
    transition: all .15s ease;
    border: 1.5px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
    line-height: 1.4;
}

.btn-primary {
    background: var(--db-primary);
    border-color: var(--db-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--db-primary-dark);
    border-color: var(--db-primary-dark);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: var(--db-border);
    color: #374151;
}

.btn-secondary:hover {
    background: var(--db-surface);
    border-color: #94a3b8;
    color: #1e293b;
}

.btn-danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn-success {
    background: #22c55e;
    border-color: #22c55e;
    color: #fff;
}

.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

.btn-outline {
    background: transparent;
    border-color: var(--db-border);
    color: #374151;
}

.btn-outline:hover {
    background: var(--db-surface);
    color: #0f172a;
}

.btn-sm {
    font-size: .78rem;
    padding: .3rem .75rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Alerts Ã¢ââ¬Ã¢ââ¬ */
.db-alert {
    border-radius: 10px;
    padding: .85rem 1.1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    font-size: .875rem;
    border: 1px solid;
}

.db-alert.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.db-alert.danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.db-alert.info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.db-alert.warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.db-alert .alert-icon { flex-shrink: 0; font-size: 1rem; }

/* Ã¢ââ¬Ã¢ââ¬ Invite Link Box Ã¢ââ¬Ã¢ââ¬ */
.invite-link-box {
    background: var(--db-primary-light);
    border: 1.5px solid #93c5fd;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.invite-link-box .link-label {
    font-size: .78rem;
    font-weight: 600;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: .4rem;
}

.invite-link-box .link-value {
    font-family: 'Courier New', monospace;
    font-size: .8rem;
    color: #1e40af;
    word-break: break-all;
    background: rgba(255,255,255,.6);
    border-radius: 6px;
    padding: .4rem .65rem;
    display: block;
    margin-bottom: .6rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Permission Checkboxes (Roles) Ã¢ââ¬Ã¢ââ¬ */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .5rem;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border: 1.5px solid var(--db-border);
    border-radius: 8px;
    transition: all .15s;
    cursor: pointer;
}

.permission-item:has(input:checked) {
    border-color: var(--db-primary);
    background: var(--db-primary-light);
}

.permission-item input { cursor: pointer; }

.permission-item label {
    font-size: .8rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    margin: 0;
}

.permission-item:has(input:checked) label { color: var(--db-primary-dark); }

/* Ã¢ââ¬Ã¢ââ¬ Filter Bar Ã¢ââ¬Ã¢ââ¬ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    align-items: flex-end;
    padding: 1rem 1.25rem;
    background: var(--db-surface);
    border-bottom: 1px solid var(--db-border);
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 140px;
}

.filter-bar label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--db-text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* Ã¢ââ¬Ã¢ââ¬ Detail List Ã¢ââ¬Ã¢ââ¬ */
.detail-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: .75rem 1rem;
    font-size: .875rem;
}

.detail-list .dl-label {
    font-weight: 600;
    color: var(--db-text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding-top: .1rem;
}

.detail-list .dl-value {
    color: #1e293b;
}

/* Ã¢ââ¬Ã¢ââ¬ Code / Monospace Ã¢ââ¬Ã¢ââ¬ */
code {
    background: #f1f5f9;
    color: var(--db-primary);
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .82em;
    font-family: 'Courier New', monospace;
}

/* Ã¢ââ¬Ã¢ââ¬ Empty State Ã¢ââ¬Ã¢ââ¬ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--db-text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .4;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: .5rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Footer Ã¢ââ¬Ã¢ââ¬ */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: .78rem;
    color: #94a3b8;
    border-top: 1px solid var(--db-border);
    background: #fff;
}

/* Ã¢ââ¬Ã¢ââ¬ Misc Ã¢ââ¬Ã¢ââ¬ */
.text-muted { color: var(--db-text-muted) !important; }
.fw-semibold { font-weight: 600; }

/* Ã¢ââ¬Ã¢ââ¬ Responsive Ã¢ââ¬Ã¢ââ¬ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}


:root {
    --db-primary:       #1a56db;
    --db-primary-dark:  #1042a8;
    --db-primary-light: #e8f0fe;
    --db-sidebar-bg:    #0f172a;
    --db-sidebar-w:     260px;
    --db-topbar-h:      60px;
    --db-text-muted:    #64748b;
    --db-border:        #e2e8f0;
    --db-surface:       #f8fafc;
    --db-card-shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --db-radius:        10px;
}

/* Ã¢ââ¬Ã¢ââ¬ Reset / Base Ã¢ââ¬Ã¢ââ¬ */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--db-surface);
    color: #1e293b;
    min-height: 100vh;
}

a { color: var(--db-primary); text-decoration: none; }
a:hover { color: var(--db-primary-dark); text-decoration: none; }

/* Ã¢ââ¬Ã¢ââ¬ Auth Pages (no sidebar) Ã¢ââ¬Ã¢ââ¬ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 2rem;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, .08);
    border: 1px solid #e2e8f0;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 2rem;
    font-weight: 700;
    font-size: 1.4rem;
    color: #0f172a;
}

.auth-logo .logo-gem {
    font-size: 1.8rem;
    line-height: 1;
}

.auth-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: .4rem;
    color: #0f172a;
}

.auth-card .subtitle {
    color: var(--db-text-muted);
    margin-bottom: 1.8rem;
    font-size: .9rem;
}

/* Ã¢ââ¬Ã¢ââ¬ App Shell Ã¢ââ¬Ã¢ââ¬ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Ã¢ââ¬Ã¢ââ¬ Sidebar Ã¢ââ¬Ã¢ââ¬ */
.sidebar {
    width: var(--db-sidebar-w);
    background: var(--db-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    text-decoration: none;
}

.sidebar-brand .brand-gem {
    font-size: 1.6rem;
    line-height: 1;
}

.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    font-size: .7rem;
    color: rgba(255,255,255,.45);
    font-weight: 400;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-section {
    padding: .4rem 1.5rem .2rem;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
    margin-top: .6rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.5rem;
    color: rgba(255,255,255,.65);
    font-size: .875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s ease;
    text-decoration: none;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,.07);
    text-decoration: none;
}

.sidebar-link.active {
    color: #fff;
    background: rgba(26,86,219,.35);
    border-left-color: var(--db-primary);
}

.sidebar-link .nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}

.sidebar-profile {
    position: relative;
    margin-bottom: .75rem;
}

.sidebar-user-btn {
    width: 100%;
    border: none;
    background: transparent;
    padding: .35rem .25rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    margin-bottom: 0;
}

.sidebar-user-btn:hover {
    background: rgba(255,255,255,.08);
}

.profile-caret {
    margin-left: auto;
    color: rgba(255,255,255,.45);
    font-size: .75rem;
}

.profile-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + .4rem);
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    padding: .45rem;
    z-index: 40;
}

.profile-dropdown-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    padding: .35rem .55rem .2rem;
}

.profile-dropdown-item {
    display: block;
    padding: .55rem .65rem;
    border-radius: 7px;
    color: #0f172a;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
}

.profile-dropdown-item:hover,
.profile-dropdown-item.active {
    background: #eff6ff;
    color: #1d4ed8;
}

.invite-instructions {
    margin-top: .85rem;
    text-align: left;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: .9rem 1rem;
}

.invite-instructions-title {
    font-weight: 600;
    font-size: .9rem;
    color: #0f172a;
    margin-bottom: .35rem;
}

.invite-instructions ul {
    margin: 0;
    padding-left: 1.15rem;
    font-size: .84rem;
    color: #475569;
    line-height: 1.65;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--db-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info .user-name {
    font-size: .825rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.user-info .user-role {
    font-size: .72rem;
    color: rgba(255,255,255,.45);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .45rem .75rem;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    color: rgba(255,255,255,.65);
    font-size: .825rem;
    cursor: pointer;
    transition: all .15s;
}

.btn-logout:hover {
    background: rgba(239,68,68,.25);
    border-color: rgba(239,68,68,.4);
    color: #fca5a5;
}

/* Ã¢ââ¬Ã¢ââ¬ Main Content Ã¢ââ¬Ã¢ââ¬ */
.main-content {
    margin-left: var(--db-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Ã¢ââ¬Ã¢ââ¬ Top Bar Ã¢ââ¬Ã¢ââ¬ */
.topbar {
    height: var(--db-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--db-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Page Content Ã¢ââ¬Ã¢ââ¬ */
.page-content {
    padding: 1.75rem;
    flex: 1;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: .25rem;
}

.page-header p {
    color: var(--db-text-muted);
    margin: 0;
    font-size: .9rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Cards Ã¢ââ¬Ã¢ââ¬ */
.db-card {
    background: #fff;
    border-radius: var(--db-radius);
    border: 1px solid var(--db-border);
    box-shadow: var(--db-card-shadow);
    overflow: hidden;
}

.db-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--db-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.db-card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
}

.db-card-body {
    padding: 1.25rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Stats Cards (Dashboard) Ã¢ââ¬Ã¢ââ¬ */
.stat-card {
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    padding: 1.25rem;
    box-shadow: var(--db-card-shadow);
    transition: box-shadow .2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: .85rem;
}

.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.purple { background: #ede9fe; }
.stat-icon.orange { background: #ffedd5; }

.stat-label {
    font-size: .78rem;
    color: var(--db-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: .25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

/* Ã¢ââ¬Ã¢ââ¬ Tables Ã¢ââ¬Ã¢ââ¬ */
.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.db-table thead tr {
    border-bottom: 2px solid var(--db-border);
}

.db-table thead th {
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--db-text-muted);
    white-space: nowrap;
}

.db-table tbody tr {
    border-bottom: 1px solid var(--db-border);
    transition: background .1s;
}

.db-table tbody tr:hover { background: var(--db-surface); }
.db-table tbody tr:last-child { border-bottom: none; }

.db-table td {
    padding: .85rem 1rem;
    color: #374151;
    vertical-align: middle;
}

/* Ã¢ââ¬Ã¢ââ¬ Badges Ã¢ââ¬Ã¢ââ¬ */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}

.badge-status.active   { background: #dcfce7; color: #166534; }
.badge-status.inactive { background: #fee2e2; color: #991b1b; }
.badge-status.owner    { background: #fef3c7; color: #92400e; }
.badge-status.admin    { background: #dbeafe; color: #1e40af; }
.badge-status.member   { background: #f3f4f6; color: #374151; }
.badge-status.yes      { background: #dcfce7; color: #166534; }
.badge-status.no       { background: #f3f4f6; color: #6b7280; }

.extraction-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600;
}
.extraction-badge.succeeded   { background: #dcfce7; color: #166534; }
.extraction-badge.pending      { background: #fef9c3; color: #854d0e; }
.extraction-badge.failed       { background: #fee2e2; color: #991b1b; }
.extraction-badge.manualreview { background: #ede9fe; color: #5b21b6; }

/* Ã¢ââ¬Ã¢ââ¬ Forms Ã¢ââ¬Ã¢ââ¬ */
.form-label {
    font-weight: 600;
    font-size: .825rem;
    color: #374151;
    margin-bottom: .35rem;
}

.form-control, .form-select {
    border: 1.5px solid var(--db-border);
    border-radius: 8px;
    padding: .55rem .85rem;
    font-size: .9rem;
    transition: border-color .15s, box-shadow .15s;
    background-color: #fff;
}

.form-control:focus, .form-select:focus {
    border-color: var(--db-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
    outline: none;
}

.form-check-input:checked {
    background-color: var(--db-primary);
    border-color: var(--db-primary);
}

/* Ã¢ââ¬Ã¢ââ¬ Buttons Ã¢ââ¬Ã¢ââ¬ */
.btn {
    font-weight: 600;
    font-size: .85rem;
    border-radius: 8px;
    padding: .5rem 1.1rem;
    transition: all .15s ease;
    border: 1.5px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
    line-height: 1.4;
}

.btn-primary {
    background: var(--db-primary);
    border-color: var(--db-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--db-primary-dark);
    border-color: var(--db-primary-dark);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: var(--db-border);
    color: #374151;
}

.btn-secondary:hover {
    background: var(--db-surface);
    border-color: #94a3b8;
    color: #1e293b;
}

.btn-danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn-success {
    background: #22c55e;
    border-color: #22c55e;
    color: #fff;
}

.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

.btn-outline {
    background: transparent;
    border-color: var(--db-border);
    color: #374151;
}

.btn-outline:hover {
    background: var(--db-surface);
    color: #0f172a;
}

.btn-sm {
    font-size: .78rem;
    padding: .3rem .75rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Alerts Ã¢ââ¬Ã¢ââ¬ */
.db-alert {
    border-radius: 10px;
    padding: .85rem 1.1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    font-size: .875rem;
    border: 1px solid;
}

.db-alert.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.db-alert.danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.db-alert.info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.db-alert.warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.db-alert .alert-icon { flex-shrink: 0; font-size: 1rem; }

/* Ã¢ââ¬Ã¢ââ¬ Invite Link Box Ã¢ââ¬Ã¢ââ¬ */
.invite-link-box {
    background: var(--db-primary-light);
    border: 1.5px solid #93c5fd;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.invite-link-box .link-label {
    font-size: .78rem;
    font-weight: 600;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: .4rem;
}

.invite-link-box .link-value {
    font-family: 'Courier New', monospace;
    font-size: .8rem;
    color: #1e40af;
    word-break: break-all;
    background: rgba(255,255,255,.6);
    border-radius: 6px;
    padding: .4rem .65rem;
    display: block;
    margin-bottom: .6rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Permission Checkboxes (Roles) Ã¢ââ¬Ã¢ââ¬ */
/* A module heading and the info icon holding what its permissions actually allow. "Read" on its
   own does not say what reading gets you, and ticking one of these is an access decision. */
.perm-cat-head {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .5rem;
}
.perm-cat-name {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #94a3b8;
}
/* Focusable, so the explanation is reachable by keyboard and not by hover alone. */
.perm-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    color: #94a3b8;
    background: #fff;
    font-size: .64rem;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    /* Plain arrow: "help" draws the question-mark cursor, and the icon is not clickable. */
    cursor: default;
    user-select: none;
    flex: 0 0 auto;
}
.perm-info:hover,
.perm-info:focus-visible {
    border-color: var(--db-primary);
    color: var(--db-primary);
    outline: none;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .5rem;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border: 1.5px solid var(--db-border);
    border-radius: 8px;
    transition: all .15s;
    cursor: pointer;
}

.permission-item:has(input:checked) {
    border-color: var(--db-primary);
    background: var(--db-primary-light);
}

.permission-item input { cursor: pointer; }

.permission-item label {
    font-size: .8rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    margin: 0;
}

.permission-item:has(input:checked) label { color: var(--db-primary-dark); }

/* Ã¢ââ¬Ã¢ââ¬ Filter Bar Ã¢ââ¬Ã¢ââ¬ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    align-items: flex-end;
    padding: 1rem 1.25rem;
    background: var(--db-surface);
    border-bottom: 1px solid var(--db-border);
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 140px;
}

.filter-bar label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--db-text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* Ã¢ââ¬Ã¢ââ¬ Detail List Ã¢ââ¬Ã¢ââ¬ */
.detail-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: .75rem 1rem;
    font-size: .875rem;
}

.detail-list .dl-label {
    font-weight: 600;
    color: var(--db-text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding-top: .1rem;
}

.detail-list .dl-value {
    color: #1e293b;
}

/* Ã¢ââ¬Ã¢ââ¬ Code / Monospace Ã¢ââ¬Ã¢ââ¬ */
code {
    background: #f1f5f9;
    color: #0f172a;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .82em;
    font-family: 'Courier New', monospace;
}

/* Ã¢ââ¬Ã¢ââ¬ Empty State Ã¢ââ¬Ã¢ââ¬ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--db-text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .4;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: .5rem;
}

/* Ã¢ââ¬Ã¢ââ¬ Footer Ã¢ââ¬Ã¢ââ¬ */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: .78rem;
    color: #94a3b8;
    border-top: 1px solid var(--db-border);
    background: #fff;
}

/* Ã¢ââ¬Ã¢ââ¬ Misc Ã¢ââ¬Ã¢ââ¬ */
.text-muted { color: var(--db-text-muted) !important; }
.fw-semibold { font-weight: 600; }

/* Ã¢ââ¬Ã¢ââ¬ Responsive Ã¢ââ¬Ã¢ââ¬ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

/* =========================================================
   SNF Notes (Notion-style)
   ========================================================= */
.pn-page { display: flex; flex-direction: column; gap: 0; }
.pn-page-title { font-size: 1.35rem; font-weight: 700; margin: 0; color: #0f172a; }
.pn-page-sub { margin: .15rem 0 0; color: #64748b; font-size: .85rem; }
.pn-filter-bar {
    display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
    padding: .75rem 0 1rem; border-bottom: 1px solid #e2e8f0; margin-bottom: .75rem;
}
.pn-filter-bar .form-control,
.pn-filter-bar .form-select { width: auto; min-width: 140px; max-width: 220px; }

/* Single-line filter bars live at the very end of this file - see "one-line filter bars". */
.pn-sort { color: inherit; text-decoration: none; font-weight: 600; }
.pn-sort:hover { color: var(--db-primary); }
.pn-status-badge {
    display: inline-block; font-size: .72rem; font-weight: 700; padding: .2rem .55rem;
    border-radius: 999px; text-transform: uppercase; letter-spacing: .02em;
}
.pn-status-badge.completed { background: #dbeafe; color: #1d4ed8; }
.pn-status-badge.awaiting { background: #ffedd5; color: #c2410c; }
.pn-status-badge.processing { background: #fef3c7; color: #a16207; }
.pn-status-badge.failed { background: #fee2e2; color: #b91c1c; }
.pn-draft-flag { display: block; margin-top: .25rem; font-size: .72rem; color: #b91c1c; font-weight: 600; }
.pn-inline-name { display: flex; align-items: center; gap: .35rem; flex: 1; min-width: 0; }
.pn-edit-input { max-width: 220px; }
.pn-clinical-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.pn-clinical-head h3 { margin: 0; }
.pn-entry-filters { display: flex; gap: .35rem; }
.pn-chip {
    font-size: .78rem; padding: .25rem .65rem; border-radius: 999px; border: 1px solid #e2e8f0;
    color: #64748b; text-decoration: none; font-weight: 600;
}
.pn-chip.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.pn-title-edit { display: flex; align-items: center; gap: .5rem; flex: 1; }
.pn-detail-title-input { font-size: 1.25rem; font-weight: 700; max-width: 420px; }
.pn-remarks-auto { display: flex; flex-direction: column; gap: .25rem; width: 100%; }
.pn-pdf-modal {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 2000;
    display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.pn-pdf-modal[hidden] { display: none !important; }
.pn-pdf-dialog {
    background: #fff; width: min(960px, 96vw); height: min(88vh, 900px);
    border-radius: 12px; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.pn-pdf-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: .65rem 1rem; border-bottom: 1px solid #e2e8f0;
}
.pn-pdf-dialog iframe { flex: 1; width: 100%; border: 0; background: #f8fafc; }
.pn-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.pn-tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.pn-tab {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .85rem; border-radius: 6px 6px 0 0;
    color: #64748b; font-size: .88rem; font-weight: 500;
    border: 1px solid transparent; border-bottom: none;
}
.pn-tab:hover { background: #f1f5f9; color: #0f172a; }
.pn-tab.active {
    background: #fff; color: #0f172a; border-color: var(--db-border);
    box-shadow: inset 0 -2px 0 var(--db-primary);
}
.pn-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pn-dot.completed { background: #3b82f6; }
.pn-dot.awaiting { background: #f59e0b; }
.pn-dot.failed { background: #ef4444; }
.pn-toolbar-actions { display: flex; align-items: center; gap: .4rem; }
.pn-icon-btn {
    width: 34px; height: 34px; border: 1px solid var(--db-border);
    background: #fff; border-radius: 8px; cursor: pointer;
}
.pn-new-btn { padding: .35rem 1rem; font-weight: 600; }
.pn-table-wrap {
    background: #fff; border: 1px solid var(--db-border);
    border-radius: var(--db-radius); overflow: visible;
}
.pn-search-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: .65rem 1rem; border-bottom: 1px solid var(--db-border);
}
.pn-search-row input { max-width: 280px; }
.pn-scroll { overflow-x: auto; overflow-y: visible; }
.pn-table {
    width: 100%; border-collapse: collapse; min-width: 1400px;
    font-size: .84rem;
}
.pn-table th {
    text-align: left; padding: .85rem .95rem; background: #f8fafc;
    border-bottom: 1px solid var(--db-border); color: #64748b;
    font-weight: 600; white-space: nowrap;
}
.pn-table td {
    padding: .95rem .95rem; border-bottom: 1px solid #f1f5f9;
    vertical-align: middle; color: #1e293b; overflow: visible;
}
.pn-table tr:hover td { background: #f8fafc; }
.pn-name-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: .5rem;
    min-height: 2.5rem;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    position: relative;
}
.pn-file-name {
    font-weight: 600;
    color: #0f172a;
    flex: 0 1 auto;
    width: max-content;
    max-width: calc(100% - 4rem);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pn-clinical-table td:first-child {
    min-width: 240px;
    width: 36%;
}
.pn-clinical-table .pn-name-cell .pn-file-name {
    width: max-content;
    max-width: calc(100% - 4rem);
}
.pn-open-btn {
    flex: 0 0 auto;
    opacity: 0;
    pointer-events: none;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: .2rem .5rem;
    border-radius: 6px;
    background: #e8f2f4;
    color: #3d6673;
    white-space: nowrap;
    text-decoration: none;
}
.pn-open-btn--visible,
.pn-clinical-table .pn-open-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
}
.pn-name-cell:hover .pn-open-btn,
.pn-row:hover .pn-open-btn,
.cn-row:hover .pn-open-btn {
    opacity: 1;
    pointer-events: auto;
}
.pn-tag {
    display: inline-block; padding: .15rem .5rem; border-radius: 4px;
    font-size: .75rem; font-weight: 600; background: #e2e8f0; color: #334155;
}
.pn-tag.green { background: #dcfce7; color: #166534; }
.pn-tag.red { background: #fee2e2; color: #991b1b; }
.pn-tag.orange { background: #ffedd5; color: #9a3412; }
.pn-sum { font-size: .8rem; white-space: nowrap; }
.pn-clinical-summary {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .15rem;
    white-space: nowrap;
    font-size: .8rem;
}
.pn-sum.pending { color: #ea580c; }
.pn-sum.analyzed { color: #16a34a; }
.pn-sum.error { color: #dc2626; }
.pn-cpt { color: #16a34a; font-weight: 600; font-size: .8rem; }
.pn-doctors {
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: .8rem; color: #475569;
}
.pn-muted { color: #94a3b8; font-size: .78rem; white-space: nowrap; }
.pn-detail {
    display: grid; grid-template-columns: 1fr 280px; gap: 1.25rem; align-items: start;
}
.pn-detail-main {
    background: #fff; border: 1px solid var(--db-border);
    border-radius: var(--db-radius); padding: 1.25rem 1.5rem;
}
.pn-detail-header {
    display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
    margin-bottom: 1rem;
}
.pn-back { font-size: .82rem; color: #64748b; }
.pn-detail-title {
    flex: 1; font-size: 1.35rem; font-weight: 700; margin: 0; color: #0f172a;
}
.pn-detail-actions { display: flex; gap: .5rem; }
.pn-setup-bar {
    display: flex; flex-wrap: wrap; gap: .75rem; align-items: end;
    padding: .85rem; background: #f8fafc; border: 1px solid var(--db-border);
    border-radius: 8px; margin-bottom: 1rem;
}
.pn-setup-bar.readonly { align-items: center; gap: 1.5rem; }
.pn-setup-field { display: flex; flex-direction: column; gap: .25rem; min-width: 160px; }
.pn-setup-field.grow { flex: 1; min-width: 220px; }
.pn-setup-field label, .pn-label {
    font-size: .72rem; font-weight: 600; color: #64748b; text-transform: uppercase;
}
.pn-view-tabs {
    display: flex; gap: .35rem; border-bottom: 1px solid var(--db-border);
    margin-bottom: 1rem;
}
.pn-view-tab {
    padding: .5rem .9rem; font-size: .86rem; font-weight: 500; color: #64748b;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.pn-view-tab.active { color: #0f172a; border-bottom-color: var(--db-primary); }
.pn-summary-block { display: flex; flex-direction: column; gap: .85rem; margin-bottom: 1.5rem; }
.pn-prop { display: grid; grid-template-columns: 160px 1fr; gap: .75rem; align-items: start; }
.pn-prop-label { font-size: .8rem; color: #64748b; font-weight: 500; }
.pn-relation { color: #2563eb; font-weight: 600; font-size: .9rem; }
.pn-linked-item {
    border: 1px solid var(--db-border); border-radius: 8px; background: #fff;
}
.pn-linked-item summary {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
    padding: .65rem .85rem; cursor: pointer; list-style: none;
}
.pn-linked-item summary::-webkit-details-marker { display: none; }
.pn-linked-name { font-weight: 600; flex: 1; min-width: 140px; }
.pn-cpt-chip {
    font-size: .72rem; font-weight: 700; color: #166534; background: #dcfce7;
    padding: .1rem .4rem; border-radius: 4px;
}
.pn-linked-body { padding: 0 .85rem .85rem; border-top: 1px solid #f1f5f9; }
.pn-meta-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem; margin: .75rem 0; font-size: .82rem;
}
.pn-pre {
    white-space: pre-wrap; word-break: break-word; font-size: .8rem;
    background: #f8fafc; border: 1px solid var(--db-border); border-radius: 6px;
    padding: .75rem; max-height: 320px; overflow: auto;
    font-family: ui-monospace, Consolas, monospace;
}
.pn-comments { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--db-border); }
.pn-comment { padding: .75rem 0; border-bottom: 1px solid #f1f5f9; font-size: .88rem; }
.pn-comment-meta { display: flex; gap: .75rem; margin-bottom: .25rem; }
.pn-detail-side {
    background: #fff; border: 1px solid var(--db-border);
    border-radius: var(--db-radius); padding: 1rem 1.1rem;
    position: sticky; top: 1rem;
}
.pn-side-row {
    display: flex; flex-direction: column; gap: .15rem;
    padding: .55rem 0; border-bottom: 1px solid #f1f5f9; font-size: .78rem;
}
.pn-side-row span { color: #64748b; }
.pn-side-row b { font-weight: 600; color: #0f172a; font-size: .84rem; }
.pn-side-long {
    font-weight: 500 !important; font-size: .75rem !important;
    max-height: 90px; overflow: auto; word-break: break-word;
}
.pn-side-check {
    display: flex; flex-direction: column; gap: .45rem;
    padding: .75rem 0; border-bottom: 1px solid #f1f5f9; font-size: .84rem;
}
.pn-side-check label { display: flex; align-items: center; gap: .45rem; margin: 0; }
@media (max-width: 992px) {
    .pn-detail { grid-template-columns: 1fr; }
    .pn-detail-side { position: static; }
    .pn-prop { grid-template-columns: 1fr; }
}

/* Notion-style selects + CPT colors */
.pn-select { position: relative; display: inline-block; z-index: 1; }
.pn-select.is-open { z-index: 40; }
.pn-select-trigger {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: .35rem;
    max-width: 100%;
    border: none; background: transparent; padding: .35rem .45rem;
    border-radius: 6px; cursor: pointer;
}
.pn-select-trigger:hover { background: #f1f5f9; }
.pn-select-menu {
    position: absolute; z-index: 2000; top: calc(100% + 6px); left: 0;
    min-width: 240px; max-height: 320px; overflow: auto;
    background: #fff; border: 1px solid var(--db-border); border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15,23,42,.18); padding: .4rem;
}
.pn-select-menu.pn-menu-fixed {
    position: fixed;
    z-index: 5000;
}
.pn-select-group-label {
    font-size: .72rem; color: #94a3b8; font-weight: 600;
    padding: .35rem .5rem .15rem; text-transform: uppercase;
}
.pn-select-hint { font-size: .75rem; color: #94a3b8; padding: .35rem .5rem; }
.pn-select-option {
    display: block; width: 100%; text-align: left; border: none;
    background: transparent; padding: .4rem .5rem; border-radius: 6px; cursor: pointer;
}
.pn-select-option:hover { background: #f1f5f9; }
.pn-select-option.pn-clear { font-size: .8rem; color: #64748b; }
.pn-create-company {
    display: flex; gap: .35rem; padding: .4rem .5rem; border-top: 1px solid #f1f5f9; margin-top: .25rem;
}
.pn-status-tag {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.pn-status-tag.notes { background: #dcfce7; color: #166534; }
.pn-status-tag.monthly { background: #ede9fe; color: #5b21b6; }
.pn-status-dot {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.pn-status-tag.notes .pn-status-dot { background: #16a34a; }
.pn-status-tag.monthly .pn-status-dot { background: #7c3aed; }
.pn-empty { color: #94a3b8; font-size: .84rem; }
.pn-sum-empty { color: #94a3b8; font-style: italic; font-weight: 600; font-size: .82rem; }
.pn-cpt-pending { color: #16a34a; font-weight: 600; font-size: .84rem; }
.pn-cpt-part.blue { color: #2563eb; }
.pn-cpt-part.orange { color: #ea580c; }
.pn-cpt-part.gray { color: #94a3b8; }
.pn-cpt-sep { color: #cbd5e1; }
.pn-coding-banner {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
    padding: .75rem 1rem; margin-bottom: 1rem; font-size: .9rem; color: #92400e;
}
.pn-autosave-hint { font-size: .72rem; color: #94a3b8; }
.pn-name-plain {
    display: inline-block;
    min-width: 4rem;
    padding: .1rem 0;
    font-weight: 600;
    color: #0f172a;
    border: none;
    background: transparent;
    outline: none;
    border-bottom: 1px solid transparent;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}
.pn-name-plain[contenteditable="true"]:hover,
.pn-name-plain[contenteditable="true"]:focus {
    border-bottom-color: #94a3b8;
}
.pn-detail-title-plain {
    font-size: 1.35rem;
    font-weight: 700;
    min-width: 12rem;
    max-width: min(100%, 520px);
}
.pn-plain-input {
    border: none;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0;
    background: transparent;
    padding-left: 0;
    box-shadow: none;
}
.pn-plain-input:focus {
    border-bottom-color: var(--db-primary, #2563eb);
    box-shadow: none;
    background: transparent;
}
.pn-check {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .84rem;
    color: #334155;
    margin: 0 .15rem;
    white-space: nowrap;
    user-select: none;
}
.pn-check input { margin: 0; }
.pn-row-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}
.pn-cn-filters { margin-bottom: .85rem; }
.pn-top-props {
    display: flex; flex-direction: column; gap: .65rem;
    padding: .75rem 0 1rem; border-bottom: 1px solid var(--db-border); margin-bottom: 1rem;
}
.pn-top-prop {
    display: grid; grid-template-columns: 120px 1fr; gap: .75rem; align-items: center;
}
.pn-report-file { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pn-inline-form { display: flex; gap: .35rem; align-items: center; width: 100%; }
.pn-inline-form input { flex: 1; }
.pn-side-title {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: #94a3b8; margin-bottom: .5rem;
}
.pn-detail-side.collapsed { display: none; }
.pn-new-page {
    background: #fff; border: 1px solid var(--db-border);
    border-radius: var(--db-radius); padding: 1.25rem 1.5rem;
}

.pn-upload-page {
    max-width: 520px;
}

.pn-upload-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}

.pn-upload-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #1f2d34;
}

.pn-upload-card {
    background: #fff;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 8px;
    padding: 1rem 1.1rem 1.1rem;
}

.pn-upload-hint {
    margin: 0 0 .9rem;
    font-size: .84rem;
    line-height: 1.45;
    color: #6d7f89;
}

.pn-upload-form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.pn-upload-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.pn-upload-label {
    margin: 0;
    font-size: .68rem;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6d7f89;
}

.pn-upload-help {
    font-size: .75rem;
    color: #9aabb4;
}

.cn-sort-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.cn-date-filter-form,
.cn-sort-form {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: .45rem;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.cn-date-filter-form .form-control,
.cn-date-filter-form .form-select,
.cn-sort-form .form-select {
    width: auto;
    min-width: 118px;
    max-width: 160px;
}

.pn-cn-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    align-items: center;
}

.pn-cn-filters > .form-control,
.pn-cn-filters > .form-select {
    flex: 0 0 auto;
}

.cn-delete-form {
    margin: 0;
}

.trash-page {
    /* Full page width, matching .cn-page / .pn-page. A capped card left dead space
       on wide screens while the tables inside still needed horizontal scrolling. */
    max-width: 100%;
}

.trash-header {
    /* The tab strip and table sat right under the heading; this separates the two. */
    margin-bottom: 1.4rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--db-border);
}

.trash-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2d34;
}

.trash-sub {
    margin: .25rem 0 0;
    font-size: .84rem;
    color: #6d7f89;
}

.trash-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .75rem;
}



/* Per-patient Linked Report page */
.lr-detail .lr-main-fields { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.25rem; }
.lr-relations { display: flex; flex-direction: column; gap: .35rem; }
.lr-notes-block { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--db-border); }
.lr-notes-block h3 { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; }
.lr-progress { max-height: 480px; }
.pn-linked-link {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
    padding: .65rem .85rem; border: 1px solid var(--db-border); border-radius: 8px;
    background: #fff; color: inherit; text-decoration: none;
}
.pn-linked-link:hover { background: #f8fafc; color: inherit; border-color: #cbd5e1; }

/* Dashboard home */
.dash-home {
    max-width: none;
    width: 100%;
}

.dash-brand-title {
    font-size: 1.85rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 1.25rem;
    letter-spacing: -0.02em;
}

.dash-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.dash-feature-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    text-decoration: none;
    color: #0f172a;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    transition: box-shadow .15s ease, border-color .15s ease;
}

.dash-feature-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
    color: #0f172a;
}

.dash-feature-name {
    position: relative;
    z-index: 1;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    padding: 1rem;
}

.dash-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .85rem;
}

.dash-metric-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 118px;
    padding: .9rem .75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.dash-metric-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
    color: inherit;
}

.dash-metric-cat {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #94a3b8;
    align-self: flex-start;
}

.dash-metric-label {
    font-size: .92rem;
    font-weight: 700;
    color: #0f172a;
    text-align: center;
    line-height: 1.25;
}

.dash-metric-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: #166534;
    line-height: 1;
    margin-top: .15rem;
}

.dash-metric-card.is-alert .dash-metric-value {
    color: #dc2626;
}

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

@media (max-width: 576px) {
    .dash-metrics { grid-template-columns: 1fr; }
    .dash-brand-title { font-size: 1.45rem; }
}

/* Ã¢ââ¬Ã¢ââ¬ Coded Notes Ã¢ââ¬Ã¢ââ¬ */
.pn-status-tag.pending { background: #fef9c3; color: #854d0e; }
.pn-status-tag.analyzed { background: #dcfce7; color: #166534; }
.pn-status-tag.error { background: #fee2e2; color: #991b1b; }
.pn-status-tag.failure { background: #ffedd5; color: #9a3412; }
.pn-status-tag.pending .pn-status-dot { background: #ca8a04; }
.pn-status-tag.analyzed .pn-status-dot { background: #16a34a; }
.pn-status-tag.error .pn-status-dot { background: #dc2626; }
.pn-status-tag.failure .pn-status-dot { background: #ea580c; }

.pn-company-tag {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 600;
    color: #0f172a;
}

.cn-page { max-width: 100%; }
.cn-header { margin-bottom: 1.25rem; }
.cn-title-row { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .85rem; }
.cn-title-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: #dcfce7; color: #166534;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.cn-title { font-size: 1.75rem; font-weight: 700; margin: 0; color: #0f172a; }
.cn-view-details { font-size: .8rem; color: #64748b; }
.cn-banner {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 10px;
    padding: .75rem 1rem;
    font-size: .9rem;
    margin-bottom: .75rem;
}
.cn-dash-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .35rem .7rem; border-radius: 8px;
    border: 1px solid #86efac; color: #166534; background: #fff;
    font-size: .82rem; font-weight: 600; text-decoration: none;
}
.cn-dash-btn:hover { background: #f0fdf4; color: #14532d; }

/* Coded Notes Dashboard */
.cn-dash-page { max-width: 100%; } /* full page width, like every other module page */
.cn-dash-header { margin-bottom: 1.25rem; }
.cn-dash-eyebrow {
    margin: 0 0 .2rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--db-primary-dark, #4a7380);
}
.cn-dash-period {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .65rem 1rem;
    margin-bottom: 1rem;
}
.cn-dash-period-view {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin: 0;
}
.cn-dash-period-view-label {
    font-size: .8rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}
.cn-dash-period-view .form-select {
    min-width: 7.5rem;
    width: auto;
}
.cn-dash-period-stepper {
    display: inline-flex;
    align-items: stretch;
    gap: .35rem;
}
.cn-dash-period-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}
.cn-dash-period-btn:hover:not(:disabled) {
    border-color: #94a3b8;
    background: #f8fafc;
}
.cn-dash-period-btn:disabled {
    color: #cbd5e1;
    cursor: default;
}
.cn-dash-period-label {
    display: inline-flex;
    align-items: center;
    min-width: 11rem;
    justify-content: center;
    padding: .35rem .85rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    font-size: .88rem;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}
.cn-dash-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: stretch;
    width: 100%;
}
.cn-dash-stack--single {
    grid-template-columns: minmax(0, 1fr);
}
.cn-dash-stack--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
/* Keep multi-card layouts horizontal until the viewport is truly narrow. */
@media (max-width: 1200px) {
    .cn-dash-stack--three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .cn-dash-stack,
    .cn-dash-stack--three {
        grid-template-columns: minmax(0, 1fr);
    }
}
.cn-dash-page [hidden] {
    display: none !important;
}
.cn-dash-stack-col {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    width: 100%;
}
.cn-dash-stack-col[hidden] {
    display: none !important;
}
.cn-dash-card {
    border: 1px solid var(--db-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    overflow: visible;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.cn-dash-ypc-match-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: -0.35rem 0 0.85rem;
}
.cn-dash-ypc-match {
    position: relative;
    display: inline-flex;
    align-items: center;
}
/* Period bar scrolls/clips children — open panel is placed with position:fixed in JS. */
.cn-dash-ypc-match-panel[hidden] {
    display: none !important;
}
.cn-dash-ypc-match-panel:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    z-index: 1080;
    min-width: 17rem;
    max-width: min(22rem, calc(100vw - 1rem));
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--db-border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
.cn-dash-ypc-match-hint {
    margin: 0;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.35;
}
.cn-dash-card > .cn-dash-filters-panel {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    padding: 1rem 1.1rem .85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    /* Keep open multi-select menus above the chart (sibling panel-host paints later). */
    position: relative;
    z-index: 5;
}
.cn-dash-card > .cn-dash-panel-host {
    padding: 0 1.1rem 1.05rem;
    min-height: 220px;
    flex: 1 1 auto;
    position: relative;
    z-index: 1;
}
.cn-dash-card .cn-dash-chart-panel,
.cn-dash-card .cn-dash-chart-panel--zero {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    padding: .35rem 0 0;
}
.cn-dash-card .cn-dash-chart-title {
    display: none;
}
.cn-dash-card .cn-dash-chart-sub {
    margin: 0;
}
.cn-dash-card .cn-dash-filters-head {
    margin-bottom: .75rem;
}
.cn-dash-card .pn-cn-filters {
    margin-bottom: 0;
    padding-bottom: .85rem;
    border-bottom: 1px solid #f1f5f9;
}
.cn-dash-panel-host {
    min-height: 220px;
}
.cn-dash-panel-host.is-loading {
    opacity: 1;
    position: relative;
}
.cn-dash-panel-host.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .45);
    pointer-events: none;
    border-radius: 0 0 12px 12px;
}
.cn-dash-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.15rem;
}
.cn-dash-charts.is-loading {
    grid-template-columns: 1fr;
    min-height: 220px;
}
.cn-dash-charts.is-loading > .cn-dash-panels-zero {
    width: 100%;
}
.cn-dash-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 2rem 1rem;
    color: #64748b;
    font-size: .9rem;
    font-weight: 600;
}
.cn-dash-loading--inline {
    padding: 1.25rem 0 .5rem;
}
.cn-dash-loading-zeros {
    font-size: .8rem;
    font-weight: 500;
    color: #94a3b8;
}
.cn-dash-panels-zero {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
@media (max-width: 960px) {
    .cn-dash-panels-zero { grid-template-columns: 1fr; }
}
.cn-dash-chart-panel--zero {
    opacity: .72;
}
.cn-dash-loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 2.5px solid #e2e8f0;
    border-top-color: var(--db-primary-dark, #4a7380);
    border-radius: 50%;
    animation: cn-dash-spin .8s linear infinite;
}
@keyframes cn-dash-spin {
    to { transform: rotate(360deg); }
}
.cn-dash-chart-panel {
    border: 1px solid var(--db-border);
    border-radius: 12px;
    background: #fff;
    padding: 1rem 1.1rem 1.05rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.cn-dash-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .75rem;
}
.cn-dash-view-toggle {
    display: inline-flex;
    gap: .25rem;
    flex: 0 0 auto;
}
.cn-dash-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
}
.cn-dash-view-btn svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.cn-dash-view-btn.is-active {
    border-color: #334155;
    color: #0f172a;
    background: #f8fafc;
}
.cn-dash-series-empty {
    margin: .5rem 0;
    font-size: .85rem;
    color: #94a3b8;
}
.cn-dash-bars {
    display: flex;
    align-items: stretch;
    gap: .5rem;
    height: 200px;
    overflow-x: auto;
    padding: .5rem .2rem .15rem;
}
.cn-dash-bar-col {
    flex: 0 0 auto;
    width: 2.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    height: 100%;
    min-width: 2.75rem;
}
.cn-dash-bar-track {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: #f8fafc;
    border-radius: 8px 8px 3px 3px;
    border: 1px solid #eef2f7;
}
.cn-dash-bar-stack {
    width: 100%;
    display: flex;
    flex-direction: column-reverse;
    border-radius: 7px 7px 2px 2px;
    overflow: hidden;
    min-height: 4px;
}
.cn-dash-bar-seg {
    display: block;
    width: 100%;
    min-height: 3px;
}
.cn-dash-bar-seg--billed {
    background: linear-gradient(180deg, #bbf7d0 0%, #86efac 100%);
}
.cn-dash-bar-seg--count {
    background: linear-gradient(180deg, #93c5fd 0%, #60a5fa 100%);
}
.cn-dash-stats--count-only {
    grid-template-columns: minmax(0, 1fr);
}
.cn-dash-stats--count-match {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cn-dash-stat--match2 .cn-dash-stat-value { color: #0369a1; }
.cn-dash-bar-seg--remaining {
    background: linear-gradient(180deg, #fed7aa 0%, #fdba74 100%);
}
.cn-dash-bar-label {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    font-size: .62rem;
    line-height: 1.15;
    color: #64748b;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cn-dash-table-wrap {
    max-height: 260px;
    overflow: auto;
    border: 1px solid var(--db-border);
    border-radius: 8px;
}
.cn-dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}
.cn-dash-table th,
.cn-dash-table td {
    padding: .45rem .65rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}
.cn-dash-table th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    z-index: 1;
}
.cn-dash-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cn-dash-table tbody tr:last-child td { border-bottom: none; }
.cn-dash-chart-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}
.cn-dash-chart-sub {
    margin: .15rem 0 0;
    font-size: .78rem;
    color: #94a3b8;
}
.cn-dash-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .85rem;
    margin-bottom: 1rem;
}
.cn-dash-stats--chart {
    margin-bottom: .75rem;
    gap: .55rem;
}
.cn-dash-stats--chart .cn-dash-stat {
    padding: .75rem .8rem;
}
.cn-dash-stats--chart .cn-dash-stat-value {
    font-size: 1.45rem;
}
@media (max-width: 1200px) {
    .cn-dash-stack--three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .cn-dash-charts { grid-template-columns: 1fr; }
}
.cn-dash-stat {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    border: 1px solid var(--db-border);
    background: #fff;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cn-dash-stat:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .07);
    transform: translateY(-1px);
}
.cn-dash-stat-icon {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    display: grid;
    place-items: center;
}
.cn-dash-stat-icon svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.cn-dash-stat--total .cn-dash-stat-icon { background: #f1f5f9; color: #334155; }
.cn-dash-stat--billed .cn-dash-stat-icon { background: #dcfce7; color: #15803d; }
.cn-dash-stat--nonbuild .cn-dash-stat-icon { background: #ffedd5; color: #c2410c; }
.cn-dash-stat--exception .cn-dash-stat-icon { background: #ede9fe; color: #6d28d9; }
.cn-dash-stat-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.cn-dash-stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
}
.cn-dash-stat--billed .cn-dash-stat-value { color: #15803d; }
.cn-dash-stat--nonbuild .cn-dash-stat-value { color: #c2410c; }
.cn-dash-stat--exception .cn-dash-stat-value { color: #6d28d9; }
.cn-dash-stat-label {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
}
.cn-dash-stat-hint { font-size: .78rem; color: #94a3b8; }
.cn-dash-stat-hint--unmatched { color: #c2410c; font-size: .72rem; }
.cn-dash-stat-link {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.cn-dash-stat-link:hover .cn-dash-stat-value {
    text-decoration: underline;
    text-underline-offset: .12em;
}
a.cn-dash-stat-hint--unmatched {
    text-decoration: none;
    cursor: pointer;
}
a.cn-dash-stat-hint--unmatched:hover,
a.cn-dash-stat-hint--unmatched:focus-visible {
    text-decoration: underline;
    text-underline-offset: .12em;
}
.cn-dash-stats--chart .cn-dash-stat { overflow: visible; position: relative; }
.cn-dash-stat-hint--unmatched[data-unmatched-tip] {
    cursor: help;
    text-decoration: underline dotted rgba(194, 65, 12, .55);
    text-underline-offset: 2px;
    position: relative;
}
.cn-dash-stat-hint--unmatched[data-unmatched-tip]::after {
    content: attr(data-unmatched-tip);
    position: absolute;
    left: 0;
    bottom: calc(100% + .35rem);
    z-index: 40;
    width: max(12rem, 100%);
    min-width: 11.5rem;
    max-width: 16rem;
    padding: .45rem .55rem;
    border-radius: 8px;
    background: #0f172a;
    color: #f8fafc;
    font-size: .72rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    text-decoration: none;
    white-space: normal;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .22);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(.15rem);
    transition: opacity .12s ease, transform .12s ease, visibility .12s;
}
.cn-dash-stat-hint--unmatched[data-unmatched-tip]:hover::after,
.cn-dash-stat-hint--unmatched[data-unmatched-tip]:focus::after,
.cn-dash-stat-hint--unmatched[data-unmatched-tip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.cn-dash-breakdown {
    margin-bottom: 1.15rem;
    padding: .85rem 1rem;
    border: 1px solid var(--db-border);
    border-radius: 10px;
    background: #fff;
}
.cn-dash-breakdown-bar {
    display: flex;
    height: .55rem;
    border-radius: 999px;
    overflow: hidden;
    background: #f1f5f9;
}
.cn-dash-breakdown-seg { display: block; height: 100%; min-width: 0; }
.cn-dash-breakdown-seg--billed { background: linear-gradient(90deg, #22c55e, #16a34a); }
.cn-dash-breakdown-seg--nonbuild { background: linear-gradient(90deg, #fb923c, #ea580c); }
.cn-dash-breakdown-seg--exception { background: linear-gradient(90deg, #a78bfa, #7c3aed); }
.cn-dash-breakdown-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .85rem 1.25rem;
    margin-top: .55rem;
    font-size: .8rem;
    color: #64748b;
}
.cn-dash-dot {
    display: inline-block;
    width: .55rem;
    height: .55rem;
    border-radius: 999px;
    margin-right: .3rem;
    vertical-align: middle;
}
.cn-dash-dot--billed { background: #86efac; }
.cn-dash-dot--nonbuild { background: #fdba74; }
.cn-dash-dot--exception { background: #c4b5fd; }
.cn-dash-chart-panel .cn-dash-breakdown {
    margin-bottom: 0;
    padding: .55rem 0 0;
    border: none;
    background: transparent;
    border-radius: 0;
}
.cn-dash-filters-panel {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.cn-dash-filters-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem 1rem;
    margin-bottom: .85rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid #f1f5f9;
}
.cn-dash-filters-title { margin: 0; font-size: 1rem; font-weight: 700; color: #0f172a; }
.cn-dash-filters-sub { margin: .15rem 0 0; font-size: .82rem; color: #94a3b8; }
.cn-dash-filter-badge {
    font-size: .72rem;
    font-weight: 700;
    padding: .25rem .6rem;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    white-space: nowrap;
}
.cn-dash-filter-form { display: flex; flex-direction: column; gap: .85rem; }
.cn-dash-search-row { width: 100%; }
.cn-dash-search-wrap { position: relative; max-width: 100%; }
.cn-dash-search-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: #94a3b8;
    stroke-width: 2;
    pointer-events: none;
}
.cn-dash-search {
    padding-left: 2.25rem !important;
    min-height: 2.5rem;
    border-radius: 10px;
    width: 100%;
    max-width: none;
}
/*
  Filters pack as many per row as fit instead of a fixed 4 columns, so a dashboard with
  eight or nine of them lands on one or two rows rather than three. The narrow-screen
  overrides below still step it down to 2 columns and then 1.
*/
.cn-dash-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: .45rem .5rem;
}
.cn-dash-filter-row--secondary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
    padding-top: .15rem;
}
.cn-dash-toggles { display: flex; flex-wrap: wrap; gap: .45rem; }
.cn-dash-toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .7rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    user-select: none;
    margin: 0;
}
.cn-dash-toggle:has(input:checked) {
    border-color: #0f172a;
    background: #0f172a;
    color: #fff;
}
.cn-dash-toggle input { margin: 0; }
.cn-dash-date-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
}
.cn-dash-date-field { min-width: 9rem; }
.cn-dash-date { width: auto; min-width: 9.5rem; }
.cn-dash-date-sep { font-size: .82rem; color: #94a3b8; }
.cn-dash-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    padding-top: .25rem;
    border-top: 1px solid #f1f5f9;
}
.cn-ms { position: relative; min-width: 0; }
.cn-ms.is-open { z-index: 60; }
.cn-ms-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .5rem .65rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    font-size: .82rem;
    text-align: left;
    color: #0f172a;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.cn-ms-btn:hover { border-color: #cbd5e1; }
.cn-ms--active .cn-ms-btn {
    border-color: #7dd3fc;
    background: #f0f9ff;
}
.cn-ms-label { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn-ms-meta { font-size: .72rem; color: #64748b; white-space: nowrap; }
.cn-ms--active .cn-ms-meta { color: #0369a1; font-weight: 600; }
.cn-ms-chevron {
    width: .95rem;
    height: .95rem;
    fill: none;
    stroke: #94a3b8;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}
.cn-ms-menu {
    position: absolute;
    z-index: 40;
    top: calc(100% + .25rem);
    left: 0;
    right: 0;
    min-width: 13rem;
    max-height: 16rem;
    display: flex;
    flex-direction: column;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    overflow: hidden;
    pointer-events: auto;
}
/* Billing Dashboard: menus must sit above chart siblings that paint later in the card. */
.cn-dash-page .cn-ms-menu {
    z-index: 2000;
}
.cn-ms-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .45rem .65rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
}
.cn-ms-clear {
    border: 0;
    background: none;
    padding: 0;
    font-size: .72rem;
    font-weight: 600;
    color: #0369a1;
    cursor: pointer;
}
.cn-ms-clear:hover { text-decoration: underline; }
.cn-ms-search {
    margin: .45rem .55rem 0;
    border-radius: 8px;
}
.cn-ms-options {
    overflow: auto;
    padding: .35rem .45rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}
.cn-ms-opt {
    display: flex;
    align-items: flex-start;
    gap: .45rem;
    padding: .35rem .4rem;
    border-radius: 7px;
    font-size: .82rem;
    color: #334155;
    cursor: pointer;
    margin: 0;
}
.cn-ms-opt:hover { background: #f8fafc; }
.cn-ms-opt input { margin-top: .15rem; flex: 0 0 auto; }
.cn-ms-opt span { line-height: 1.35; word-break: break-word; }
.cn-ms-menu-foot {
    display: flex;
    justify-content: flex-end;
    gap: .35rem;
    padding: .45rem .55rem .55rem;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}
.cn-ms-apply {
    min-width: 4.5rem;
}
@media (max-width: 992px) {
    .cn-dash-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .cn-dash-stats { grid-template-columns: 1fr; }
    .cn-dash-filter-grid { grid-template-columns: 1fr; }
    .cn-dash-filter-row--secondary { flex-direction: column; align-items: stretch; }
    .cn-dash-date-row { width: 100%; }
}
.cn-section-title {
    font-size: 1.05rem; font-weight: 700; margin: 1rem 0 .65rem; color: #0f172a;
}
.cn-toolbar { margin-bottom: .5rem; }
.cn-patient-link {
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    flex: 0 1 auto;
    width: max-content;
    max-width: calc(100% - 4rem);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cn-patient-link:hover { color: var(--db-primary-dark, #4a7380); text-decoration: underline; }
.cn-file-link { color: #334155; font-size: .84rem; }
.cn-file-link:hover { color: var(--db-primary-dark, #4a7380); }
.cn-entry.original { color: #16a34a; font-weight: 600; font-size: .84rem; }
.cn-entry.duplicate { color: #ea580c; font-weight: 600; font-size: .84rem; }
.cn-icd {
    width: 160px;
    max-width: 160px;
}
.cn-icd .cn-cell-clip,
.cn-cell-clip {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .82rem;
}
.cn-table {
    table-layout: fixed;
    min-width: 1680px;
    width: 100%;
}
.cn-table th,
.cn-table td {
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cn-table th.cn-col-created,
.cn-table td.cn-col-created {
    width: 150px;
    max-width: 150px;
}
.cn-table th.cn-col-actions,
.cn-table td.cn-col-actions {
    width: 96px;
    max-width: 96px;
    overflow: visible;
    white-space: nowrap;
}
.cn-table th:first-child,
.cn-table td:first-child {
    min-width: 220px;
    width: 220px;
    max-width: 260px;
}
.cn-table td:first-child {
    overflow: visible;
    white-space: normal;
}
.cn-meta-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 1040;
}
.cn-meta-side {
    position: fixed; top: 0; right: 0; width: min(360px, 92vw); height: 100vh;
    background: #fff; border-left: 1px solid var(--db-border);
    z-index: 1050; padding: 1rem 1.1rem; overflow: auto;
    box-shadow: -8px 0 24px rgba(15, 23, 42, .08);
}
.cn-meta-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--db-border);
}
.cn-meta-body .pn-prop {
    display: grid; grid-template-columns: 120px 1fr; gap: .5rem;
    margin-bottom: .75rem; font-size: .9rem;
}
.cn-page-sub { margin: .15rem 0 0; }
.cn-footer {
    display: flex; flex-wrap: wrap; gap: .75rem 1.25rem;
    align-items: center; justify-content: space-between;
    padding: .75rem .5rem; border-top: 1px solid var(--db-border);
}
.cn-pager { display: flex; gap: .5rem; }
.cn-summary {
    display: flex; flex-wrap: wrap; gap: .65rem 1rem;
    font-size: .72rem; font-weight: 600; color: #64748b; text-transform: uppercase;
}
.cn-summary-top {
    margin-top: .65rem;
}

.cn-error-kw {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 6px;
    background: #fef3c7;
    color: #92400e;
    font-size: .78rem;
    font-weight: 600;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cn-status-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .28rem;
}
.cn-status-cell .cn-error-kw,
.cn-detail-header .cn-error-kw {
    max-width: 240px;
}

.cn-no-access {
    color: #94a3b8;
    font-size: .8rem;
    font-style: italic;
}

/* Coded note patient detail (Notion-style) */
.cn-detail {
    max-width: 920px;
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    padding: 1.25rem 1.5rem 2rem;
}

.cn-detail-top { margin-bottom: 1rem; }
.cn-detail-name {
    font-size: 1.85rem;
    font-weight: 700;
    margin: .35rem 0 .15rem;
    color: #0f172a;
}

.cn-detail-props { margin-bottom: 1.25rem; }
.cn-prop-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .85rem 1rem;
    margin-bottom: .85rem;
}
.cn-prop-label {
    font-size: .72rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .25rem;
}
.cn-prop-value { font-size: .95rem; color: #0f172a; font-weight: 500; }
.cn-prop-block { margin-bottom: .85rem; }
.cn-wrap { white-space: pre-wrap; line-height: 1.45; }

.cn-section { margin-top: 1.35rem; padding-top: 1rem; border-top: 1px solid #f1f5f9; }
.cn-block-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 .65rem;
    color: #0f172a;
}

.cn-relations {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem .75rem;
}
.cn-rel {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .84rem;
    color: #1d4ed8;
    text-decoration: none;
}
.cn-rel.muted { color: #94a3b8; }
.cn-rel:hover { text-decoration: underline; }

.cn-comment-box {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .65rem .85rem;
    color: #94a3b8;
    font-size: .88rem;
    background: #f8fafc;
}

.cn-progress { max-height: none; white-space: pre-wrap; }
.cn-source-file {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .55rem .75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #0f172a;
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
}
.cn-source-file:hover { background: #f8fafc; color: #0f172a; }
.cn-pdf-icon { font-size: 1.1rem; }

@media (max-width: 900px) {
    .cn-prop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* =========================================================
   Mature clinical product theme
   Restrained, high-trust UI for medical operations
   ========================================================= */
:root {
    --db-primary: #3d5a66;
    --db-primary-dark: #314851;
    --db-primary-light: #eef3f5;
    --db-sidebar-bg: #ffffff;
    --db-sidebar-w: 248px;
    --db-topbar-h: 56px;
    --db-text: #24333b;
    --db-text-muted: #667883;
    --db-border: #dde5e9;
    --db-surface: #f5f7f8;
    --db-card: #ffffff;
    --db-card-shadow: none;
    --db-radius: 8px;
    --db-radius-sm: 6px;
    --db-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --db-success-bg: #edf6f1;
    --db-success-fg: #2f5d46;
    --db-danger-bg: #f7efef;
    --db-danger-fg: #7a4545;
    --db-warn-bg: #f7f3eb;
    --db-warn-fg: #735c36;
}

html {
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--db-font);
    font-optical-sizing: auto;
    letter-spacing: -0.01em;
    line-height: 1.5;
    background: var(--db-surface);
    color: var(--db-text);
}

h1, h2, h3, h4,
.page-header h1,
.pn-page-title,
.cn-title,
.dash-brand-title,
.topbar-title {
    letter-spacing: -0.02em;
    color: #1f2d34;
    font-weight: 600;
}

a { color: var(--db-primary); }
a:hover { color: var(--db-primary-dark); }

/* Brand */
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    min-width: 1.85rem;
    padding: 0;
    border-radius: 6px;
    background: var(--db-primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    border: none;
    box-shadow: none;
}

.profile-caret {
    margin-left: auto;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #8a9ba4;
}

.status-badge-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    flex-shrink: 0;
    border: 1px solid var(--db-border);
}

.status-badge-icon--ok {
    background: var(--db-success-bg);
    color: var(--db-success-fg);
}

.status-badge-icon--off {
    background: #f0f3f4;
    color: #667883;
}

.empty-state-label {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #8a9ba4;
    margin-bottom: .35rem;
}

.dash-feature-icon { display: none; }

/* Auth â quiet, institutional */
.auth-wrapper {
    background: var(--db-surface);
    min-height: 100vh;
}

.auth-card {
    border-radius: 10px;
    border: 1px solid var(--db-border);
    box-shadow: none;
    background: #fff;
    padding: 2rem 2.1rem;
    max-width: 400px;
}

.auth-logo {
    gap: .7rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.auth-logo > div > div:first-child {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2d34;
    letter-spacing: -0.02em;
}

.auth-logo-sub {
    font-size: .68rem;
    font-weight: 500;
    color: var(--db-text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-top: .15rem;
}

.auth-card h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: .35rem;
}

.auth-card .subtitle {
    color: var(--db-text-muted);
    font-size: .88rem;
    margin-bottom: 1.5rem;
}

.auth-card .btn-primary {
    border-radius: var(--db-radius-sm);
    padding: .65rem 1rem;
    font-weight: 600;
    background: var(--db-primary);
    border-color: var(--db-primary);
    box-shadow: none;
}

.auth-card .btn-primary:hover {
    background: var(--db-primary-dark);
    border-color: var(--db-primary-dark);
    box-shadow: none;
    transform: none;
}

/* Shell */
.app-shell { background: var(--db-surface); }

.sidebar {
    width: var(--db-sidebar-w);
    background: #fff;
    border-right: 1px solid var(--db-border);
    box-shadow: none;
}

.sidebar-brand {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--db-border);
    gap: .65rem;
}

.sidebar-brand .brand-text {
    color: #1f2d34;
    font-size: .84rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.sidebar-brand .brand-sub {
    color: #8a9ba4;
    letter-spacing: .08em;
    font-size: .62rem;
    font-weight: 500;
    margin-top: .1rem;
}

.sidebar-nav { padding: .75rem 0; }

.sidebar-section {
    color: #8a9ba4;
    font-weight: 600;
    letter-spacing: .08em;
    font-size: .62rem;
    margin-top: .55rem;
    padding: .35rem 1.1rem .15rem;
}

.sidebar-link {
    margin: .1rem .6rem;
    padding: .55rem .75rem;
    border-left: none;
    border-radius: 6px;
    color: #445760;
    font-size: .875rem;
    font-weight: 500;
}

.sidebar-link:hover {
    background: #f3f6f7;
    color: #1f2d34;
}

.sidebar-link.active {
    background: var(--db-primary-light);
    color: var(--db-primary-dark);
    border-left: none;
    box-shadow: none;
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--db-border);
    padding: .85rem .9rem 1rem;
    background: #fff;
}

.sidebar-user-btn {
    border-radius: 6px;
    padding: .35rem .3rem;
}

.sidebar-user-btn:hover { background: #f3f6f7; }

.user-info .user-name {
    color: #1f2d34;
    font-weight: 600;
    font-size: .8rem;
}

.user-info .user-role {
    color: #8a9ba4;
    font-size: .7rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--db-primary-light);
    color: var(--db-primary-dark);
    border: 1px solid var(--db-border);
    box-shadow: none;
    font-size: .75rem;
    font-weight: 700;
}

.btn-logout {
    background: #fff;
    border: 1px solid var(--db-border);
    color: #445760;
    border-radius: 6px;
    font-weight: 550;
    font-size: .8rem;
}

.btn-logout:hover {
    background: var(--db-danger-bg);
    border-color: #e5d4d4;
    color: var(--db-danger-fg);
}

.profile-dropdown {
    border-radius: 8px;
    border: 1px solid var(--db-border);
    box-shadow: 0 8px 24px rgba(36, 51, 59, .08);
    padding: .35rem;
}

.profile-dropdown-item {
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 500;
}

.profile-dropdown-item:hover,
.profile-dropdown-item.active {
    background: var(--db-primary-light);
    color: var(--db-primary-dark);
}

.main-content {
    margin-left: var(--db-sidebar-w);
    min-width: 0;
    background: var(--db-surface);
    transition: margin-left .25s ease;
}

.topbar {
    height: var(--db-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--db-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 110;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-width: 0;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--db-border);
    border-radius: 8px;
    background: #fff;
    color: #3d5a66;
    cursor: pointer;
    flex: 0 0 auto;
}

.sidebar-toggle:hover {
    background: #eef3f5;
    color: #314851;
}

html.sidebar-hidden .sidebar {
    transform: translateX(-100%);
}

html.sidebar-hidden .main-content {
    margin-left: 0;
}

html.sidebar-hidden .sidebar-toggle svg {
    transform: scaleX(-1);
}

.topbar-title {
    font-size: .95rem;
    font-weight: 600;
    color: #1f2d34;
}

.topbar-date {
    font-size: .75rem;
    font-weight: 500;
    color: var(--db-text-muted);
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0;
}

.page-content {
    padding: 1.35rem 1.5rem 1.75rem;
}

.page-header { margin-bottom: 1.15rem; }

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: .2rem;
}

.page-header p {
    font-size: .85rem;
    color: var(--db-text-muted);
}

/* Cards / tables / forms */
.db-card {
    border-radius: var(--db-radius);
    border: 1px solid var(--db-border);
    box-shadow: none;
    background: #fff;
}

.db-card-header {
    background: #fff;
    padding: .85rem 1.1rem;
}

.db-card-header h2 {
    font-size: .92rem;
    font-weight: 600;
    color: #1f2d34;
}

.db-card-body { padding: 1.1rem; }

.db-table thead th {
    font-size: .68rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #6d7f89;
    font-weight: 600;
    background: #f8fafb;
    border-bottom: 1px solid var(--db-border);
}

.db-table tbody tr:hover { background: #f8fafb; }

.db-table td { color: #33464f; font-size: .875rem; }

.badge-status {
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: .01em;
    font-size: .72rem;
    border: 1px solid transparent;
    padding: .2rem .45rem;
}

.badge-status.active,
.badge-status.yes {
    background: var(--db-success-bg);
    color: var(--db-success-fg);
    border-color: #d7e8de;
}

.badge-status.inactive {
    background: var(--db-danger-bg);
    color: var(--db-danger-fg);
    border-color: #e8d8d8;
}

.badge-status.owner {
    background: var(--db-warn-bg);
    color: var(--db-warn-fg);
    border-color: #e8dfcf;
}

.badge-status.admin {
    background: var(--db-primary-light);
    color: var(--db-primary-dark);
    border-color: #d7e2e6;
}

.badge-status.member,
.badge-status.no {
    background: #f0f3f4;
    color: #445760;
    border-color: #e2e8ea;
}

.form-label {
    color: #3d5059;
    font-weight: 600;
    font-size: .8rem;
}

.form-control,
.form-select {
    border-radius: var(--db-radius-sm);
    border: 1px solid #cfd8dd;
    font-family: var(--db-font);
    color: var(--db-text);
    background: #fff;
    padding: .5rem .75rem;
    font-size: .875rem;
    box-shadow: none;
}

.form-control:focus,
.form-select:focus {
    border-color: #8aa3ac;
    box-shadow: 0 0 0 3px rgba(61, 90, 102, .12);
}

.btn {
    font-family: var(--db-font);
    border-radius: var(--db-radius-sm);
    letter-spacing: -0.01em;
    font-weight: 600;
    font-size: .82rem;
    padding: .45rem .9rem;
}

.btn-primary {
    background: var(--db-primary);
    border-color: var(--db-primary);
    box-shadow: none;
    color: #fff;
}

.btn-primary:hover {
    background: var(--db-primary-dark);
    border-color: var(--db-primary-dark);
    box-shadow: none;
    transform: none;
    color: #fff;
}

.btn-secondary,
.btn-outline,
.btn-outline-secondary {
    border-radius: var(--db-radius-sm);
    border-color: #cfd8dd;
    color: #3d5059;
    background: #fff;
    box-shadow: none;
}

.btn-secondary:hover,
.btn-outline-secondary:hover {
    background: #f3f6f7;
    border-color: #b8c5cc;
    color: #1f2d34;
}

.btn-danger {
    background: #a86868;
    border-color: #a86868;
    box-shadow: none;
}

.btn-danger:hover {
    background: #965c5c;
    border-color: #965c5c;
}

.btn-outline-danger {
    border-radius: var(--db-radius-sm);
    border-color: #c9a0a0;
    color: #8a4a4a;
    background: #fff;
    box-shadow: none;
}

.btn-outline-danger:hover {
    background: #faf2f2;
    border-color: #b88888;
    color: #6e3a3a;
}

.btn-success {
    background: #5f8a73;
    border-color: #5f8a73;
}

.app-footer {
    color: #8a9ba4;
    font-size: .72rem;
    padding: .85rem 1.5rem 1.15rem;
    border-top: none;
}

/* Dashboard — operational, not marketing */
.dash-home {
    max-width: none;
    width: 100%;
}

.dash-hero {
    margin-bottom: 1.35rem;
    padding: 1.15rem 1.25rem 1.2rem;
    border: 1px solid var(--db-border);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.dash-hero-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem 1rem;
}

.dash-hero-copy { min-width: 0; flex: 1 1 16rem; }

.dash-hero-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.dash-hero-actions .db-menu-list {
    right: 0;
    left: auto;
}

.dash-eyebrow {
    display: block;
    margin: 0 0 .3rem;
    font-size: .68rem;
    font-weight: 650;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: #7b8f99;
}

.dash-brand-title {
    font-size: 1.5rem;
    font-weight: 650;
    margin: 0 0 .3rem;
    color: #15262e;
    letter-spacing: -0.03em;
}

.dash-lead {
    margin: 0;
    max-width: none;
    color: var(--db-text-muted);
    font-size: .88rem;
    line-height: 1.45;
}

.dash-jump {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin: .9rem 0 0;
}

.dash-jump a {
    display: inline-flex;
    align-items: center;
    padding: .32rem .75rem;
    border: 1px solid #dbe4ea;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: .78rem;
    font-weight: 600;
}

.dash-jump a:hover {
    border-color: #c5d4f0;
    background: var(--db-primary-light);
    color: var(--db-primary);
}

.dash-section + .dash-section {
    margin-top: .85rem;
}

/* Main hub: module groups fill the page in columns instead of one narrow stack. */
.dash-module-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .85rem;
    margin-top: .15rem;
    align-items: start;
}

.dash-module-grid > .dash-section {
    margin-top: 0;
    min-width: 0;
}

.dash-module-grid .dash-panel {
    height: 100%;
}

@media (min-width: 768px) {
    .dash-module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
}

/* Cap at 3 columns so uneven section counts do not leave a wide empty column. */
@media (min-width: 1100px) {
    .dash-module-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* The module list embedded at the foot of the main dashboard. The dashboard is a wide page,
   so the groups run two-up instead of the single narrow column the standalone page uses. */
.dash-modules {
    margin-top: 1.6rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--db-border);
}
.dash-modules-head { margin-bottom: .9rem; }
.dash-modules-title {
    margin: 0 0 .2rem;
    font-size: 1.05rem;
    font-weight: 650;
    color: #1f2d34;
}
.dash-modules-sub { margin: 0; font-size: .85rem; color: #64748b; }
.dash-modules .dash-jump { margin-bottom: 1rem; }
.dash-modules .dash-section,
.dash-modules .dash-section + .dash-section { margin-top: 0; }
.dash-modules > .dash-section,
.dash-modules .dash-section {
    break-inside: avoid;
}

@media (min-width: 992px) {
    .dash-modules {
        column-count: 2;
        column-gap: 1rem;
    }
    .dash-modules-head,
    .dash-modules .dash-jump { column-span: all; }
    .dash-modules .dash-section { margin-bottom: 1rem; display: block; }
}

.dash-section {
    scroll-margin-top: calc(var(--db-topbar-h) + 12px);
}

.dash-panel {
    border: 1px solid var(--db-border);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}

.dash-panel-title,
.dash-section-title {
    margin: 0;
    padding: .75rem 1rem .7rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #475569;
    background: #f8fafb;
    border-bottom: 1px solid var(--db-border);
}

.dash-list {
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    background: transparent;
    overflow: visible;
}

.dash-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid #eef2f5;
    color: inherit;
    text-decoration: none;
}

.dash-row:last-child { border-bottom: none; }

.dash-row-icon {
    display: inline-flex;
    width: 2.15rem;
    height: 2.15rem;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--db-primary-light);
    color: var(--db-primary);
    flex-shrink: 0;
}

.dash-row-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dash-row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: .12rem;
}

.dash-row::after {
    content: '\203A';
    color: #c0c9d1;
    font-size: 1.2rem;
    line-height: 1;
}

.dash-row:hover {
    background: #f7f9fc;
    color: inherit;
}

.dash-row:hover::after { color: var(--db-primary); }

.dash-row:hover .dash-row-name { color: var(--db-primary); }

.dash-row-name {
    font-size: .95rem;
    font-weight: 600;
    color: #15262e;
}

.dash-row-desc {
    font-size: .8rem;
    color: var(--db-text-muted);
    line-height: 1.35;
}

.dash-empty-access {
    margin-top: .5rem;
    padding: .9rem 1rem;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--db-border);
    color: var(--db-text-muted);
    font-size: .88rem;
}

@media (max-width: 640px) {
    .dash-hero { padding: 1rem 1rem 1.05rem; }
    .dash-row { gap: .7rem; padding: .8rem .9rem; }
}

/* Notes pages */
.pn-page-title,
.cn-title {
    font-size: 1.35rem;
    font-weight: 600;
    color: #1f2d34;
}

.pn-page-sub,
.cn-page-sub {
    color: var(--db-text-muted) !important;
    font-size: .85rem !important;
}

.pn-toolbar {
    margin-bottom: .65rem;
    padding-bottom: .65rem;
    border-bottom: 1px solid var(--db-border);
}

.pn-filter-bar,
.pn-cn-filters {
    gap: .45rem;
    padding: .75rem 0 .9rem;
    border-bottom: 1px solid var(--db-border);
}

.pn-table-wrap,
.pn-scroll {
    border-radius: 8px;
    border: 1px solid var(--db-border);
    background: #fff;
    box-shadow: none;
}

.pn-table th {
    font-size: .68rem;
    letter-spacing: .04em;
    background: #f8fafb;
}

.pn-tab {
    border-radius: 6px;
    font-weight: 550;
    font-size: .82rem;
    color: #445760;
    padding: .4rem .75rem;
}

.pn-tab.active {
    background: var(--db-primary);
    color: #fff;
    box-shadow: none;
}

.pn-chip {
    border-radius: 6px;
}

.pn-chip.active {
    background: var(--db-primary);
    border-color: var(--db-primary);
    color: #fff;
}

.pn-status-badge,
.pn-status-tag {
    border-radius: 4px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: .01em;
}

.pn-status-badge.completed,
.pn-status-tag.analyzed {
    background: #e8f0f2;
    color: #3d5a66;
    border: 1px solid #d3e0e4;
}

.pn-status-badge.awaiting,
.pn-status-tag.pending {
    background: var(--db-warn-bg);
    color: var(--db-warn-fg);
    border: 1px solid #e5dccb;
}

.pn-status-badge.processing {
    background: #f0f3f4;
    color: #445760;
    border: 1px solid #e2e8ea;
}

.pn-status-badge.failed,
.pn-status-tag.error {
    background: var(--db-danger-bg);
    color: var(--db-danger-fg);
    border: 1px solid #e5d5d5;
}

.pn-open-btn {
    background: var(--db-primary-light);
    color: var(--db-primary-dark);
    border-radius: 4px;
    font-size: .65rem;
    font-weight: 650;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.pn-sort:hover,
.pn-relation,
.pn-cpt-part.blue,
.cn-patient-link:hover,
.cn-file-link:hover,
.cn-rel {
    color: var(--db-primary-dark);
}

.cn-col-patient {
    min-width: 260px !important;
    width: 22%;
    max-width: 360px;
}

.cn-patient-ids {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    line-height: 1.25;
    white-space: normal;
}

.cn-patient-id-ref {
    font-weight: 500;
}

.cn-patient-id-sys {
    font-size: 0.82em;
    color: #64748b;
}

.cn-dos-range-filter {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.cn-table {
    table-layout: fixed;
    min-width: 1680px;
}

.cn-table td.cn-col-patient { overflow: visible; white-space: normal; }

.cn-table .pn-name-cell {
    display: flex;
    width: 100%;
    gap: .5rem;
}

.cn-table .pn-name-cell .pn-file-name,
.cn-table .pn-name-cell .cn-patient-link {
    flex: 0 1 auto;
    width: max-content;
    max-width: calc(100% - 4rem);
}

.cn-entry.original { color: #3d6b54; }
.cn-entry.duplicate { color: #8a5a32; }

.db-alert {
    border-radius: 8px;
    border-width: 1px;
    font-size: .88rem;
}

.db-alert.success {
    background: var(--db-success-bg);
    border-color: #d7e8de;
    color: var(--db-success-fg);
}

.db-alert.danger {
    background: var(--db-danger-bg);
    border-color: #e5d5d5;
    color: var(--db-danger-fg);
}

.db-flash-dialog,
.db-confirm-dialog {
    border-radius: 10px;
    font-family: var(--db-font);
    box-shadow: 0 16px 40px rgba(36, 51, 59, .12);
}

.db-flash-success .modal-header,
.db-confirm-dialog .modal-header {
    border-left-color: var(--db-primary);
}

.db-flash-error .modal-header,
.db-confirm-danger .modal-header {
    border-left-color: #a86868;
}

.db-flash-warning .modal-header { border-left-color: #b08948; }
.db-flash-info .modal-header { border-left-color: var(--db-primary); }

.empty-state {
    padding: 2.5rem 1.5rem;
}

.empty-state h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2d34;
}

.empty-state p {
    color: var(--db-text-muted);
    font-size: .88rem;
}

@media (max-width: 768px) {
    .page-content { padding: 1rem .85rem 1.35rem; }
    .dash-feature-card { padding: 1rem; }
    .topbar { padding: 0 1rem; }
    .sidebar {
        top: var(--db-topbar-h);
        height: calc(100vh - var(--db-topbar-h));
        box-shadow: 8px 0 24px rgba(36, 51, 59, .08);
    }
    html:not(.sidebar-hidden) .sidebar {
        transform: none;
    }
    html .main-content,
    html.sidebar-hidden .main-content {
        margin-left: 0;
    }
}


/* =========================================================
   Detail pages â clean property layout
   ========================================================= */
.cn-detail {
    max-width: 960px;
}

/*
   .cn-detail caps its width on purpose: the coded-note page is prose, and very long
   lines are hard to read. Detail pages whose body is a wide table need the whole page
   instead, so they opt out rather than the cap being dropped for everyone.
*/
.cn-detail--wide {
    max-width: 100%;
}

.cn-detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    margin-bottom: .75rem;
}

.cn-id-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem 1.25rem;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    background: #fff;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 8px;
}

.cn-id-row .pn-prop {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    min-width: 0;
}

.cn-source-link {
    font-size: .88rem;
    font-weight: 500;
    color: #1f2d34;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.cn-note-edit {
    font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
    font-size: .82rem;
    line-height: 1.55;
    color: #33464f;
    white-space: pre-wrap;
    min-height: 8rem;
    resize: vertical;
}

.cn-note-edit.cn-progress {
    min-height: 18rem;
}

.cn-status-top {
    width: auto;
    min-width: 7.5rem;
    max-width: 10rem;
    font-weight: 600;
    font-size: .8rem;
}

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

.cn-detail-header .cn-patient-name,
.cn-detail-header .cn-detail-name,
.cn-detail-header .pn-detail-title-plain {
    font-size: 1.35rem;
    font-weight: 600;
    color: #1f2d34;
    letter-spacing: -0.02em;
    margin: 0;
    min-width: 0;
    flex: 1 1 auto;
}

.cn-panel {
    background: #fff;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 8px;
    padding: 1rem 1.15rem 1.15rem;
    margin-bottom: .85rem;
}

.cn-panel-title {
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6d7f89;
    margin: 0 0 .85rem;
}

.cn-dup-panel .cn-dup-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .35rem;
}
.cn-dup-panel .cn-dup-head .cn-panel-title { margin: 0; }
.cn-dup-help {
    margin: 0 0 .75rem;
    font-size: .82rem;
    color: #6d7f89;
}
.cn-dup-empty {
    margin: 0 0 .75rem;
    font-size: .88rem;
    color: #6d7f89;
}
.cn-dup-table-wrap {
    overflow-x: auto;
    margin-bottom: .85rem;
}
.cn-dup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .84rem;
}
.cn-dup-table th,
.cn-dup-table td {
    padding: .45rem .55rem;
    border-bottom: 1px solid #e8eef1;
    text-align: left;
    vertical-align: middle;
}
.cn-dup-table th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6d7f89;
    font-weight: 650;
}
.cn-dup-row.cn-dup-current { background: #f7fafb; }
.cn-dup-you { color: #6d7f89; font-style: normal; font-size: .78rem; }
.cn-dup-file {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cn-dup-inline-form { display: inline; margin: 0; }
.cn-dup-link {
    border-top: 1px solid #e8eef1;
    padding-top: .75rem;
}
.cn-dup-link-title {
    font-size: .78rem;
    font-weight: 650;
    margin: 0 0 .45rem;
    color: #3a4a52;
}
.cn-dup-link-row { max-width: 420px; margin-bottom: .5rem; }
.cn-dup-results {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    max-height: 220px;
    overflow-y: auto;
}
.cn-dup-candidate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .5rem .65rem;
    border: 1px solid #e8eef1;
    border-radius: 6px;
    background: #fafcfd;
}
.cn-dup-candidate-meta {
    min-width: 0;
    font-size: .82rem;
}
.cn-dup-candidate-meta strong { display: block; }
.cn-dup-candidate-meta span {
    color: #6d7f89;
    font-size: .76rem;
}
.pn-status-tag.original { background: #e8f5ee; color: #1f6b45; }
.pn-status-tag.original .pn-status-dot { background: #16a34a; }
.pn-status-tag.duplicate { background: #fff1e6; color: #9a4b12; }
.pn-status-tag.duplicate .pn-status-dot { background: #ea580c; }

.cn-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .85rem 1.25rem;
}

.cn-meta-item {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.cn-meta-label {
    font-size: .72rem;
    font-weight: 600;
    color: #6d7f89;
    letter-spacing: .02em;
}

.cn-meta-value {
    font-size: .9rem;
    color: #1f2d34;
    font-weight: 500;
    word-break: break-word;
}

.cn-field-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem 1.25rem;
}

.cn-field-grid .pn-prop {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    grid-template-columns: none;
    align-items: stretch;
}

.cn-field-grid .pn-prop-label {
    font-size: .72rem;
    font-weight: 600;
    color: #6d7f89;
}

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

.cn-field-grid .form-control,
.cn-field-grid .form-select {
    max-width: none !important;
    width: 100%;
}

.cn-source-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.cn-optum-panel .cn-dup-head { margin-bottom: .65rem; }
.cn-optum-badge {
    background: #fff1e6;
    color: #9a4b12;
    font-size: .72rem;
    font-weight: 600;
}
.cn-optum-empty {
    margin: 0;
    font-size: .88rem;
    color: #6d7f89;
    line-height: 1.45;
}
.cn-optum-list {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.cn-optum-match {
    padding: .85rem 1rem;
    border: 1px solid #e8eef1;
    border-radius: 8px;
    background: #fafcfd;
}
.cn-optum-member-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem .75rem;
    margin-bottom: .75rem;
    padding-bottom: .65rem;
    border-bottom: 1px solid #e8eef1;
}
.cn-optum-member-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2d34;
    text-decoration: none;
}
.cn-optum-member-name:hover { color: var(--db-primary-dark); text-decoration: underline; }
.cn-optum-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem 1.25rem;
}
.cn-optum-roster-file { grid-column: 1 / -1; }
@media (max-width: 768px) {
    .cn-optum-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    .cn-optum-grid { grid-template-columns: 1fr; }
}

/* Linked transaction report — mirrors the coded-note panel on the Transaction patient page. */
.cn-txn-panel .cn-dup-head { margin-bottom: .65rem; }
.cn-txn-empty {
    margin: 0;
    font-size: .88rem;
    color: #6d7f89;
    line-height: 1.45;
}
.cn-txn-list {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.cn-txn-line {
    padding: .85rem 1rem;
    border: 1px solid #e8eef1;
    border-radius: 8px;
    background: #fafcfd;
}
.cn-txn-line-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem .75rem;
    margin-bottom: .75rem;
    padding-bottom: .65rem;
    border-bottom: 1px solid #e8eef1;
}
.cn-txn-line-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .65rem;
}
.cn-txn-line-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2d34;
    text-decoration: none;
}
.cn-txn-line-name:hover { color: var(--db-primary-dark); text-decoration: underline; }
.cn-txn-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem 1.25rem;
}
.cn-txn-file { grid-column: 1 / -1; }
@media (max-width: 768px) {
    .cn-txn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    .cn-txn-grid { grid-template-columns: 1fr; }
}

.cn-detail .pn-pre {
    margin: 0;
    background: #f8fafb;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 6px;
    padding: .85rem 1rem;
    font-size: .82rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 420px;
    overflow: auto;
    color: #33464f;
}

.pn-summary-line {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    align-items: center;
    font-size: .875rem;
}

.pn-batch-detail .pn-detail-main {
    padding: .85rem 1.1rem 1.1rem;
}

.pn-batch-detail .pn-detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    margin-bottom: .65rem;
    padding-bottom: .65rem;
    border-bottom: 1px solid var(--db-border, #dde5e9);
}

.pn-batch-detail .pn-detail-header .pn-detail-title,
.pn-batch-detail .pn-detail-header .pn-detail-title-plain {
    flex: 1 1 12rem;
    min-width: 0;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #1f2d34;
}

.pn-detail-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin-left: auto;
}

.pn-overview-panel {
    margin-bottom: .65rem;
    padding: .75rem .9rem;
    background: #f7f9fa;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 8px;
}

.pn-overview-meta {
    display: grid;
    grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr);
    gap: .5rem 1.25rem;
    margin-bottom: .65rem;
    align-items: start;
}

/* Transaction file detail: Company · DtServ · Dir · Post range on one row */
.tr-overview-meta {
    grid-template-columns: minmax(12rem, 1.5fr) minmax(11rem, 1.1fr) minmax(6rem, 0.7fr) minmax(11rem, 1.1fr);
}

.pn-display-name-input {
    max-width: 100%;
}

.pn-header-name {
    flex: 1 1 14rem;
    min-width: 0;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #1f2d34;
    border: 1px solid transparent;
    background: transparent;
    box-shadow: none;
    padding: .25rem .4rem;
}

.pn-header-name:hover {
    border-color: var(--db-border, #dde5e9);
    background: #fff;
}

.pn-header-name:focus {
    border-color: var(--db-primary, #5a8794);
    background: #fff;
    box-shadow: none;
}

.pn-overview-item {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    min-width: 0;
}

.pn-overview-label {
    font-size: .68rem;
    font-weight: 650;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #6d7f89;
}

.pn-overview-value {
    font-size: .9rem;
    color: #1f2d34;
    min-width: 0;
}

.pn-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1rem;
    padding: .45rem .35rem;
    background: #fff;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 6px;
    text-align: center;
    min-width: 0;
}

.pn-stat-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .4rem;
}

.pn-stat-value {
    font-size: 1.15rem;
    font-weight: 650;
    line-height: 1.1;
    color: #1f2d34;
    letter-spacing: -0.02em;
}

.pn-stat-label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #6d7f89;
}

.pn-stat--pending .pn-stat-value { color: #b45309; }
.pn-stat--draft .pn-stat-value,
.pn-stat--err .pn-stat-value { color: #b42318; }
.pn-stat--failure .pn-stat-value { color: #c2410c; }
.pn-stat--ok .pn-stat-value { color: #3d6b54; }
.pn-stat--optum .pn-stat-value { color: #9a4b12; }

/* Feature Control - release switches for the system's modules. */
.fc-group { margin-bottom: 1.1rem; }
.fc-group-title {
    margin: 0 0 .85rem;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
}
.fc-list {
    display: flex;
    flex-direction: column;
    gap: .65rem;
}
.fc-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
    padding: .85rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}
.fc-item--off {
    border-color: #f0d3cd;
    background: #fdf6f4;
}
.fc-item-text { flex: 1 1 320px; min-width: 0; }
.fc-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .65rem;
}
.fc-item-name { font-weight: 600; color: #1f2d34; }
.fc-item-desc {
    margin: .3rem 0 0;
    font-size: .88rem;
    color: #64748b;
    line-height: 1.45;
}
.fc-item-meta {
    margin: .35rem 0 0;
    font-size: .78rem;
    color: #94a3b8;
}
.fc-badge {
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}
.fc-badge--on { background: #e4f2ea; color: #3d6b54; }
.fc-badge--off { background: #fbe7e3; color: #b42318; }
.fc-item-action { flex: 0 0 auto; margin: 0; }

/* ------------------------------------------------- saved filter sets ---- */
.sf-bar { display: inline-flex; flex: 0 0 auto; }
.sf-trigger {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
}
/* Sits on the primary button, so the badge reads against it rather than a grey bar. */
.sf-count {
    padding: 0 .35rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .25);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
}
/* The bar scrolls sideways, so the panel is anchored wide enough to stay readable. */
.sf-menu {
    min-width: 16rem;
    max-height: 22rem;
    overflow-y: auto;
    padding: .35rem;
}
.sf-group-label {
    padding: .35rem .5rem .2rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
}
.sf-empty {
    margin: 0;
    padding: .5rem;
    font-size: .82rem;
    color: #64748b;
    line-height: 1.4;
}
.sf-row {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .1rem .25rem;
}
.sf-apply {
    flex: 1 1 auto;
    padding: .3rem .4rem;
    border-radius: 6px;
    font-size: .85rem;
    color: #1f2d34;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sf-apply:hover { background: #f1f5f9; color: var(--db-primary-dark); }
.sf-del { margin: 0; flex: 0 0 auto; }
.sf-del-btn {
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1;
    padding: .15rem .35rem;
    cursor: pointer;
    border-radius: 6px;
}
.sf-del-btn:hover { background: #fee2e2; color: #b42318; }
.sf-save {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin: .35rem 0 0;
    padding: .5rem .5rem .25rem;
    border-top: 1px solid #e8eef1;
}

.pn-batch-detail .pn-linked-section {
    margin-top: 0;
    padding-top: .65rem;
    border-top: 1px solid var(--db-border, #dde5e9);
}

.pn-batch-detail .pn-clinical-head {
    margin-bottom: .45rem;
}

.pn-batch-detail .pn-clinical-head h3 {
    font-size: 1rem;
    margin: 0;
}

.pn-batch-detail .pn-filter-bar,
.pn-batch-detail .pn-cn-filters {
    margin-bottom: .45rem;
    padding: .45rem 0 .55rem;
}

.pn-batch-detail .pn-coding-banner {
    margin-bottom: .55rem;
}

.pn-batch-detail .pn-scroll {
    margin-top: 0;
}

.pn-section-count {
    font-weight: 400;
    font-size: .85rem;
    color: #6d7f89;
}

.pn-batch-detail .pn-comments {
    margin-top: 1rem;
    padding-top: .85rem;
    border-top: 1px solid var(--db-border, #dde5e9);
}

.pn-batch-detail .pn-comments h3 {
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6d7f89;
    margin: 0 0 .75rem;
}

@media (max-width: 900px) {
    .pn-overview-meta {
        grid-template-columns: 1fr;
    }

    .tr-overview-meta {
        grid-template-columns: 1fr;
    }

    .pn-stat-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .pn-detail-header-actions {
        margin-left: 0;
        width: 100%;
    }

    .cn-id-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .pn-stat-row,
    .tr-detail .tr-stat-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 800px) {
    .cn-meta-grid,
    .cn-field-grid {
        grid-template-columns: 1fr;
    }
}

/* ï¿½ï¿½ Coding Dashboard ï¿½ï¿½ */
.cd-page { max-width: 100%; } /* full page width, matches .cn-page / .pn-page */
.cd-header {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1rem;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.cd-title { margin: 0; font-size: 1.45rem; color: #1f2d34; }
.cd-sub { margin: .25rem 0 0; color: var(--db-text-muted); font-size: .88rem; max-width: 36rem; }
.cd-header-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.cd-stat-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .65rem;
    margin-bottom: 1.15rem;
}
.cd-stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .85rem 1rem;
    border: 1px solid var(--db-border);
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    color: inherit;
}
a.cd-stat:hover { border-color: #94a3b8; background: #f8fafc; }
.cd-stat-value { font-size: 1.55rem; font-weight: 650; line-height: 1.1; color: #1f2d34; }
.cd-stat-label { font-size: .78rem; color: var(--db-text-muted); text-transform: uppercase; letter-spacing: .02em; }
.cd-stat--pending .cd-stat-value { color: #b45309; }
.cd-stat--analyzed .cd-stat-value { color: #15803d; }
.cd-stat--error .cd-stat-value { color: #b91c1c; }
.cd-stat--failure .cd-stat-value { color: #c2410c; }
.cd-stat--processing .cd-stat-value { color: #1d4ed8; }
.cd-stat--stuck .cd-stat-value { color: #b45309; }
.cd-stat-row--jobs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 22rem;
}
.cd-panel-head {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem 1rem;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: .35rem;
}
.cd-panel-head .cd-panel-desc { margin-bottom: 0; max-width: 42rem; }
.cd-jobs-subtitle {
    margin: 1rem 0 .4rem;
    font-size: .92rem;
    font-weight: 650;
    color: #1f2d34;
}
.cd-jobs-empty {
    margin: 0 0 .5rem;
    font-size: .88rem;
    color: var(--db-text-muted);
}
.cd-jobs-table-wrap { overflow-x: auto; margin-bottom: .35rem; }
.cd-jobs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.cd-jobs-table th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--db-text-muted);
    font-weight: 600;
    padding: .4rem .5rem .4rem 0;
    border-bottom: 1px solid var(--db-border);
}
.cd-jobs-table td {
    padding: .55rem .5rem .55rem 0;
    border-bottom: 1px solid var(--db-border);
    vertical-align: top;
    color: #33464f;
}
.cd-jobs-table tr:last-child td { border-bottom: none; }
.cd-jobs-name { font-weight: 600; color: #1f2d34; text-decoration: none; }
.cd-jobs-name:hover { text-decoration: underline; }
.cd-jobs-file, .cd-jobs-msg {
    font-size: .78rem;
    color: var(--db-text-muted);
    margin-top: .15rem;
    max-width: 28rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cd-panel {
    border: 1px solid var(--db-border);
    border-radius: 8px;
    background: #fff;
    padding: 1rem 1.1rem 1.15rem;
    margin-bottom: 1rem;
}
.cd-panel-title { margin: 0 0 .35rem; font-size: 1.05rem; color: #1f2d34; }
.cd-panel-desc { margin: 0 0 .85rem; font-size: .88rem; color: var(--db-text-muted); line-height: 1.45; }
.cd-settings-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    margin-bottom: .85rem;
    font-size: .8rem;
    color: var(--db-text-muted);
}
.cd-mode-form { display: flex; flex-direction: column; gap: .65rem; align-items: flex-start; }
.cd-radio {
    display: flex;
    gap: .65rem;
    align-items: flex-start;
    padding: .65rem .75rem;
    border: 1px solid var(--db-border);
    border-radius: 8px;
    width: 100%;
    max-width: 40rem;
    cursor: pointer;
}
.cd-radio input { margin-top: .2rem; }
.cd-radio strong { display: block; font-size: .9rem; }
.cd-radio small { display: block; color: var(--db-text-muted); font-size: .8rem; margin-top: .15rem; }
.cd-prompt {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
    line-height: 1.45;
    min-height: 22rem;
}
.cd-prompt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    align-items: center;
    margin-top: .65rem;
}
.cd-prompt-readonly {
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    line-height: 1.45;
    max-height: 28rem;
    overflow: auto;
    padding: .75rem;
    border: 1px solid var(--db-border);
    border-radius: 6px;
    background: #f8fafc;
}
.cn-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
}
@media (max-width: 900px) {
    .cd-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .cd-stat-row { grid-template-columns: 1fr; }
}

/* YourPChoice Claude Dashboard — daily API call bars */
.ls-claude-usage-chart {
    display: flex;
    align-items: flex-end;
    gap: .2rem;
    height: 7.5rem;
    margin-top: .85rem;
    padding: .5rem .15rem 0;
    overflow-x: auto;
}
.ls-claude-usage-bar {
    flex: 1 0 1.1rem;
    min-width: 1.1rem;
    max-width: 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: .2rem;
}
.ls-claude-usage-fill {
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
}
.ls-claude-usage-day {
    font-size: .62rem;
    color: var(--db-text-muted);
    white-space: nowrap;
}

.cd-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin-bottom: .85rem;
    max-width: 40rem;
}
.cd-field--wide { grid-column: 1 / -1; }
.cd-label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--db-text-muted);
    margin-bottom: .25rem;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.cd-check {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .4rem;
    font-size: .82rem;
    color: var(--db-text-muted);
}
.cd-mode-block {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    margin-bottom: .85rem;
}
.cd-label-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
}
.cd-label-row .cd-label { margin-bottom: 0; }
.cd-info-btn {
    padding: .15rem .55rem;
    font-size: .75rem;
    line-height: 1.2;
}
.cd-guide-table th {
    font-size: .78rem;
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
}
.cd-guide-table td {
    font-size: .85rem;
    vertical-align: middle;
}
.cd-guide-note {
    font-size: .75rem;
    color: #64748b;
    margin-top: .1rem;
}
.cd-guide-footnote {
    margin-top: 1rem;
    font-size: .8rem;
    line-height: 1.45;
}
.cd-settings-form .cd-radio { max-width: 40rem; }
@media (max-width: 700px) {
    .cd-field-grid { grid-template-columns: 1fr; }
}
.cd-apikey-wrap {
    display: flex;
    gap: .4rem;
    align-items: center;
}
.cd-apikey-wrap .form-control { flex: 1; }
.cd-apikey-toggle { white-space: nowrap; }
.cn-coding-progress {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border: 1px solid #fde68a;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
}
.cn-coding-progress[hidden] { display: none !important; }
.cn-coding-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #fcd34d;
    border-top-color: #b45309;
    border-radius: 50%;
    animation: cn-spin .7s linear infinite;
    flex: 0 0 auto;
}
.cn-coding-progress-text {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}
.cn-coding-progress-text strong { font-size: .9rem; }
.cn-coding-progress-text span { font-size: .82rem; opacity: .92; }
.cn-coding-count { font-weight: 600; }
@keyframes cn-spin { to { transform: rotate(360deg); } }

/* ÎÃ¶ÃÎÃ¶Ã Transaction Reports ÎÃ¶ÃÎÃ¶Ã */
.tr-badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 700;
}
.tr-badge.build { background: #dcfce7; color: #166534; }
.tr-badge.nonbuild { background: #ffedd5; color: #9a3412; }

.tr-mode-bar {
    display: inline-flex;
    gap: .25rem;
    padding: .25rem;
    background: #f1f5f9;
    border-radius: 10px;
    margin: .75rem 0 1rem;
}
.tr-mode {
    padding: .4rem .9rem;
    border-radius: 8px;
    font-size: .86rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
}
.tr-mode.active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}
.tr-mode:hover { color: #0f172a; }

.tr-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem 1.35rem;
    margin: 0;
}
.tr-meta-grid > div {
    padding: .35rem 0;
    min-width: 0;
}
.tr-meta-grid dt {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    margin: 0 0 .35rem;
}
.tr-meta-grid dd {
    margin: 0;
    font-weight: 600;
    color: #0f172a;
    font-size: .92rem;
    line-height: 1.35;
    word-break: break-word;
}

.tr-content-card {
    padding: 1.35rem 1.5rem 1.5rem !important;
    border-radius: 12px;
}
.tr-content-card .tr-edit-form {
    margin-top: 1.25rem;
    padding-top: 1.1rem;
    border-top: 1px solid #e2e8f0;
}

.tr-filter-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .85rem;
    align-items: center;
}
.tr-filter-bar .form-control,
.tr-filter-bar .form-select {
    max-width: 170px;
}
.tr-filter-bar #tr-search {
    max-width: 260px;
    flex: 1 1 200px;
}

.tr-open-actions {
    margin-top: 1rem;
    padding-top: .85rem;
    border-top: 1px solid #e2e8f0;
}

.tr-modal[hidden] { display: none !important; }
.tr-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.tr-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}
.tr-modal-panel {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem 1.4rem 1.4rem;
    width: min(480px, calc(100vw - 2rem));
    box-shadow: 0 20px 40px rgba(15, 23, 42, .18);
}
.tr-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.1rem;
    gap: .75rem;
}
.tr-modal-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

button.tr-open-tip,
button.tr-open-patient {
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
}


/* ÎÃ¶ÃÎÃ¶Ã Transaction Reports ÎÃ¶ÃÎÃ¶Ã */
.tr-badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 700;
}
.tr-badge.build { background: #dcfce7; color: #166534; }
.tr-badge.nonbuild { background: #ffedd5; color: #9a3412; }

.tr-mode-bar {
    display: inline-flex;
    gap: .25rem;
    padding: .25rem;
    background: #f1f5f9;
    border-radius: 10px;
    margin: .75rem 0 1rem;
}
.tr-mode {
    padding: .4rem .9rem;
    border-radius: 8px;
    font-size: .86rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
}
.tr-mode.active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}
.tr-mode:hover { color: #0f172a; }

.tr-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem 1.35rem;
    margin: 0;
}
.tr-meta-grid > div {
    padding: .35rem 0;
    min-width: 0;
}
.tr-meta-grid dt {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    margin: 0 0 .35rem;
}
.tr-meta-grid dd {
    margin: 0;
    font-weight: 600;
    color: #0f172a;
    font-size: .92rem;
    line-height: 1.35;
    word-break: break-word;
}

.tr-content-card {
    padding: 1.35rem 1.5rem 1.5rem !important;
    border-radius: 12px;
}
.tr-content-card .tr-edit-form {
    margin-top: 1.25rem;
    padding-top: 1.1rem;
    border-top: 1px solid #e2e8f0;
}

.tr-filter-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .85rem;
    align-items: center;
}
.tr-filter-bar .form-control,
.tr-filter-bar .form-select {
    max-width: 170px;
}
.tr-filter-bar #tr-search {
    max-width: 260px;
    flex: 1 1 200px;
}

.tr-open-actions {
    margin-top: 1rem;
    padding-top: .85rem;
    border-top: 1px solid #e2e8f0;
}

.tr-modal[hidden] { display: none !important; }
.tr-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.tr-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}
.tr-modal-panel {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem 1.4rem 1.4rem;
    width: min(480px, calc(100vw - 2rem));
    box-shadow: 0 20px 40px rgba(15, 23, 42, .18);
}
.tr-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.1rem;
    gap: .75rem;
}
.tr-modal-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

button.tr-open-tip,
button.tr-open-patient {
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
}


/* Transaction Report  details drawer */
.tr-drawer[hidden] { display: none !important; }
.tr-drawer {
    position: fixed;
    inset: 0;
    z-index: 1060;
}
.tr-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .4);
}
.tr-drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(380px, 92vw);
    background: #fff;
    box-shadow: 8px 0 32px rgba(15, 23, 42, .18);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    animation: tr-drawer-in .2s ease-out;
}
@keyframes tr-drawer-in {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}
.tr-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.15rem;
    background: var(--db-sidebar-bg, #0f2744);
    color: #fff;
}
.tr-drawer-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}
.tr-drawer-body {
    padding: 1.15rem 1.25rem;
    overflow: auto;
}
body.tr-drawer-open { overflow: hidden; }
.tr-lines-table { min-width: 1400px; }

/* Transaction Report  details drawer */
.tr-drawer[hidden] { display: none !important; }
.tr-drawer {
    position: fixed;
    inset: 0;
    z-index: 1060;
}
.tr-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .4);
}
.tr-drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(380px, 92vw);
    background: #fff;
    box-shadow: 8px 0 32px rgba(15, 23, 42, .18);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    animation: tr-drawer-in .2s ease-out;
}
@keyframes tr-drawer-in {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}
.tr-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.15rem;
    background: var(--db-sidebar-bg, #0f2744);
    color: #fff;
}
.tr-drawer-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}
.tr-drawer-body {
    padding: 1.15rem 1.25rem;
    overflow: auto;
}
body.tr-drawer-open { overflow: hidden; }
.tr-lines-table { min-width: 1400px; }

/* Login password show/hide */
.password-field {
    position: relative;
}
.password-field .form-control {
    padding-right: 2.75rem;
}
.password-toggle {
    position: absolute;
    right: .6rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: none;
    box-shadow: none;
    color: #94a3b8;
    padding: 0;
    line-height: 0;
    cursor: pointer;
    transition: color .15s ease;
}
.password-toggle:hover,
.password-toggle:focus {
    color: #475569;
    background: none;
    box-shadow: none;
    outline: none;
}
.password-toggle:focus-visible {
    color: #475569;
    outline: none;
}
.password-toggle:active {
    background: none;
    box-shadow: none;
}

/* Profile photo */
.profile-photo-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}
.profile-photo-preview {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--db-border);
    flex-shrink: 0;
}
.profile-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--db-primary-light, #e8f1f6);
    color: var(--db-primary-dark, #1e4a63);
    font-weight: 700;
    font-size: 1.25rem;
}
.user-avatar-img {
    object-fit: cover;
    padding: 0;
    background: transparent;
}

/* SNF notes: multi-file drop zone + upload queue */
.pn-dropzone {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1rem 1.1rem;
    border: 1px dashed #c6d3da;
    border-radius: 8px;
    background: #fbfdfe;
    color: #6d7f89;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.pn-dropzone:hover,
.pn-dropzone:focus-visible {
    border-color: #9fb4c0;
    background: #f6fafc;
    outline: none;
}
.pn-dropzone.is-dragover {
    border-color: var(--db-primary, #2b6a8b);
    background: #f2f8fb;
}
.pn-dropzone-icon {
    flex-shrink: 0;
    color: #8fa5b1;
}
.pn-dropzone-text {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    line-height: 1.35;
}
.pn-dropzone-text b {
    font-size: .86rem;
    font-weight: 600;
    color: #1f2d34;
}
.pn-dropzone-text span {
    font-size: .78rem;
    color: #8b9ca6;
}
.pn-dropzone-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.pn-queue {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.pn-queue-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: .6rem;
    padding: .45rem .6rem;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 6px;
    background: #fff;
    font-size: .8rem;
}
.pn-queue-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1f2d34;
    font-weight: 500;
}
.pn-queue-size {
    color: #9aabb4;
    font-size: .74rem;
    font-variant-numeric: tabular-nums;
}
.pn-queue-status {
    font-size: .74rem;
    font-weight: 600;
    color: #6d7f89;
}
.pn-queue-item.is-uploading .pn-queue-status { color: #2b6a8b; }
.pn-queue-item.is-done .pn-queue-status { color: #1f7a4d; }
.pn-queue-item.is-failed { border-color: #eccfcf; }
.pn-queue-item.is-failed .pn-queue-status { color: #b3261e; }
.pn-queue-remove {
    border: 0;
    background: none;
    color: #9aabb4;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .15rem;
    cursor: pointer;
}
.pn-queue-remove:hover { color: #b3261e; }

/* Add Report: centred card + choose-files row */
.pn-upload-page {
    max-width: 600px;
    margin-inline: auto;
}
.pn-upload-header {
    justify-content: center;
    position: relative;
}
.pn-upload-header .btn {
    position: absolute;
    left: 0;
}
.pn-upload-card {
    padding: 1.25rem 1.35rem 1.35rem;
}
.pn-upload-hint {
    text-align: center;
}
.pn-dropzone {
    flex-direction: column;
    text-align: center;
    gap: .5rem;
    padding: 1.4rem 1.1rem;
}
.pn-dropzone-text {
    align-items: center;
}
.pn-dropzone-or {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    max-width: 220px;
    color: #b3c2cb;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.pn-dropzone-or::before,
.pn-dropzone-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e4ebef;
}
.pn-upload-actions {
    display: flex;
    justify-content: center;
    gap: .6rem;
    margin-top: .35rem;
}
.pn-tag.gray { background: #eef2f5; color: #64748b; }

/* Directories */
.sidebar-group { margin: .1rem .6rem; }
.sidebar-group-toggle {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-group-toggle::-webkit-details-marker { display: none; }
.sidebar-group-toggle::after {
    content: '';
    width: .45rem;
    height: .45rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    opacity: .55;
    transition: transform .15s ease;
}
.sidebar-group[open] > .sidebar-group-toggle::after {
    transform: rotate(45deg);
}
.sidebar-subnav {
    display: flex;
    flex-direction: column;
    padding: .15rem 0 .35rem .35rem;
}
.sidebar-sublink {
    margin: .05rem 0 .05rem .35rem !important;
    padding: .4rem .65rem !important;
    font-size: .8125rem !important;
    font-weight: 450 !important;
}
.dir-page { max-width: 100%; } /* full page width, matches .cn-page / .pn-page */
.dir-header { margin-bottom: 1rem; }
.dir-title {
    margin: .35rem 0 .25rem;
    font-size: 1.45rem;
    font-weight: 650;
    color: #1f2d34;
}
.dir-sub { margin: 0; color: #64748b; font-size: .875rem; }
.dir-back {
    display: inline-block;
    font-size: .8rem;
    color: #64748b;
    text-decoration: none;
}
.dir-back:hover { color: #1f2d34; }
.dir-search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    align-items: center;
    margin-bottom: .85rem;
}
.dir-search-bar .form-control { max-width: 360px; }
.dir-toolbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: .85rem;
    overflow-x: auto;
}
/* The detail-page toolbar carries a whole edit form plus Remove, Merge and Billing exception.
   Inheriting the list toolbar's single scrolling line pushed the last buttons off the right edge,
   where they read as clipped text ("Remo…", "Billing ex…") with no hint that the bar scrolls.
   It wraps instead: each form stays on its own line, and the group falls onto the next row when
   the header runs out of width. */
/* One line. The toolbar carries the edit form plus Remove, Merge and Billing exception, and
   wrapping it pushed the second half onto its own row at 100% zoom. Instead of wrapping, the
   text inputs give up width - they are the only elastic thing here - so the whole set stays on
   one line and the buttons, which cannot usefully shrink, keep their size. */
.dir-toolbar-end {
    margin-bottom: 0;
    justify-content: flex-end;
    flex-wrap: nowrap;
    overflow-x: visible;
    min-width: 0;
}
.dir-toolbar-end .dir-toolbar-form {
    flex: 0 1 auto;
    min-width: 0;
}
/* Buttons and the merge picker hold their size; only the free-text fields flex. */
.dir-toolbar-end .dir-toolbar-form .btn { flex: 0 0 auto; white-space: nowrap; }
/* A button sitting directly in the toolbar (the YourPChoice email popup trigger) holds its size
   the same way the ones inside the forms do. */
.dir-toolbar-end > .btn { flex: 0 0 auto; white-space: nowrap; }
/* The name / codes / YourPChoice inputs are what make that bar overflow first. They keep a
   usable width but give ground before the buttons do. */
.dir-toolbar-end .dir-toolbar-form .form-control {
    width: auto;
    min-width: 90px;
    max-width: 190px;
    flex: 1 1 90px;
}
.dir-toolbar-end .dir-toolbar-form .form-select {
    width: auto;
    min-width: 130px;
    max-width: 240px;
    flex: 1 1 130px;
}
/* The title has to yield too, or it holds the row wide and the toolbar has nothing to take. */
.dir-header-row > div:first-child { min-width: 0; }
/* Title on the left, its one action pinned to the right of the same line. */
.dir-title-row {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    width: 100%;
    min-width: 0;
}
.dir-title-row > div:first-child { min-width: 0; }
.dir-title-action { flex: 0 0 auto; margin-left: auto; white-space: nowrap; }

/* =========================================================
   Small button dropdown (details/summary, no JS framework)
   ========================================================= */
.db-menu { position: relative; display: inline-block; }
.db-menu > summary { list-style: none; cursor: pointer; }
.db-menu > summary::-webkit-details-marker { display: none; }
.db-menu-toggle::after {
    content: "";
    display: inline-block;
    margin-left: .45rem;
    border: 4px solid transparent;
    border-top-color: currentColor;
    transform: translateY(2px);
}
.db-menu[open] .db-menu-toggle::after { transform: translateY(-2px) rotate(180deg); }
.db-menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + .35rem);
    min-width: 230px;
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .14);
    padding: .35rem;
    z-index: 40;
}
.db-menu-label {
    padding: .3rem .55rem .35rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #94a3b8;
}
.db-menu-item {
    display: block;
    padding: .45rem .55rem;
    border-radius: 7px;
    color: #1f2d34;
    font-size: .87rem;
    text-decoration: none;
    white-space: nowrap;
}
.db-menu-item:hover, .db-menu-item:focus {
    background: rgba(148, 163, 184, .18);
    color: #0f172a;
}

/* Gear beside the sidebar user: the account menu keeps only the profile, everything else
   lives on the Settings page. */
.sidebar-profile { display: flex; align-items: center; gap: .35rem; }
.sidebar-profile .sidebar-user-btn { flex: 1 1 auto; min-width: 0; }
/* Leaves the settings area and returns to the module nav. */
.sidebar-back {
    margin-bottom: .35rem;
    font-weight: 600;
    color: #64748b;
}
.sidebar-back:hover { color: var(--db-primary); }

.sidebar-settings-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: #64748b;
    border: 1px solid transparent;
    text-decoration: none;
}
.sidebar-settings-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sidebar-settings-btn:hover,
.sidebar-settings-btn.active {
    color: #1f2d34;
    background: rgba(148, 163, 184, .18);
    border-color: var(--db-border);
}
.dir-toolbar-form {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .45rem;
    margin: 0;
}
.dir-toolbar .form-control,
.dir-toolbar-form .form-control,
.dir-toolbar .form-select,
.dir-toolbar-form .form-select {
    width: 220px;
    max-width: 220px;
}
.dir-toolbar-form .form-select { width: 280px; max-width: 280px; }
.dir-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem;
}
.dir-map-card {
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}
.dir-map-head { margin-bottom: .65rem; }
.dir-map-title {
    margin: 0 0 .2rem;
    font-size: .92rem;
    font-weight: 650;
    color: #1f2d34;
}
.dir-map-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .45rem;
    margin-bottom: .5rem;
}
.dir-map-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .45rem;
    margin: 0;
}
.dir-map-field {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    margin: 0;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
}
.dir-map-field .form-control,
.dir-map-field .form-select { width: 140px; max-width: 140px; }
.dir-map-select {
    width: 120px;
    min-width: 120px;
}
.dir-map-inline { margin: 0 0 .25rem; }
.dir-map-remove { margin: 0; }
.dir-map-readonly {
    margin: 0 0 .35rem;
    font-size: .9rem;
    color: #1f2d34;
}
.dir-table { min-width: 0; }

/* Tab strip and its export buttons share one row. */
.dir-tab-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem .75rem;
    margin-bottom: .75rem;
}
.dir-tab-row .pn-tabs { margin-bottom: 0; }
/* space-between only separates the tabs and the exports while both share a line. Once the tab
   strip is wide enough to push this group onto its own row it is alone there, and without the
   auto margin it fell back to the left edge - the exports have to stay in the corner either way. */
.dir-tab-exports {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-left: auto;
}
.dir-tab-count { white-space: nowrap; margin-right: .25rem; }

/*
  A provider can hold thousands of notes. The tab scrolls in its own box with the header
  pinned, so the whole set is reachable by scrolling without losing the column names.
*/
.dir-tab-scroll {
    max-height: 62vh;
    overflow-y: auto;
    overflow-x: auto;
}
.dir-tab-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
}
.dir-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem 1.5rem;
}
.dir-meta-grid .pn-prop {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
}
.dir-meta-grid .pn-prop > span:last-child,
.dir-meta-grid .pn-prop > a {
    font-size: .92rem;
    color: #1f2d34;
    line-height: 1.35;
    word-break: break-word;
}
.dir-meta-grid .pn-prop-label {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
}
.dir-meta-grid .dir-source {
    align-self: flex-start;
}
.dir-footnote { margin: .65rem 0 0; color: #94a3b8; font-size: .78rem; }
.dir-source {
    display: inline-block;
    padding: .12rem .45rem;
    border-radius: .25rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}
.dir-source--coded { background: #dbeafe; color: #1e40af; }
.dir-source--txn { background: #fef3c7; color: #92400e; }
.dir-source--both { background: #dcfce7; color: #166534; }
.dir-color-dot {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.08);
}
.dir-inline-link {
    color: #0f5f6b;
    text-decoration: none;
    border-bottom: 1px dotted rgba(15,95,107,.35);
}
.dir-inline-link:hover {
    color: #0a3f47;
    border-bottom-color: currentColor;
}
.dir-profile-link {
    display: inline-block;
    margin-top: .25rem;
    font-size: .72rem;
    color: #0f5f6b;
    text-decoration: none;
}
.dir-profile-link:hover { text-decoration: underline; }
.dir-manage-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    align-items: center;
    margin-bottom: .85rem;
}
.dir-manage-bar .form-control { max-width: 280px; }

/* Keep Coded Notes filter actions aligned with the SNF Notes filter bar. */
.pn-cn-filters > .cn-date-filter-form,
.pn-cn-filters > .cn-sort-form,
.pn-cn-filters > #cn-reset-filters {
    flex: 0 0 auto;
}
.pn-cn-filters #cn-reset-filters,
.pn-cn-filters .cn-sort-form .form-select,
.pn-filter-bar .pn-filter-reset {
    min-height: 31px;
    white-space: nowrap;
}

.tr-detail .tr-stat-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tr-stat-link {
    color: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tr-stat-link:hover {
    color: inherit;
    border-color: var(--db-primary);
    box-shadow: 0 2px 8px rgba(15, 95, 107, .12);
    transform: translateY(-1px);
}
.tr-stat-link.active {
    border-color: var(--db-primary);
    box-shadow: 0 0 0 2px rgba(15, 95, 107, .1);
}
.tr-line-field-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.tr-patient {
    max-width: 1080px;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.tr-patient-header {
    display: flex;
    align-items: flex-start;
    gap: .75rem 1rem;
    background: #fff;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 8px;
    padding: 1rem 1.15rem 1.1rem;
}
.tr-patient-heading { min-width: 0; flex: 1; }
.tr-patient-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .65rem;
}
.tr-patient-name {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
    line-height: 1.2;
}
.tr-patient-sub {
    margin: .3rem 0 0;
    color: #64748b;
    font-size: .85rem;
}
.tr-patient-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .65rem;
    margin: 0;
    padding: .85rem;
    background: #f7f9fa;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 8px;
}
.tr-patient-summary-item {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 6px;
    padding: .7rem .8rem;
}
.tr-patient-section {
    background: #fff;
    border: 1px solid var(--db-border, #dde5e9);
    border-radius: 8px;
    padding: 1rem 1.15rem 1.15rem;
    margin: 0;
}
.tr-patient-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem .75rem;
    margin-bottom: .85rem;
}
.tr-patient-section-head .tr-patient-section-title { margin: 0; }
.tr-patient-section-title {
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6d7f89;
    margin: 0 0 .85rem;
}
.tr-patient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .85rem 1.15rem;
}
.tr-patient-field {
    display: flex;
    flex-direction: column;
    gap: .28rem;
    min-width: 0;
}
.tr-patient-field-wide { grid-column: 1 / -1; }
.tr-patient-label {
    font-size: .68rem;
    font-weight: 650;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #6d7f89;
}
.tr-patient-value {
    font-size: .92rem;
    font-weight: 600;
    color: #1f2d34;
    line-height: 1.35;
    word-break: break-word;
}
.tr-patient-value-strong { color: #0f172a; }
.tr-patient-empty,
.tr-patient-value:empty { color: #94a3b8; font-weight: 500; }
.tr-patient-alias { color: #94a3b8; font-weight: 500; }
.tr-patient-wrap { white-space: pre-wrap; }
.tr-patient-banner {
    margin: 0;
    padding: .85rem 1rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 500;
}
.tr-patient-banner-warn {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}
.tr-patient-coded .tr-patient-section-title { margin-bottom: 0; }
.tr-patient-input {
    width: 100%;
    max-width: 100%;
    margin-top: .15rem;
}
.tr-patient-name-input {
    font-size: 1.45rem;
    font-weight: 650;
    color: #1f2d34;
    max-width: 28rem;
    padding: .2rem .5rem;
}
.tr-patient-inline-input {
    width: 8rem;
    vertical-align: middle;
}
.tr-patient-hint {
    display: block;
    margin-top: .2rem;
    font-size: .72rem;
    color: #94a3b8;
}
.tr-patient-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0 0 1rem;
}
@media (max-width: 640px) {
    .tr-patient-header { flex-direction: column; }
    .tr-patient-summary { grid-template-columns: 1fr 1fr; }
}

/* CPT Dashboard */
.cpt-dash-page { max-width: 100%; } /* full page width; .cd-page sets this too, but this rule comes later */
.cpt-dash-filters { margin-bottom: 1rem; }
.cpt-stat-row { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cpt-dash-page .pn-table-wrap { overflow: hidden; }

/* The shared .pn-table forces a 1400px min-width for wide line tables;
   this narrow summary table must fit its own card instead. */
.cpt-dash-table {
    min-width: 0;
    table-layout: fixed;
}
.cpt-dash-table th,
.cpt-dash-table td {
    padding: .6rem .9rem;
    white-space: nowrap;
}
.cpt-dash-table td:last-child { width: auto; }
.cpt-dash-table tbody tr:last-child td { border-bottom: 0; }
.cpt-dash-code {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.cpt-dash-num { font-variant-numeric: tabular-nums; }
.cpt-bar {
    height: .5rem;
    border-radius: 999px;
    background: #edf2f4;
    overflow: hidden;
    width: 100%;
    min-width: 5rem;
}
.cpt-bar-fill {
    display: block;
    height: 100%;
    min-width: 2px;
    background: var(--db-primary, #0f5f6b);
    border-radius: inherit;
}
@media (max-width: 1100px) {
    .cpt-stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .cpt-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cpt-dash-table th:last-child,
    .cpt-dash-table td:last-child { display: none; }
}

/* =========================================================
   Quick date-range preset dropdown (shared filter control)
   ========================================================= */
.pn-filter-bar .db-range-preset,
.tr-filter-bar .db-range-preset { min-width: 130px; max-width: 170px; }

/* =========================================================
   Summary metric strip attached above a table
   (the SNF Notes "N file(s) · M patient(s)" treatment, reused
   by Coded Notes, Transaction Report, Demographics, Optum)
   ========================================================= */
.pn-summary-row {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: .35rem 1.15rem;
}
.pn-summary-metrics {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem 1.15rem;
    font-size: .85rem;
    font-weight: 500;
    color: #64748b;
}
.pn-summary-item {
    display: inline-flex;
    align-items: baseline;
    gap: .3rem;
    white-space: nowrap;
}
a.pn-summary-item {
    color: inherit;
    text-decoration: none;
}
a.pn-summary-item:hover {
    color: var(--db-primary, #0f5f6b);
}
a.pn-summary-item.is-active {
    color: var(--db-primary, #0f5f6b);
    font-weight: 600;
}
/* Numbers read at the same weight and colour as the rest of the line, so the
   whole strip matches the SNF Notes "N file(s) · M patient(s)" treatment. */
.pn-summary-item b,
.pn-summary-item .pn-summary-sub {
    color: inherit;
    font-weight: inherit;
    font-variant-numeric: tabular-nums;
}

/* Demographics / Optum stat strips size to their own card count. */
.demo-stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.optum-stat-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* Counts rendered as badges stay links without picking up link colours. */
a.tr-badge { text-decoration: none; }
a.tr-badge:hover { filter: brightness(.94); }

/* Coding dashboard: ?jobs=processing|stuck highlights the table it opens on. */
.cd-jobs-block { scroll-margin-top: 5rem; border-radius: 8px; }
.cd-jobs-block--focused {
    background: #f8fafc;
    box-shadow: 0 0 0 1px rgba(15, 95, 107, .18);
    padding: .25rem .75rem .5rem;
}
.cd-stat--focused {
    border-color: var(--db-primary);
    box-shadow: 0 0 0 2px rgba(15, 95, 107, .12);
}

/* Summary cards that act as filters rather than links. */
.pn-stat-btn {
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pn-stat-btn:hover {
    border-color: var(--db-primary);
    box-shadow: 0 2px 8px rgba(15, 95, 107, .12);
    transform: translateY(-1px);
}
.pn-stat-btn.is-active {
    border-color: var(--db-primary);
    box-shadow: 0 0 0 2px rgba(15, 95, 107, .1);
}

/* Manual provider merge panel (Directories > Provider) */
.dir-merge-panel {
    padding: .85rem 1rem;
    margin-bottom: .75rem;
}

.dir-merge-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
}

.dir-merge-copy {
    display: flex;
    flex-direction: column;
    margin-right: auto;
}

.dir-merge-form .form-select {
    width: auto;
    min-width: 260px;
    max-width: 420px;
}

/* Build exception: out of billing scope, not something to action - neutral, not a warning. */
.tr-badge.exception { background: #e2e8f0; color: #475569; }

/* Directory list filters (Providers / Nursing homes / Companies) */
.dir-list-filters {
    margin-bottom: .75rem;
    align-items: center;
}

.dir-list-filters .form-select {
    width: auto;
    min-width: 170px;
    max-width: 240px;
}

.dir-list-filters .dir-sub {
    margin-left: auto;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- bulk edit ---- */
/* Selection bar + dialog shared by every bulk-editable table (see _BulkEditBar.cshtml). */

.bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0 0 .75rem;
    padding: .6rem .9rem;
    border: 1px solid #bfdbfe;
    border-radius: .5rem;
    background: #eff6ff;
}

.bulk-bar[hidden] {
    display: none !important;
}

.bulk-bar-count {
    font-size: .9rem;
    color: #1e3a8a;
}

.bulk-bar-count strong {
    font-size: 1rem;
}

.bulk-bar-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.bulk-col {
    width: 2.25rem;
    text-align: center;
}

.pn-table tbody tr.bulk-row-selected > td {
    background: #eff6ff;
}

.bulk-help {
    margin: 0 0 1rem;
    font-size: .85rem;
    color: #64748b;
}

.bulk-fields {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.bulk-field {
    display: grid;
    grid-template-columns: 6rem 1fr;
    gap: .75rem;
    align-items: start;
    padding-bottom: .85rem;
    border-bottom: 1px solid #e2e8f0;
}

.bulk-field:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.bulk-field-toggle {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding-top: 1.75rem;
    font-size: .8rem;
    color: #475569;
}

.bulk-field-input .form-label {
    margin-bottom: .25rem;
    font-size: .85rem;
    font-weight: 600;
    color: #0f172a;
}

.bulk-field-hint {
    margin-top: .25rem;
    font-size: .78rem;
    color: #94a3b8;
}

.bulk-modal-warning {
    margin-right: auto;
    font-size: .85rem;
    color: #b91c1c;
}

.bulk-modal-warning[hidden] {
    display: none;
}

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

    .bulk-field-toggle {
        padding-top: 0;
    }
}

/* Coding Dashboard filter bar (reuses the coded-notes dashboard filter styles). */
.cd-filters {
    margin-bottom: 1rem;
}

.cd-filter-note {
    margin: 0 0 .85rem;
    font-size: .85rem;
    color: #475569;
}

/* ----------------------------------------------------------------- analytics ---- */
/* Workspace usage dashboard: quiet cards, generous whitespace, numbers first. */

/* Full width, the way .dir-page, .cn-page and .dash-home are. The 1180px cap with no auto
   margin left every pixel past it as dead space down the right-hand side on a wide screen;
   the card grids are auto-fit, so they simply use the width once it is given back. */
.an-page {
    padding: 1.5rem 1.75rem 2.5rem;
    max-width: 100%;
}

.an-head {
    margin-bottom: 2rem;
}

.an-title {
    margin: 0 0 .25rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
}

.an-sub {
    margin: 0;
    font-size: .9rem;
    color: #64748b;
}

.an-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 2rem 0 .85rem;
}

.an-section-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #0f172a;
}

.an-section-note {
    font-size: .8rem;
    color: #94a3b8;
}

.an-range {
    display: inline-flex;
    gap: .25rem;
    padding: .2rem;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    background: #f8fafc;
}

.an-range-btn {
    padding: .3rem .7rem;
    border-radius: .35rem;
    font-size: .82rem;
    color: #475569;
    text-decoration: none;
}

.an-range-btn:hover {
    background: #eef2f7;
    color: #0f172a;
}

.an-range-btn.active {
    background: #fff;
    color: #0f172a;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.an-card-row {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.an-card-row--two {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.an-card-row--three {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.an-card {
    padding: 1.1rem 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: .6rem;
    background: #fff;
}

.an-card--metric {
    text-align: center;
    padding: 1.4rem 1.25rem;
}

.an-metric-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: #0f172a;
}

.an-metric-delta {
    margin-top: .3rem;
    font-size: .82rem;
}

.an-up { color: #15803d; }
.an-down { color: #b91c1c; }
.an-flat { color: #94a3b8; }

.an-card-title {
    margin-bottom: .85rem;
    font-size: .85rem;
    font-weight: 600;
    color: #475569;
    text-align: center;
}

.an-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.an-list-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .85rem;
}

.an-list-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #0f172a;
}

.an-list-count {
    flex-shrink: 0;
    color: #94a3b8;
    font-size: .8rem;
}

.an-avatar {
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: #e8f0fe;
    color: #1a56db;
    font-size: .7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.an-empty {
    margin: 0;
    font-size: .82rem;
    color: #94a3b8;
    text-align: center;
}

.an-content-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(280px, 1.4fr);
    gap: 1rem;
}

.an-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.an-card--stat {
    display: flex;
    align-items: baseline;
    gap: .5rem;
}

.an-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0f172a;
}

.an-stat-label {
    font-size: .85rem;
    color: #64748b;
}

.an-spark {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 110px;
}

.an-spark-bar {
    flex: 1;
    min-width: 2px;
    background: #bfdbfe;
    border-radius: 1px 1px 0 0;
}

.an-spark-bar:hover {
    background: #60a5fa;
}

.an-spark-axis {
    display: flex;
    justify-content: space-between;
    margin-top: .4rem;
    font-size: .75rem;
    color: #94a3b8;
}

.an-footnote {
    margin-top: 1.5rem;
    font-size: .78rem;
    color: #94a3b8;
}

@media (max-width: 860px) {
    .an-content-grid {
        grid-template-columns: 1fr;
    }
}

/* --------------------------------------------------------- matching dashboard ---- */

.mr-page { padding: 1.25rem 1.5rem 2rem; }

.mr-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.mr-title { margin: 0 0 .25rem; font-size: 1.5rem; font-weight: 700; color: #0f172a; }
.mr-sub { margin: 0; font-size: .88rem; color: #64748b; max-width: 62ch; }

.mr-last {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: .82rem;
}
.mr-last-label { color: #94a3b8; }
.mr-last-value { color: #0f172a; font-weight: 600; }

.mr-stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}

.mr-stat {
    padding: .85rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.mr-stat--active { border-color: #bfdbfe; background: #eff6ff; }
.mr-stat--bad { border-color: #fecaca; background: #fef2f2; }

.mr-stat-value { font-size: 1.35rem; font-weight: 700; color: #0f172a; }
.mr-stat-label { font-size: .78rem; color: #64748b; }

.mr-warning {
    margin-bottom: 1rem;
    padding: .7rem .9rem;
    border: 1px solid #fde68a;
    border-radius: .5rem;
    background: #fffbeb;
    color: #92400e;
    font-size: .85rem;
}

.mr-filters { margin-bottom: 1rem; }

/* Notifications: week pager above the provider upload alerts. */
.nt-week-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
    margin-bottom: .9rem;
}
/* The week range and the Billing / Calendar toggle are one unit at the end of the row: which
   week you are looking at, and how a week is measured. The range takes the gap so the pair
   travels together - an auto margin on both would split it and leave a hole between them. */
.nt-week-range {
    flex-direction: row;
    align-items: baseline;
    gap: .35rem;
    margin-left: auto;
    white-space: nowrap;
}
.nt-week-mode {
    display: inline-flex;
    border: 1px solid var(--db-border);
    border-radius: 8px;
    overflow: hidden;
}
.nt-week-mode-opt {
    padding: .3rem .7rem;
    font-size: .8rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    background: #fff;
}
.nt-week-mode-opt + .nt-week-mode-opt { border-left: 1px solid var(--db-border); }
.nt-week-mode-opt.is-on { background: #eff6ff; color: #1e40af; }

.mr-status {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.mr-status--ok { background: #dcfce7; color: #166534; }
.mr-status--fail { background: #fee2e2; color: #991b1b; }
.mr-status--running { background: #dbeafe; color: #1e40af; }

/* ----------------------------- background actions live panel ---- */

.ba-live {
    margin-bottom: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.ba-live--busy {
    border-color: #bfdbfe;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, .08);
}
.ba-live-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .9rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.ba-live-title {
    margin: 0 0 .15rem;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}
.ba-live-sub {
    margin: 0;
    font-size: .8rem;
    color: #64748b;
}
.ba-live-dot {
    display: inline-block;
    width: .45rem;
    height: .45rem;
    margin: 0 .35rem;
    border-radius: 50%;
    background: #94a3b8;
    vertical-align: middle;
}
.ba-live--busy .ba-live-dot {
    background: #2563eb;
    animation: ba-pulse 1.4s ease-in-out infinite;
}
@keyframes ba-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}
.ba-live-updated { color: #94a3b8; }
.ba-live-list { padding: .35rem 0 .55rem; }
.ba-cat { padding: .35rem 1rem .15rem; }
.ba-cat-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #94a3b8;
    margin: .35rem 0 .25rem;
}
.ba-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .55rem .65rem;
    border-radius: 8px;
    margin-bottom: .25rem;
}
.ba-row.is-active { background: #eff6ff; }
.ba-row.is-idle { opacity: .78; }
.ba-row-main {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 220px;
}
.ba-row-name { font-size: .88rem; font-weight: 600; color: #0f172a; }
.ba-row-meta {
    display: flex;
    align-items: baseline;
    gap: .65rem;
    flex: 1;
    min-width: 200px;
    justify-content: flex-end;
}
.ba-depth {
    font-variant-numeric: tabular-nums;
    font-size: .82rem;
    font-weight: 700;
    color: #334155;
    min-width: 2.2rem;
    text-align: right;
}
.ba-detail {
    font-size: .8rem;
    color: #64748b;
    max-width: 42ch;
    text-align: right;
}
.ba-state {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}
.ba-state--idle { background: #f1f5f9; color: #64748b; }
.ba-state--queued { background: #fef3c7; color: #92400e; }
.ba-state--running { background: #dbeafe; color: #1e40af; }
.ba-state--paused { background: #e2e8f0; color: #475569; }
.ba-empty {
    margin: .75rem 1rem;
    font-size: .85rem;
    color: #94a3b8;
}
.ba-history-title {
    margin: 1.35rem 0 .65rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.mr-msg {
    margin-top: .2rem;
    font-size: .75rem;
    color: #94a3b8;
    max-width: 34ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ------------------------------------------- multi-select inside filter bars ---- */
/* The dashboards lay their filters out on a CSS grid, which gives each control a
   track to fill. The list pages use a horizontal flex bar instead, where .cn-ms has
   no basis of its own and collapses to zero width. Give it the same footprint the
   plain selects in those bars already have. */

.pn-filter-bar > .cn-ms,
.pn-cn-filters > .cn-ms,
.tr-filter-bar > .cn-ms {
    flex: 0 0 auto;
    min-width: 150px;
    max-width: 210px;
}

/* The dropdown is absolutely positioned; an overflow-scrolling bar would clip it.
   site.js always lifts open .cn-ms-menu panels to position:fixed. */
.pn-cn-filters .cn-ms-menu,
.pn-filter-bar .cn-ms-menu,
.tr-filter-bar .cn-ms-menu {
    z-index: 40;
}

/* Apply sits with the filters rather than being squeezed between them. */
.pn-filter-bar > .btn,
.pn-cn-filters > .btn,
.tr-filter-bar > .btn {
    flex: 0 0 auto;
}

/* Filter bars are single-line everywhere (see the .pn-filter-bar block above). The open
   multi-select panel is switched to position:fixed by initMultiSelects(), so the scroll box
   no longer clips it and the bar does not need to wrap. */
.pn-cn-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
}

.mr-historic {
    display: inline-block;
    padding: .05rem .35rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: .68rem;
    font-weight: 600;
}

.mr-historic-note {
    margin: 0 0 .85rem;
    padding: .6rem .9rem;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    background: #f8fafc;
    color: #475569;
    font-size: .82rem;
}

/* ------------------------------------ coded notes table with a select column ---- */
/* The patient column was styled as :first-child. Adding the bulk-select checkbox in
   front of it handed those 220px to the checkbox and left the patient name with the
   narrow, ellipsised default - which squeezed every column after it. Target the
   patient column by its own class, and give the checkbox column a real width so the
   fixed table layout stops stealing space from the rest. */

.cn-table th.bulk-col,
.cn-table td.bulk-col {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    padding-left: .5rem;
    padding-right: .5rem;
    overflow: visible;
    text-align: center;
}

.cn-table th.cn-col-patient,
.cn-table td.cn-col-patient {
    min-width: 220px;
    width: 220px;
    max-width: 260px;
}

.cn-table td.cn-col-patient {
    overflow: visible;
    white-space: normal;
}

/* The select column is extra width on top of what the columns already needed. */
.cn-table {
    min-width: 1720px;
}

/* The old positional rules must not win over the class-based ones above. */
.cn-table th:first-child:not(.cn-col-patient):not(.bulk-col),
.cn-table td:first-child:not(.cn-col-patient):not(.bulk-col) {
    min-width: 0;
    width: auto;
    max-width: none;
}

/* Column widths, matching how the EMR records table behaves.

   .cn-table used table-layout: fixed, which ignores the per-column min-width the view
   asks for and instead divides the width equally - every middle column landed on 88px
   and truncated to "Sta...", "Do...", "Phy...". Auto layout honours those min-widths
   and sizes to content, and .pn-scroll already provides the horizontal scroll. */
.cn-table {
    table-layout: auto;
    min-width: 1720px;
}

/* Ellipsis still applies to genuinely long values, just no longer to every heading. */
.cn-table th {
    white-space: nowrap;
}

/* Matching dashboard tiles are links, so they need the affordances of one. */
a.mr-stat {
    text-decoration: none;
    color: inherit;
    transition: border-color .12s, box-shadow .12s;
}

a.mr-stat:hover {
    border-color: #94a3b8;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

/* The tile whose filter is currently applied. */
.mr-stat--on {
    border-color: #0284c7;
    box-shadow: 0 0 0 1px #0284c7 inset;
}

/* Migration workflow */
.mig-steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.mig-step-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
}

.mig-step-card h2 {
    font-size: 1.05rem;
    margin: 0 0 .5rem;
}

.mig-facility-form {
    margin-top: .75rem;
}

.mig-facility-row {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-top: .35rem;
}

.mig-facility-row .form-control {
    flex: 1 1 280px;
    max-width: 480px;
}

.mig-bulk-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin: .75rem 0;
}

.mig-match-pct {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 4px;
    background: #fef3c7;
    font-weight: 600;
    font-size: .85rem;
}

.mig-match-pct.is-high {
    background: #bbf7d0;
}

.mig-match-pct.is-mid {
    background: #fde68a;
}

.mig-global-steps {
    margin-top: 1.25rem;
}

.mig-files-card {
    margin-bottom: 0;
}

.mig-files-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: .75rem;
}

.mig-files-header h2 {
    margin-bottom: .25rem;
}

.mig-files-filter {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 220px;
}

.mig-files-filter-label {
    font-size: .82rem;
    font-weight: 600;
    color: #64748b;
    margin: 0;
    white-space: nowrap;
}

.mig-files-filter .form-select {
    min-width: 200px;
}

.mig-tick-col {
    width: 3rem;
    text-align: center;
    vertical-align: middle;
}

.mig-step-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 700;
}

.mig-step-tick.is-done {
    background: #dcfce7;
    color: #15803d;
}

.mig-step-tick.is-pending {
    background: #f1f5f9;
    color: #94a3b8;
}

.mig-step-tick-icon {
    width: 1rem;
    height: 1rem;
}

.mig-step-tick-empty {
    line-height: 1;
}

.mig-facility-cell {
    font-size: .88rem;
    max-width: 220px;
}

.mig-facility-missing {
    color: #b45309;
    font-weight: 600;
}

.mig-facility-partial {
    color: #b45309;
}

.mig-files-empty {
    margin: .75rem 0 0;
}

.pn-pager,
.mig-files-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-top: .75rem;
}

.pn-pager-label {
    font-size: .85rem;
    color: #64748b;
}

.mig-file-cell {
    font-size: .85rem;
    max-width: 180px;
}

.mig-file-cell a {
    font-weight: 600;
}

.mig-step-lead {
    margin-bottom: .5rem;
}

.mig-rules-list {
    margin: 0 0 .75rem 1.1rem;
    padding: 0;
    font-size: .9rem;
    color: #475569;
}

.mig-rules-list li {
    margin-bottom: .25rem;
}

.mig-hint-banner {
    padding: .55rem .85rem;
    border-radius: 8px;
    font-size: .88rem;
    margin: .65rem 0;
}

.mig-hint-banner.is-warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.mig-hint-banner.is-danger {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.mig-summary-line {
    margin: 0 0 .5rem;
    font-size: .88rem;
}

.mig-summary-stat {
    display: inline-block;
    margin-right: .75rem;
    font-weight: 600;
}

.mig-summary-stat.is-ok { color: #15803d; }
.mig-summary-stat.is-warn { color: #b45309; }

.mig-proposal-table .mig-row-ok {
    background: #f0fdf4;
}

.mig-proposal-table .mig-row-warn {
    background: #fff7ed;
}

.mig-patient-name {
    font-weight: 600;
}

.mig-patient-meta {
    font-size: .82rem;
    margin-top: .15rem;
}

.mig-name-compare {
    margin-top: .25rem;
    font-size: .88rem;
}

.mig-name-label {
    display: block;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #64748b;
}

.mig-name-mismatch {
    color: #b91c1c;
    font-weight: 600;
}

.mig-match-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .35rem;
}

.mig-confidence-tag {
    display: inline-block;
    font-size: .75rem;
    font-weight: 600;
    padding: .1rem .4rem;
    border-radius: 4px;
}

.mig-confidence-tag.is-ok {
    background: #dcfce7;
    color: #166534;
}

.mig-confidence-tag.is-warn {
    background: #ffedd5;
    color: #9a3412;
}

.mig-facility-compare {
    font-size: .85rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.mig-field-diff {
    font-size: .82rem;
    max-width: 320px;
}

.mig-notion-upload-form {
    margin: .75rem auto 0;
    max-width: 40rem;
    text-align: center;
}

.mig-notion-upload-form .pn-upload-label,
.mig-notion-upload-form .pn-upload-help {
    text-align: center;
}

.mig-notion-upload-form .pn-upload-actions {
    margin-top: .75rem;
    justify-content: center;
}

.mig-notion-upload-form .pn-queue {
    text-align: left;
}

.mig-notion-recalc-all {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 40rem;
    margin: .75rem auto 0;
}

.mig-import-list {
    margin: .75rem 0 0;
    padding-left: 1.25rem;
}

.mig-notion-imports-table th:nth-child(2),
.mig-notion-imports-table td:nth-child(2),
.mig-notion-imports-table th:nth-child(3),
.mig-notion-imports-table td:nth-child(3) {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 5.5rem;
}

.mig-notion-imports-table th:last-child,
.mig-notion-imports-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

.mig-notion-imports-table td:last-child .btn + .btn {
    margin-left: .35rem;
}

.pn-migration-tag {
    flex-shrink: 0;
}

.pn-tag-group {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
}

.pn-tag-group .pn-tag,
.pn-tag-group .pn-company-tag,
.pn-tag-group .pn-migration-tag {
    flex-shrink: 0;
}

.pn-select-trigger .pn-tag + .pn-migration-tag,
.pn-company-tag + .pn-migration-tag,
.pn-tag-group .pn-tag + .pn-migration-tag {
    margin-left: 0;
}

.pn-upload-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 500;
}

/* ============================================================ one-line filter bars ====
   Every filter bar stays on one row and scrolls sideways instead of wrapping.

   This block sits at the END of the stylesheet on purpose. Several of these selectors are
   also set earlier in the file (.tr-filter-bar and .pn-cn-filters each appear more than
   once), and at equal specificity the last rule wins - so putting the intent here is what
   makes it hold, rather than chasing every earlier definition.

   An open dropdown would be clipped by the scroll box, so it is lifted to position:fixed
   by msPlaceMenu() in site.js (always — not only when a scroll ancestor is detected).
   ==================================================================================== */
.pn-filter-bar,
.pn-filter-bar,
.pn-filter-bar--single-line,
.pn-cn-filters,
.tr-filter-bar,
.filter-bar,
.cn-dash-filter-grid,
.cn-dash-filter-row,
.cn-dash-period,
.dir-toolbar-form {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    gap: .45rem;
    /* Room for the horizontal scrollbar so it never sits on top of the controls. */
    padding-bottom: .35rem;
    scrollbar-width: thin;
}

/* Without this the controls squeeze instead of the bar scrolling. */
.pn-filter-bar > *,
.pn-cn-filters > *,
.tr-filter-bar > *,
.filter-bar > *,
.cn-dash-filter-grid > *,
.cn-dash-filter-row > *,
.cn-dash-period > *,
.dir-toolbar-form > * { flex: 0 0 auto; }

.cn-dash-global-entities {
    margin: 0 0 .75rem;
}
.cn-dash-global-entities > .cn-ms {
    min-width: 150px;
    max-width: 210px;
}

/* The dashboards laid their filters on a grid, which gave each control a track to fill.
   On a flex row .cn-ms has no basis of its own, so it needs the same footprint back. */
.cn-dash-filter-grid > .cn-ms,
.cn-dash-filter-row > .cn-ms {
    min-width: 150px;
    max-width: 210px;
}
.cn-dash-filter-grid > .form-control,
.cn-dash-filter-grid > .form-select,
.cn-dash-filter-row > .form-control,
.cn-dash-filter-row > .form-select {
    width: auto;
    min-width: 140px;
    max-width: 210px;
}

/* The secondary row holds the date range and the buttons, which should sit at each end. */
.cn-dash-filter-row--secondary { justify-content: flex-start; }

.pn-filter-bar::-webkit-scrollbar,
.pn-cn-filters::-webkit-scrollbar,
.tr-filter-bar::-webkit-scrollbar,
.filter-bar::-webkit-scrollbar,
.cn-dash-filter-grid::-webkit-scrollbar,
.cn-dash-filter-row::-webkit-scrollbar { height: 6px; }
.pn-filter-bar::-webkit-scrollbar-thumb,
.pn-cn-filters::-webkit-scrollbar-thumb,
.tr-filter-bar::-webkit-scrollbar-thumb,
.filter-bar::-webkit-scrollbar-thumb,
.cn-dash-filter-grid::-webkit-scrollbar-thumb,
.cn-dash-filter-row::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}
.pn-filter-bar::-webkit-scrollbar-track,
.pn-cn-filters::-webkit-scrollbar-track,
.tr-filter-bar::-webkit-scrollbar-track,
.filter-bar::-webkit-scrollbar-track,
.cn-dash-filter-grid::-webkit-scrollbar-track,
.cn-dash-filter-row::-webkit-scrollbar-track { background: transparent; }

/* The audit bar stacks a label above each control, so it aligns from the bottom. */
.filter-bar { align-items: flex-end; }

/* Analytics tiles that drill into the audit log they were counted from. */
.an-card--link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.an-card--link:hover,
.an-card--link:focus-visible {
    border-color: var(--db-primary, #2f6f5f);
    box-shadow: 0 6px 16px rgba(15, 23, 42, .10);
    transform: translateY(-1px);
    color: inherit;
}

/* Audit log: what the current view is narrowed to, when arriving from an Analytics tile. */
.au-scope {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .5rem;
    margin-bottom: .75rem;
    padding: .55rem .8rem;
    border: 1px solid #dbe7f0;
    border-left: 3px solid var(--db-primary, #2f6f5f);
    border-radius: 8px;
    background: #f4f9fb;
    font-size: .85rem;
}
.au-scope-label { font-weight: 700; color: #475569; }
.au-scope-chip {
    padding: .12rem .5rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #1f2d34;
    font-weight: 600;
    font-size: .8rem;
}
.au-scope-count { color: #64748b; }
.au-scope-clear { margin-left: auto; font-weight: 600; }

/* Analytics rows that drill into the audit log. */
.an-list-row--link { padding: 0; }
.an-list-hit {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .5rem .25rem;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}
.an-list-hit:hover,
.an-list-hit:focus-visible { background: #f1f5f9; color: inherit; }
.an-list-hit .an-list-name { flex: 1 1 auto; min-width: 0; }

/* Missing Patient IDs — nursing home breakdown + upload tables
   (override shared .pn-table 1400px min-width so columns stay aligned) */
.mpi-nh-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .5rem;
    padding: .85rem .95rem .25rem;
}
.mpi-section-intro {
    padding: .85rem .95rem 0;
}
.mpi-section-intro .pn-section-title { margin: 0 0 .35rem; font-size: 1rem; }
.mpi-section-intro .text-muted { margin: 0 0 .75rem; }
.mpi-compact-table {
    min-width: 0 !important;
    width: 100%;
    table-layout: auto;
}
.mpi-compact-table th,
.mpi-compact-table td {
    padding: .65rem .95rem;
}
.mpi-compact-table tbody tr:last-child td { border-bottom: 0; }
.mpi-nh-table col.mpi-nh-col-name { width: auto; }
.mpi-nh-table col.mpi-nh-col-count { width: 6.5rem; }
.mpi-nh-table col.mpi-nh-col-actions { width: 11.5rem; }
.mpi-nh-table th:nth-child(2),
.mpi-nh-table td:nth-child(2) {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.mpi-nh-table th:nth-child(3),
.mpi-nh-table td:nth-child(3) {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}
.mpi-nh-table td:nth-child(3) .btn + .btn {
    margin-left: .35rem;
}
.mpi-nh-link,
.mpi-nh-count {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}
.mpi-nh-link:hover,
.mpi-nh-count:hover {
    color: var(--db-primary, #2f6f5f);
    text-decoration: underline;
}
.mpi-nh-row--active {
    background: #f0f7f4;
}
.mpi-nh-row--active .mpi-nh-link,
.mpi-nh-row--active .mpi-nh-count {
    color: var(--db-primary, #2f6f5f);
}
.mpi-uploads-table th:nth-child(3),
.mpi-uploads-table td:nth-child(3) {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 5rem;
}
.mpi-uploads-table th:last-child,
.mpi-uploads-table td:last-child {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}

/* Revoke control on the pending-invitations list: a cross, not a word, so the row stays narrow. */
.inv-revoke-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 1.15rem;
    line-height: 1;
    color: #b91c1c;
    background: #fff;
    border: 1px solid #fecaca;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
}
.inv-revoke-btn:hover { background: #fef2f2; border-color: #f87171; }
.inv-revoke-btn:focus-visible { outline: 2px solid #ef4444; outline-offset: 2px; }

/* Second-level tabs inside a Trash tab (the directory catalogues). */
.trash-subtabs {
    margin: .9rem 1rem .25rem;
    font-size: .82rem;
}

/* Saved filters sit in the filter row now, so the control has to look and size like the
   selects beside it rather than like a page action button. */
.pn-filter-bar .sf-bar,
.pn-cn-filters .sf-bar,
.tr-filter-bar .sf-bar,
.filter-bar .sf-bar,
.cn-dash-filter-grid .sf-bar,
.cn-dash-filter-row .sf-bar {
    margin: 0;
    flex: 0 0 auto;
    align-self: center;
}
.pn-filter-bar .sf-trigger,
.pn-cn-filters .sf-trigger,
.tr-filter-bar .sf-trigger,
.filter-bar .sf-trigger,
.cn-dash-filter-grid .sf-trigger,
.cn-dash-filter-row .sf-trigger {
    padding: .25rem .6rem;
    min-height: 31px;
    font-size: .82rem;
    font-weight: 500;
    color: #334155;
    background: #fff;
    border: 1px solid var(--db-border);
    box-shadow: none;
    white-space: nowrap;
}
.pn-filter-bar .sf-trigger:hover,
.pn-cn-filters .sf-trigger:hover,
.tr-filter-bar .sf-trigger:hover,
.filter-bar .sf-trigger:hover,
.cn-dash-filter-grid .sf-trigger:hover,
.cn-dash-filter-row .sf-trigger:hover {
    border-color: var(--db-primary);
    color: var(--db-primary);
    background: #fff;
}

/* ---------------------------------------------------------------- Invite user card */
.invite-page {
    display: flex;
    justify-content: center;
    padding: 1.25rem 0 2.5rem;
}
.invite-card {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
    overflow: hidden;
}
.invite-card-head {
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    padding: 1.25rem 1.4rem 1.1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
    border-bottom: 1px solid var(--db-border);
}
.invite-card-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #eef2ff;
    color: var(--db-primary);
}
.invite-card-icon svg { width: 21px; height: 21px; }
.invite-card-title {
    margin: 0 0 .2rem;
    font-size: 1.1rem;
    font-weight: 650;
    color: #1f2d34;
}
.invite-card-sub { margin: 0; font-size: .85rem; color: #64748b; line-height: 1.45; }
.invite-card-body { padding: 1.25rem 1.4rem 1.4rem; }
.invite-field { margin-bottom: 1.15rem; }
.invite-label {
    display: block;
    margin-bottom: .4rem;
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
}
.invite-error { display: block; margin-top: .3rem; font-size: .78rem; color: #b91c1c; }

.invite-roles { display: grid; gap: .5rem; }
.invite-role {
    display: flex;
    gap: .65rem;
    align-items: flex-start;
    padding: .7rem .85rem;
    border: 1px solid var(--db-border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}
.invite-role:hover { border-color: #c7d2fe; background: #fbfcff; }
.invite-role input { margin-top: .18rem; flex: 0 0 auto; }
/* :has keeps the selected state on the label without any script. */
.invite-role:has(input:checked) { border-color: var(--db-primary); background: #f5f7ff; }
.invite-role:has(input:focus-visible) { outline: 2px solid var(--db-primary); outline-offset: 2px; }
.invite-role-body { display: flex; flex-direction: column; gap: .12rem; }
.invite-role-name { font-size: .9rem; font-weight: 600; color: #1f2d34; }
.invite-role-desc { font-size: .8rem; color: #64748b; line-height: 1.4; }

.invite-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding-top: .35rem;
    border-top: 1px solid var(--db-border);
    margin-top: .25rem;
    padding-top: 1.1rem;
}

/* Topbar clock: date on one line, running time plus the GMT offset under it. */
.topbar-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .1rem;
    line-height: 1.2;
}
.topbar-time {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    font-weight: 600;
    color: #334155;
    font-variant-numeric: tabular-nums;
}
.topbar-offset {
    padding: .05rem .4rem;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--db-primary);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
}

/* The dashboard is the widest page in the app; nothing should cap it short of the window.
   Stated last and explicitly so no earlier column width from the old narrow layout wins. */
.main-content { flex: 1 1 auto; min-width: 0; }
.page-content { width: 100%; }
.cd-page,
.cn-dash-page,
.cd-page.cn-dash-page {
    max-width: none;
    width: 100%;
}
.cn-dash-charts,
.cn-dash-panels-zero { width: 100%; }

/* Submission ids are short; the name-cell ellipsis was cutting them for the OPEN button. */
.ls-id-cell .pn-file-name {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
}

/* Notifications keeps its description under the heading rather than inside it, so the head
   block's own bottom margin was showing up as a hole between the title and that line. */
.mr-page:has(.nt-sub) .mr-head { margin-bottom: .3rem; }
.nt-sub { margin: 0 0 1rem; max-width: none; }

/* The dashboard's period block is a filter row like any other: View by, Date by, Exceptions,
   the week stepper, the dates and DOS all ride one scrolling line instead of stacking. */
.cn-dash-period {
    gap: .45rem .7rem;
    padding-bottom: .35rem;
    margin-bottom: 1rem;
}
.cn-dash-period::-webkit-scrollbar { height: 6px; }
.cn-dash-period::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

/* ====================================================================================
   Export CSV / Print PDF sit in the same place on every page: the far right of the
   page's action group, with nothing to their right. Ordering it here rather than in
   markup means a page can add a button anywhere and the exports still end up last.
   ==================================================================================== */
.pn-toolbar-actions,
.cd-header-actions,
.cn-header-actions,
.dir-header-actions,
.nt-head-actions,
.pn-detail-header-actions,
.mr-head-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}
.pn-toolbar-actions > .pn-export-link,
.cd-header-actions > .pn-export-link,
.cn-header-actions > .pn-export-link,
.dir-header-actions > .pn-export-link,
.nt-head-actions > .pn-export-link,
.pn-detail-header-actions > .pn-export-link,
.mr-head-actions > .pn-export-link,
.dir-toolbar-form > .pn-export-link {
    order: 99;
    /* Pushed to the right edge of the toolbar, not just to the end of the buttons - the pair
       reads as "the exports live in the corner" on every page that has them. */
    margin-left: auto;
}
/* Print sits immediately after CSV, so the pair always reads the same way, and only the first
   of the two takes the gap. */
.pn-export-link + .pn-export-link { order: 100; margin-left: 0; }
/* The page's primary action (Add Report / Upload roster / Upload report) leads that corner
   group, immediately to the left of Export CSV. Without an order of its own it kept order 0 and
   was left stranded beside the page title while the exports were pushed away from it. It is the
   first of the group, so it takes the gap and the exports give theirs up - two auto margins
   would split the free space and leave a hole in the middle of the set. */
.pn-toolbar-actions > .pn-new-btn { order: 98; margin-left: auto; }
.pn-toolbar-actions:has(> .pn-new-btn) > .pn-export-link { margin-left: 0; }
/* When Delete all / Recheck share the corner with exports, the whole group is one trailing unit. */
.pn-toolbar-actions > .pn-toolbar-end {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    margin-left: auto;
    order: 99;
}
.pn-toolbar-actions > .pn-toolbar-end > .pn-export-link {
    order: unset;
    margin-left: 0;
}
.pn-toolbar-actions > .pn-toolbar-end > .pn-export-link + .pn-export-link {
    order: unset;
    margin-left: 0;
}
/* Tab counts keep parentheses tight: "(211)" not "( 211 )" from .pn-tab flex gap. */
.ls-tab-count { white-space: nowrap; }
/* margin-left:auto only has somewhere to push if its row is actually full width. These action
   bars size to their content otherwise, which left the exports mid-row. Scoped with :has() so
   only a toolbar that actually carries exports / a trailing group is widened. */
.pn-toolbar-actions:has(> .pn-export-link),
.pn-toolbar-actions:has(> .pn-new-btn),
.pn-toolbar-actions:has(> .pn-toolbar-end),
.cd-header-actions:has(> .pn-export-link),
.cn-header-actions:has(> .pn-export-link),
.dir-header-actions:has(> .pn-export-link),
.nt-head-actions:has(> .pn-export-link),
.pn-detail-header-actions:has(> .pn-export-link),
.mr-head-actions:has(> .pn-export-link) {
    flex: 1 1 auto;
}

/* The saved-filter panel is a sibling of the filter form (it carries forms of its own, and a
   nested form would close the filter form early). This row puts the two back on one line. */
/* The row itself is what scrolls, not the filter form inside it. That is what lets Saved
   filters sit directly after Reset filters and travel with it when the bar is scrolled -
   pinned to the row's right edge it stayed put while Reset slid away underneath it. */
.pn-filter-row {
    display: flex;
    align-items: stretch;
    gap: .45rem;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
/* Saved filters is an action on the filter row, not one of the filters, so it comes last -
   after Reset filters - rather than in front of the search box. No auto margin: it has to stay
   welded to Reset instead of being pushed to the far edge. */
.pn-filter-row > .sf-bar {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: .75rem;
    order: 99;
}
.pn-filter-row > .sf-bar .sf-trigger { min-height: 35px; }
/* The scroll box moved up to the row, so the bar keeps its natural width and lets the row do
   the scrolling. Overriding overflow here is what keeps the two on one scrolling line. */
.pn-filter-row > .pn-filter-bar,
.pn-filter-row > .filter-bar,
.pn-filter-row > .tr-filter-bar { flex: 0 0 auto; min-width: 0; overflow: visible; }
/* Audit wraps its bar in the get form; the form itself has to carry the width. */
.pn-filter-row > form { flex: 0 0 auto; min-width: 0; overflow: visible; }

/* Background-work progress strip: log sheet sync (Settings) and the read-the-backlog button
   (Submissions) both poll a status endpoint and update this while the work runs. */
.ls-progress { margin-top: .4rem; }
.ls-progress[hidden] { display: none !important; }
.ls-progress--toolbar {
    display: inline-block;
    vertical-align: middle;
    margin-top: 0;
    max-width: min(360px, 42vw);
}
.ls-progress-card {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    min-width: 240px;
    padding: .45rem .65rem;
    border: 1px solid #cfe0ef;
    border-radius: 8px;
    background: #f4f9fc;
    box-shadow: none;
}
.ls-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.ls-progress-label {
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #3d5a6c;
}
.ls-progress--toolbar .ls-progress-stop {
    flex: 0 0 auto;
    padding: .1rem .45rem;
    font-size: .72rem;
    line-height: 1.2;
    text-decoration: none;
}
.ls-progress--toolbar .ls-progress-text {
    margin-top: 0;
    font-size: .75rem;
    line-height: 1.35;
    color: #475569;
    font-variant-numeric: tabular-nums;
}

/* On sheet: total patients + handwritten split, readable at a glance. */
.ls-onsheet {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .2rem;
    line-height: 1.2;
}
.ls-onsheet-total {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: #1e293b;
}
.ls-onsheet-hw {
    display: inline-block;
    padding: .1rem .4rem;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: .7rem;
    font-weight: 550;
    color: #475569;
    white-space: nowrap;
}

/* YourPChoice Provider Submissions / Review: keep date field + from/to on one line. */
.ls-filter-dates {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: .35rem;
    flex: 0 0 auto;
}
.ls-filter-dates > .form-select {
    width: auto;
    min-width: 7.5rem;
    max-width: 9.5rem;
}
.ls-filter-dates > input[type="date"].form-control {
    width: auto;
    min-width: 8.75rem;
    max-width: 10.5rem;
    display: inline-block;
}
.ls-filter-dates .ls-date-sep {
    flex: 0 0 auto;
    font-size: .78rem;
    font-weight: 600;
    color: #64748b;
    line-height: 1;
    padding: 0 .05rem;
    white-space: nowrap;
}
.pn-filter-bar .ls-filter-search {
    min-width: 12rem;
    max-width: 18rem;
}
#logsheet-index-filter.pn-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
}

/* Status cell head: the badge and the live percentage sit on one baseline. */
.ls-status-head { display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: baseline; }
.ls-status-pct { font-variant-numeric: tabular-nums; font-weight: 600; }
.ls-progress-track {
    height: 8px;
    border-radius: 999px;
    background: #dbe7ef;
    overflow: hidden;
}
.ls-progress-fill {
    height: 100%;
    background: var(--db-primary, #0d6efd);
    border-radius: 999px;
    transition: width .4s ease;
}
.ls-progress-text { margin-top: .25rem; }
/* Small, sitting under its button rather than a full-width strip. */
.ls-progress--compact { width: 220px; margin-top: .4rem; }
.ls-progress-text-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
}
.ls-progress-stop {
    flex: 0 0 auto;
    border: none;
    background: none;
    padding: 0;
    font-size: .78rem;
    color: #b91c1c;
    text-decoration: underline;
    cursor: pointer;
}
.ls-progress-stop:hover { color: #7f1d1d; }
.ls-progress-stop:disabled { color: var(--db-text-muted); cursor: default; text-decoration: none; }

/* SharePoint connection: label above each field (not a single-line filter bar). */
.ls-cred-form { margin: .35rem 0 0; width: 100%; }
.ls-cred-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem 1.25rem;
    width: 100%;
    max-width: none;
}
.ls-cred-field .form-label {
    margin-bottom: .3rem;
    font-size: .78rem;
    font-weight: 600;
}
.ls-cred-field .form-control,
.ls-cred-field .form-select {
    width: 100%;
    max-width: none;
}
.ls-cred-field--wide { grid-column: 1 / -1; }
.ls-cred-actions { margin-top: .85rem; }
@media (min-width: 1100px) {
    .ls-cred-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ls-cred-field--wide { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
    .ls-cred-grid { grid-template-columns: 1fr; }
}

/* Add company workbook: same labeled fields — stretch across the page. */
.ls-source-form { margin: .35rem 0 0; width: 100%; }
.ls-source-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem 1.25rem;
    width: 100%;
    max-width: none;
}
.ls-source-grid .ls-cred-field .form-control,
.ls-source-grid .ls-cred-field .form-select {
    width: 100%;
    max-width: none;
    min-width: 0;
}
@media (max-width: 1100px) {
    .ls-source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .ls-source-grid { grid-template-columns: 1fr; }
}

/* Inline Import from / Schedule editors on the company files table. */
.ls-schedule-form { display: none; }
.ls-inline-date {
    max-width: 10.5rem;
}
.ls-schedule-edit {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: .35rem;
    min-width: 11rem;
}
.ls-schedule-edit .form-select {
    max-width: 16rem;
}
.ls-schedule-toggle {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0;
    font-size: .78rem;
    font-weight: 500;
    color: var(--db-text-muted, #5b6573);
}
.ls-schedule-edit .btn {
    align-self: flex-start;
}

.ls-download-banner {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    margin: .65rem 0 .35rem;
    padding: .65rem .85rem;
    border: 1px solid var(--border, #d8dee6);
    background: #f8fafc;
    font-size: .9rem;
    line-height: 1.4;
}
.ls-download-banner .tr-badge { flex: 0 0 auto; margin-top: .1rem; }

/* Column-mapping confirm: inline under Company log sheet files. */
.ls-mapping-panel {
    margin-top: 1.25rem;
    padding: 1rem;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    background: #fff;
}
.ls-mapping-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .55rem;
}
.ls-mapping-panel .pn-page-sub { margin-bottom: .55rem; font-size: .85rem; }
.ls-mapping-date-filter {
    margin: 0 0 .75rem;
    padding: .65rem .75rem;
    border: 1px solid var(--db-border);
    border-radius: 8px;
    background: var(--db-surface);
    max-width: 28rem;
}
.ls-mapping-date-filter .form-label {
    margin-bottom: .3rem;
    font-size: .82rem;
    font-weight: 600;
}
.ls-mapping-date-filter .form-control {
    max-width: 12rem;
}
.ls-mapping-panel-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .85rem;
}
.ls-mapping-scroll {
    max-height: min(50vh, 22rem);
    overflow: auto;
}
.ls-mapping-table {
    width: 100%;
    table-layout: fixed;
    margin: 0;
}
.ls-mapping-table th,
.ls-mapping-table td {
    padding: .28rem .45rem;
    vertical-align: middle;
    font-size: .82rem;
    line-height: 1.25;
}
.ls-mapping-table th:nth-child(1),
.ls-mapping-table td:nth-child(1) { width: 32%; }
.ls-mapping-table th:nth-child(2),
.ls-mapping-table td:nth-child(2) { width: 48%; }
.ls-mapping-table th:nth-child(3),
.ls-mapping-table td:nth-child(3) { width: 20%; white-space: nowrap; }
.ls-mapping-table .pn-summary-sub { font-size: .72rem; }
.ls-mapping-table .tr-badge {
    font-size: .68rem;
    padding: .12rem .4rem;
    line-height: 1.2;
}
.ls-mapping-select {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    height: 1.7rem;
    padding: .1rem 1.6rem .1rem .4rem;
    font-size: .78rem;
    line-height: 1.2;
}

/* Log sheet submission details: side-by-side metadata + attachment preview */
.ls-detail-page {
    gap: .65rem;
}
.ls-detail-header {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .5rem .65rem;
    margin-bottom: .35rem;
    min-width: 0;
}
.ls-detail-back { flex: 0 0 auto; }
.ls-detail-identity {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .35rem;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    margin-left: .15rem;
}
.ls-detail-name {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 650;
    color: #1f2d34;
    letter-spacing: -0.02em;
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ls-detail-name-link {
    color: inherit;
    text-decoration: none;
}
.ls-detail-name-link:hover {
    color: var(--db-primary);
}
.ls-detail-header .ls-id-chip {
    display: inline-flex;
    align-items: center;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #eef4ff 0%, #e8f0fe 100%);
    border: 1px solid #c7d7fe;
    color: var(--db-primary-dark);
    font-size: .75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}
.ls-detail-header .tr-badge { flex: 0 0 auto; }
.ls-detail-header > .ls-dl-icon {
    flex: 0 0 auto;
    margin-left: .15rem;
}
.ls-crumb-facility {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    min-width: 0;
    max-width: 22rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .88rem;
}
.ls-crumb-facility .dir-inline-link,
.ls-detail-identity > .dir-inline-link {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .88rem;
}
.ls-crumb-sep {
    flex: 0 0 auto;
    color: #94a3b8;
}
.ls-dl-icon {
    display: inline-flex;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    flex: 0 0 auto;
    position: relative;
    vertical-align: middle;
}
.ls-dl-icon::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: .55rem;
    height: .55rem;
    border-radius: 999px;
    background: currentColor;
}
.ls-dl-icon--ok {
    background: #dcfce7;
    color: #16a34a;
}
.ls-dl-icon--ok::before {
    width: .35rem;
    height: .55rem;
    border-radius: 0;
    background: transparent;
    border-right: 2px solid #16a34a;
    border-bottom: 2px solid #16a34a;
    transform: rotate(45deg) translate(-1px, -1px);
}
.ls-dl-icon--pending {
    background: #fef3c7;
    color: #d97706;
}
.ls-dl-icon--pending::before {
    width: .45rem;
    height: .45rem;
    border: 2px solid #d97706;
    border-top-color: transparent;
    background: transparent;
    animation: ls-dl-spin .8s linear infinite;
}
.ls-dl-icon--err {
    background: #fee2e2;
    color: #dc2626;
}
.ls-dl-icon--err::before {
    width: .55rem;
    height: 2px;
    border-radius: 1px;
    background: #dc2626;
    transform: rotate(45deg);
    box-shadow: 0 0 0 0;
}
.ls-dl-icon--err::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: .55rem;
    height: 2px;
    border-radius: 1px;
    background: #dc2626;
    transform: rotate(-45deg);
}
.ls-dl-icon--muted {
    background: #e2e8f0;
    color: #94a3b8;
}
.ls-dl-icon--muted::before {
    width: .4rem;
    height: 2px;
    border-radius: 1px;
}
@keyframes ls-dl-spin { to { transform: rotate(360deg); } }

.ls-detail-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
}
@media (max-width: 1100px) {
    .ls-detail-header {
        flex-wrap: wrap;
    }
    .ls-detail-identity {
        flex: 1 1 calc(100% - 8rem);
    }
    .ls-detail-actions {
        flex-wrap: wrap;
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }
    .ls-detail-header > .ls-dl-icon {
        order: 4;
    }
}

.ls-detail-page .ls-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}
.ls-detail-page .ls-detail--with-viewer {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 46%);
}
.ls-detail-main {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    min-width: 0;
}

.ls-metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
    gap: .5rem;
}
/* Provider Submissions / Submission Review — Transaction Report-style status cards. */
.ls-stat-row {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    margin-bottom: .85rem;
}
.ls-review-stat-row {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    margin-bottom: .85rem;
}
.ls-stat-row .pn-stat--ok .pn-stat-label,
.ls-review-stat-row .pn-stat--ok .pn-stat-label { color: #3d6b54; }
.ls-stat-row .pn-stat--pending .pn-stat-label,
.ls-review-stat-row .pn-stat--pending .pn-stat-label { color: #b45309; }
.ls-stat-row .pn-stat--err .pn-stat-label,
.ls-review-stat-row .pn-stat--err .pn-stat-label { color: #b42318; }
@media (max-width: 1100px) {
    .ls-stat-row,
    .ls-review-stat-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .ls-stat-row,
    .ls-review-stat-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.ls-metric-row .pn-stat {
    padding: .7rem .55rem .65rem;
    border-radius: 10px;
    box-shadow: var(--db-card-shadow);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.ls-metric-row .pn-stat:hover {
    border-color: #c7d7fe;
    box-shadow: 0 4px 14px rgba(26, 86, 219, .08);
    transform: translateY(-1px);
}
.ls-metric-row .pn-stat-value {
    font-size: 1.35rem;
}
.ls-metric-of {
    font-size: .72rem;
    font-weight: 600;
    color: #94a3b8;
    margin-left: .1rem;
}
.ls-metric-text {
    font-size: .92rem !important;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* How a sheet was / will be read — self-parse vs Claude. */
.ls-parse-badge {
    display: inline-block;
    padding: .15rem .45rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .01em;
    line-height: 1.25;
    white-space: nowrap;
    border: 1px solid transparent;
}
.ls-parse--self {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}
.ls-parse--claude {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}
.ls-parse--pending {
    background: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}
.ls-parse--failed {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}
.ls-parse--manual,
.ls-parse--done,
.ls-parse--skipped {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}
.ls-metric-hint {
    display: block;
    margin-top: .1rem;
    font-size: .68rem;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.2;
}

.ls-status-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem .65rem;
    padding: .75rem .95rem;
    border-radius: 10px;
    border: 1px solid var(--db-border);
    background: #fff;
    box-shadow: var(--db-card-shadow);
    border-left-width: 4px;
}
.ls-status-banner--ok {
    border-left-color: #16a34a;
    background: linear-gradient(90deg, #f0fdf4 0%, #fff 42%);
}
.ls-status-banner--warn {
    border-left-color: #ea580c;
    background: linear-gradient(90deg, #fff7ed 0%, #fff 42%);
}
.ls-status-banner--muted {
    border-left-color: #94a3b8;
    background: linear-gradient(90deg, #f8fafc 0%, #fff 42%);
}
.ls-status-banner--neutral {
    border-left-color: var(--db-primary);
    background: linear-gradient(90deg, #eef4ff 0%, #fff 42%);
}
.ls-status-banner-msg {
    color: #334155;
    font-size: .9rem;
    line-height: 1.35;
}
.ls-status-banner-action {
    display: inline-flex;
    margin: 0;
}

.ls-panel {
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    padding: 1rem 1.1rem 1.15rem;
    box-shadow: var(--db-card-shadow);
}
.ls-panel-head {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-bottom: .65rem;
}
.ls-panel-title {
    margin: 0 0 .65rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #64748b;
}
.ls-panel-head .ls-panel-title { margin-bottom: 0; }
.ls-panel-sub {
    margin: -.25rem 0 .75rem;
    color: #64748b;
    font-size: .85rem;
    line-height: 1.45;
}
.ls-other-submission {
    margin-top: 1rem;
    padding-top: .9rem;
    border-top: 1px solid #eef2f7;
}
.ls-other-submission-title {
    margin: 0 0 .65rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #64748b;
    display: flex;
    align-items: baseline;
    gap: .45rem;
    flex-wrap: wrap;
}
.ls-other-submission-link {
    font-size: .85rem;
    font-weight: 650;
    letter-spacing: 0;
    text-transform: none;
}
.ls-other-submission-grid {
    margin: 0;
}
.ls-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.4rem;
    padding: 0 .45rem;
    border-radius: 999px;
    background: var(--db-primary-light);
    color: var(--db-primary-dark);
    font-size: .75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ls-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .55rem .65rem;
    margin: 0;
}
.ls-meta-item {
    display: flex;
    flex-direction: column;
    gap: .28rem;
    min-width: 0;
    padding: .7rem .8rem;
    border-radius: 8px;
    background: var(--db-surface);
    border: 1px solid #eef2f7;
}
.ls-meta-item--wide { grid-column: 1 / -1; }
.ls-meta-item dt {
    margin: 0;
    color: #64748b;
    font-weight: 650;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.ls-meta-item dd {
    margin: 0;
    color: #0f172a;
    font-size: .9rem;
    line-height: 1.4;
    word-break: break-word;
}
.ls-log-date-edit,
.ls-inline-edit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .5rem;
}
.ls-log-date-edit .form-control,
.ls-inline-edit .form-control {
    width: auto;
    min-width: 9.5rem;
}
.ls-inline-edit input[type="number"].form-control {
    min-width: 6.5rem;
}
/* Overlay app date format (e.g. "Aug, 7 2026") over locale-locked <input type="date"> text. */
.ls-date-input {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.ls-date-input-text {
    position: absolute;
    left: .55rem;
    right: 1.85rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .875rem;
    line-height: 1.4;
    color: #212529;
    z-index: 1;
}
.ls-date-input input[type="date"] {
    color: transparent;
    min-width: 10.75rem;
}
.ls-date-input input[type="date"]::-webkit-datetime-edit,
.ls-date-input input[type="date"]::-webkit-datetime-edit-fields-wrapper,
.ls-date-input input[type="date"]::-webkit-datetime-edit-text,
.ls-date-input input[type="date"]::-webkit-datetime-edit-month-field,
.ls-date-input input[type="date"]::-webkit-datetime-edit-day-field,
.ls-date-input input[type="date"]::-webkit-datetime-edit-year-field {
    color: transparent;
}
.ls-date-input input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 1;
    position: relative;
    z-index: 2;
}
.ls-meta-muted {
    color: #64748b;
    font-size: .82rem;
}
.ls-attachment-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
}
.ls-view-inline-btn { flex: 0 0 auto; }

.ls-detail-table { margin: 0; }
.ls-detail-table thead th {
    background: #f8fafc;
    font-size: .72rem;
    letter-spacing: .03em;
}
.ls-detail-table tbody tr:hover { background: #f8fbff; }
.ls-row-num {
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.ls-patient-name { font-weight: 600; color: #0f172a; }
.ls-cell-empty { color: #cbd5e1; }
.ls-patient-actions {
    white-space: nowrap;
    display: flex;
    gap: .35rem;
    align-items: center;
}
.ls-detail-table td .form-control-sm {
    min-width: 4.5rem;
    width: 100%;
}
.ls-source-pill {
    display: inline-flex;
    align-items: center;
    padding: .12rem .45rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: .72rem;
    font-weight: 650;
}
.ls-read-from {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .15rem;
}
.ls-confidence {
    color: #94a3b8;
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.ls-filter-confidence {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    flex: 0 0 auto;
}
.ls-filter-confidence-label {
    font-size: .72rem;
    font-weight: 650;
    color: #64748b;
    white-space: nowrap;
}
.ls-filter-confidence-input {
    width: 4.25rem;
}
.ls-filter-confidence-unit {
    font-size: .75rem;
    color: #94a3b8;
}
.ls-empty-state {
    padding: 1.25rem 1rem;
    text-align: center;
    border: 1px dashed #dbe3ee;
    border-radius: 8px;
    background: #fafbfc;
}
.ls-empty-state strong {
    display: block;
    margin-bottom: .25rem;
    color: #0f172a;
}
.ls-empty-state p {
    margin: 0;
    color: #64748b;
    font-size: .85rem;
}

.ls-add-patient { margin-top: 1rem; }
.ls-add-patient > summary {
    display: inline-block;
    list-style: none;
}
.ls-add-patient > summary::-webkit-details-marker { display: none; }
.ls-add-patient-form {
    margin-top: .75rem;
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 0;
}
.ls-record-meta-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 900px) {
    .ls-record-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    .ls-record-meta-grid { grid-template-columns: 1fr; }
}

.ls-detail-viewer {
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    box-shadow: var(--db-card-shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 7rem);
    min-height: 560px;
    max-height: calc(100vh - 7rem);
    position: sticky;
    top: 1rem;
    overflow: hidden;
}
.ls-detail-viewer--empty {
    height: auto;
    min-height: 240px;
    max-height: none;
    justify-content: center;
}
.ls-viewer-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem .85rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    flex: 0 0 auto;
}
.ls-viewer-title {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}
.ls-viewer-title strong { font-size: .9rem; color: #0f172a; }
.ls-viewer-title .pn-summary-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.ls-viewer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    flex: 0 0 auto;
}
.ls-viewer-frame {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: #e2e8f0;
}
.ls-viewer-frame--image {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: #0f172a;
    padding: .75rem;
}
.ls-viewer-pdf {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #e2e8f0;
}
.ls-viewer-frame--image .ls-viewer-pdf { display: none; }
.ls-viewer-fallback {
    margin: 1.25rem;
    color: #334155;
    font-size: .9rem;
}
.ls-viewer-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: auto;
}
.ls-viewer-frame:not(.ls-viewer-frame--image) .ls-viewer-image {
    position: absolute;
    inset: 0;
    margin: auto;
    padding: .75rem;
}
.ls-viewer-empty {
    padding: 1.5rem 1.25rem;
    text-align: center;
}
.ls-viewer-empty strong {
    display: block;
    margin-bottom: .35rem;
    color: #0f172a;
}
.ls-file-dialog {
    width: min(1100px, 96vw);
    height: min(92vh, 980px);
}
.ls-compare-dialog {
    width: min(96vw, 1600px);
    height: min(94vh, 980px);
    max-width: none;
}
.ls-compare-panes {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 0;
    background: #e2e8f0;
}
.ls-compare-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #fff;
    border-right: 1px solid #cbd5e1;
}
.ls-compare-pane:last-child { border-right: 0; }
.ls-compare-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.ls-compare-pane-head strong {
    font-size: .85rem;
    color: #0f172a;
}
.ls-compare-pane-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}
.ls-compare-pane-body .ls-modal-pdf {
    flex: 1;
    width: 100%;
    border: 0;
    background: #f8fafc;
}
.ls-compare-empty {
    margin: 1.5rem;
    color: #64748b;
    text-align: center;
}
@media (max-width: 900px) {
    .ls-compare-panes { grid-template-columns: 1fr; }
    .ls-compare-pane { border-right: 0; border-bottom: 1px solid #cbd5e1; min-height: 40vh; }
    .ls-compare-pane:last-child { border-bottom: 0; }
}
.ls-modal-pdf {
    flex: 1;
    width: 100%;
    border: 0;
    background: #f8fafc;
}
.ls-modal-image-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    padding: 1rem;
}
.ls-modal-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

@media (max-width: 1100px) {
    .ls-detail-page .ls-detail--with-viewer {
        grid-template-columns: 1fr;
    }
    .ls-detail-viewer {
        position: static;
        height: 70vh;
        min-height: 420px;
        max-height: 70vh;
    }
}
@media (max-width: 720px) {
    .ls-meta-grid { grid-template-columns: 1fr; }
    .ls-meta-item--wide { grid-column: auto; }
    .ls-detail-actions { justify-content: flex-start; }
}



/* YourPChoice Facility ID coverage on the submissions list. */
.ls-facility-badge {
    display: inline-block;
    padding: .15rem .45rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .01em;
    line-height: 1.25;
    white-space: nowrap;
    border: 1px solid transparent;
}
.ls-facility--full {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}
.ls-facility--partial {
    background: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}
.ls-facility--none {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}
.ls-facility--empty {
    background: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0;
}

/* YourPChoice Patients: match basis + clearer pager */
.ls-patients-page .ls-match-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .2rem;
    min-width: 7rem;
}
.ls-patients-page .ls-match-basis {
    display: inline-block;
    font-size: .72rem;
    line-height: 1.2;
    color: #64748b;
    white-space: nowrap;
}
.ls-patients-page .ls-facility-cell {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ls-patients-page .ls-col-remarks {
    max-width: 14rem;
    min-width: 10rem;
    font-size: .78rem;
    color: #475569;
    line-height: 1.35;
    white-space: normal;
}
.ls-patients-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
    margin-top: 0;
    padding: .85rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}
.ls-patients-pager .pn-pager-range {
    font-size: .875rem;
    color: #475569;
}
.ls-patients-pager .pn-pager-range strong {
    color: #0f172a;
    font-weight: 600;
}
.ls-patients-pager .pn-pager-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.ls-patients-pager .btn.disabled {
    pointer-events: none;
    opacity: .45;
}

/* ------------------------------------------------------------------
   Page titles - one format for every page.

   Each module had grown its own <h1> class, and they had drifted to ten
   different treatments: Analytics rendered at 25.4px, the invite page at
   16.0px - an <h1> smaller than the body text beside it - with three
   different colours in between. `dir-title` is the Patient Directory
   format the directories were standardised on, so it is the one every
   page uses now.

   Only the type is set here. Margins, flex and the ellipsis on the long
   detail names stay with the per-module classes, so no header row
   changes shape. The compound selectors at the end exist to outrank the
   nested rules that would otherwise still win on specificity.
   ------------------------------------------------------------------ */
main.page-content .an-title,
main.page-content .cn-title,
main.page-content .cd-title,
main.page-content .dash-brand-title,
main.page-content .pn-page-title,
main.page-content .dir-title,
main.page-content .mr-title,
main.page-content .trash-title,
main.page-content .cn-detail-name,
main.page-content .cn-patient-name,
main.page-content .pn-detail-title,
main.page-content .pn-detail-title-plain,
main.page-content .pn-upload-title,
main.page-content .ls-detail-name,
main.page-content .tr-patient-name,
main.page-content .invite-card-title,
main.page-content .page-header h1,
main.page-content .cn-detail-header .cn-detail-name,
main.page-content .cn-detail-header .cn-patient-name,
main.page-content .cn-detail-header .pn-detail-title-plain,
main.page-content .pn-batch-detail .pn-detail-header .pn-detail-title,
main.page-content .pn-batch-detail .pn-detail-header .pn-detail-title-plain {
    font-size: 1.45rem;
    font-weight: 650;
    color: #1f2d34;
    letter-spacing: -0.02em;
}

/* ------------------------------------------------------------ access review ----
   Settings → Access Review: one page answering "who can do X today". The tables
   reuse .db-table; only the summary tiles and the permission chips are new. */
.ar-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.ar-stat {
    background: #fff;
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    box-shadow: var(--db-card-shadow);
    padding: .8rem 1rem;
}

.ar-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.ar-stat-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--db-text-muted);
    margin-top: .15rem;
}

/* A count that is worth a second look - more than one Administrator, a user with no
   role, a permission nobody holds. Amber, not red: none of them is broken by itself. */
.ar-stat.warn .ar-stat-value { color: #92400e; }

/* Every tile is a way in: the counts open User Management or Roles & Permissions, and the
   two findings narrow this page. Anchors and buttons both need the card reset back to a
   card - a button carries its own font, centring and border otherwise. */
.ar-stat--link {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .12s, box-shadow .12s, transform .12s;
}

.ar-stat--link:hover,
.ar-stat--link:focus-visible {
    border-color: var(--db-primary);
    box-shadow: 0 4px 12px rgba(15, 23, 42, .1);
    transform: translateY(-1px);
    color: inherit;
    text-decoration: none;
}

.ar-stat--link:focus-visible { outline: 2px solid var(--db-primary); outline-offset: 2px; }

.ar-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.ar-generated { font-size: .78rem; color: var(--db-text-muted); white-space: nowrap; }

.ar-perm-chips { display: flex; flex-wrap: wrap; gap: .3rem; }

.ar-chip {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-size: .7rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Permissions that can be used to hand out further access, and the empty cases. */
.ar-chip.privileged { background: #fef3c7; color: #92400e; }
.ar-chip.none { background: #fee2e2; color: #991b1b; }

.ar-cat { margin-bottom: .5rem; }
.ar-cat:last-child { margin-bottom: 0; }

.ar-cat-name {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--db-text-muted);
    margin-bottom: .25rem;
}

.ar-details > summary {
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
    color: var(--db-primary);
    list-style: none;
}

.ar-details > summary::-webkit-details-marker { display: none; }
.ar-details > summary::before { content: "▸ "; }
.ar-details[open] > summary::before { content: "▾ "; }
.ar-details[open] > summary { margin-bottom: .45rem; }

.ar-footnote {
    padding: .65rem 1.25rem 1rem;
    font-size: .78rem;
    color: var(--db-text-muted);
}

/* Billing Dashboard cards: always side-by-side (overrides older/cached rules). */
.cn-dash-page .cn-dash-stack[data-progress-stack] {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 1rem !important;
    align-items: stretch !important;
    width: 100% !important;
}
.cn-dash-page .cn-dash-stack[data-progress-stack] > .cn-dash-stack-col {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100%;
}
.cn-dash-page .cn-dash-stack[data-progress-stack] > .cn-dash-stack-col[hidden] {
    display: none !important;
    flex: 0 0 0 !important;
}
.cn-dash-page .cn-dash-stack--single[data-progress-stack] > .cn-dash-stack-col {
    flex: 1 1 100% !important;
}
@media (max-width: 720px) {
    .cn-dash-page .cn-dash-stack[data-progress-stack] {
        flex-direction: column !important;
    }
    .cn-dash-page .cn-dash-stack[data-progress-stack] > .cn-dash-stack-col {
        flex: 1 1 100% !important;
    }
}
