/* Solvera Recuperative Care - brand tokens (docs/Solvera_Brand_Guide_Download.pdf) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --navy: #0C2E3E;
    --deep-navy: #082735;
    --gold: #C78F22;
    --dark-gold: #B47D12;
    --bright-gold: #D69D2F;
    --ivory: #FBF8F1;
    --cream: #F4EEE4;
    --beige: #E8DED0;
    --charcoal: #26363D;
    --muted: #5F6F76;
    --white: #FFFFFF;

    /* chart series (validated for colour-blind separation) */
    --series-available: #B47D12;
    --series-occupied: #1670A0;
    --series-unavailable: #A65E3B;

    --font-display: Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', Arial, sans-serif;
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--ivory);
    color: var(--charcoal);
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
}

a { color: inherit; }

/* ---------- Header ---------- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 40px;
    background: var(--white);
    border-bottom: 1px solid var(--beige);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.brand img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.7rem;
    color: var(--navy);
    line-height: 1;
}

.brand-sub {
    display: block;
    margin-top: 6px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--dark-gold);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.welcome {
    font-size: .95rem;
    color: var(--muted);
}
.welcome strong { color: var(--navy); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--navy);
    background: var(--white);
    color: var(--navy);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--navy); color: var(--white); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: .95rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }

/* Primary CTA: gold gradient, white bold text */
.btn-primary {
    background: linear-gradient(135deg, var(--bright-gold), var(--dark-gold));
    color: var(--white);
    box-shadow: 0 4px 12px rgba(180, 125, 18, .25);
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(180, 125, 18, .35); }

/* Secondary CTA: light background, navy outline */
.btn-secondary {
    background: var(--ivory);
    color: var(--navy);
    border-color: var(--navy);
}
.btn-secondary:hover { background: var(--cream); }

/* ---------- Main ---------- */
main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 36px 40px 48px;
}

.page-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 2.2rem;
    color: var(--navy);
    text-align: center;
    margin: 0 0 6px;
}

.page-tagline {
    text-align: center;
    color: var(--muted);
    margin: 0 0 26px;
}

.card {
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(12, 46, 62, .06);
    padding: 26px;
}

.summary {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    flex: 1 1 160px;
    background: var(--cream);
    border-radius: 10px;
    padding: 14px 18px;
}
.stat-label {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}
.stat-value {
    font-family: var(--font-display);
    font-size: 1.9rem;
    color: var(--navy);
    margin-top: 4px;
}
.stat .swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
}

.chart-wrap {
    position: relative;
    height: 380px;
}
.chart-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin: 0 0 8px;
}
.chart-branch-control { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; }
.chart-branch-control select {
    max-width: 240px;
    padding: 8px 10px;
    border: 1px solid var(--beige);
    border-radius: 8px;
    background: var(--ivory);
    color: var(--charcoal);
    font: inherit;
}

.empty-state {
    text-align: center;
    padding: 70px 20px;
    color: var(--muted);
}
.empty-state h3 {
    font-family: var(--font-display);
    color: var(--navy);
    font-weight: 600;
    margin: 0 0 8px;
}

/* ---------- Table ---------- */
.table-wrap {
    max-height: 380px;
    overflow: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .93rem;
}
th {
    position: sticky;
    top: 0;
    background: var(--navy);
    color: var(--white);
    text-align: left;
    font-weight: 600;
    padding: 12px 14px;
}
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--cream);
}
.bed-table td { border-bottom-color: #D1D5D8; }
tbody tr:hover { background: var(--ivory); }
.bed-row-action { width: 116px; padding-left: 4px; padding-right: 8px; text-align: right; white-space: nowrap; }
.bed-row-action form { display: inline-block; margin: 0 0 0 6px; vertical-align: middle; }
.btn-icon {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--beige);
    border-radius: 8px;
    background: var(--white);
    color: var(--navy);
    cursor: pointer;
}
.btn-icon:hover { background: var(--cream); }
.btn-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.warning-indicator {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #FFF0D6;
    color: #8A5F0C;
    font-size: .75rem;
    font-weight: 600;
}
.edit-bed-dialog { width: min(520px, 92vw); }
.edit-bed-dialog .form-group { margin-bottom: 14px; }
.edit-bed-dialog .form-group input,
.edit-bed-dialog .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--beige);
    border-radius: 9px;
    background: var(--ivory);
    font: inherit;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
}
.badge-unavailable { background: #F7E9E1; color: #8F472D; }
.badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: currentColor;
}
.badge-available { background: #F6ECD6; color: #8A5F0C; }
.badge-occupied { background: #E1EEF5; color: #125A80; }

.hidden { display: none !important; }

/* ---------- Bottom action bar ---------- */
.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 22px;
}

.toggle {
    display: inline-flex;
    background: var(--cream);
    border-radius: 10px;
    padding: 4px;
}
.toggle button {
    border: 0;
    background: transparent;
    padding: 9px 18px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}
.toggle button.active {
    background: var(--navy);
    color: var(--white);
}

/* ---------- Login ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    flex: 1;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.auth-card img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
}
.auth-card h1 {
    font-family: var(--font-display);
    color: var(--navy);
    font-weight: 600;
    margin: 12px 0 4px;
}
.auth-card p { color: var(--muted); margin: 0 0 22px; }
.form-group { text-align: left; margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--beige);
    border-radius: 10px;
    background: var(--ivory);
    font-family: var(--font-body);
    font-size: .95rem;
}
.form-group input:focus {
    outline: 2px solid var(--gold);
    border-color: var(--gold);
}
.auth-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.alert {
    background: #FBE9E7;
    color: #9B2C1F;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: .9rem;
    margin-bottom: 16px;
    text-align: left;
}
.back-link {
    display: inline-block;
    margin-top: 18px;
    color: var(--muted);
    font-size: .9rem;
}

footer {
    text-align: center;
    padding: 18px;
    font-size: .8rem;
    color: var(--muted);
    border-top: 1px solid var(--beige);
}

@media (max-width: 700px) {
    .site-header { padding: 14px 18px; }
    .brand-name { font-size: 1.3rem; }
    .brand-sub { display: none; }
    main { padding: 24px 18px; }
    .welcome { display: none; }
    .actions { flex-direction: column-reverse; gap: 14px; align-items: stretch; }
}

/* ---------- HRIS ---------- */
.muted { color: var(--muted); font-weight: 400; }
.card-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.card-title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--navy);
    margin: 0 0 14px;
}
.card-toolbar .card-title { margin: 0; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-danger {
    background: var(--white);
    color: #9B2C1F;
    border-color: #E3B4AD;
}
.btn-danger:hover { background: #FBE9E7; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.row-actions form { margin: 0; }
/* In a table, keep the actions cell a real cell so row lines and heights stay aligned */
td.row-actions { display: table-cell; text-align: right; white-space: nowrap; vertical-align: middle; }
td.row-actions > * { display: inline-block; vertical-align: middle; margin-left: 8px; }
td.row-actions > :first-child { margin-left: 0; }
.kyc-review td.row-actions { text-align: left; }
.badge-accepted { background: #E3F1E6; color: #2D6B3A; }
.badge-invalid { background: #F6ECD6; color: #8A5F0C; }
.badge-disabled { background: var(--cream); color: var(--muted); }
.alert-success { background: #E3F1E6; color: #2D6B3A; }
dialog {
    width: min(460px, 92vw);
    border: 0;
}
dialog::backdrop { background: rgba(8, 39, 53, .55); }
.form-group select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--beige);
    border-radius: 10px;
    background: var(--ivory);
    font-family: var(--font-body);
    font-size: .95rem;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.room-list { display: grid; gap: 12px; }
.room-item { border: 1px solid var(--beige); border-radius: 12px; padding: 14px 18px; transition: border-color .2s, box-shadow .2s; }
/* Room cards glow gold on hover and while open */
.room-item:hover, .room-item[open] { border-color: var(--gold, #C9971C); box-shadow: 0 0 0 3px rgba(201, 151, 28, .18), 0 6px 18px rgba(201, 151, 28, .25); }
.room-item > summary { cursor: pointer; }
.room-item summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.room-item summary::-webkit-details-marker { display: none; }
.room-item summary strong, .room-item summary small { display: block; }
.room-item summary strong { color: var(--navy); }
.room-item[open] summary { margin-bottom: 14px; }
.room-header-actions { display: flex; align-items: center; gap: 10px; }
.room-item > .muted { margin: 14px 0; }
.room-add-bed { display: flex; align-items: flex-end; gap: 12px; margin-top: 14px; }
.room-add-bed label { display: grid; flex: 1; gap: 6px; font-size: .85rem; font-weight: 600; }
.room-add-bed input, .room-add-bed select {
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--beige);
    border-radius: 10px;
    background: var(--ivory);
    font: inherit;
}
@media (max-width: 560px) {
    .chart-controls { align-items: flex-end; flex-direction: column; }
    .chart-branch-control { width: 100%; justify-content: space-between; }
    .room-add-bed { align-items: stretch; flex-direction: column; }
}
main > .back-link { margin: 0 0 12px; }

/* ---------- Submit Referral pop-up ---------- */
.referral-dialog {
    position: relative;
    width: min(960px, 94vw);
    max-height: 92vh;
    padding: 30px 30px 26px;
    border: 0;
    border-radius: 18px;
    background: var(--ivory);
    color: var(--navy);
    box-shadow: 0 20px 60px rgba(8, 39, 53, .35);
}
.referral-dialog::backdrop { background: rgba(8, 39, 53, .55); }

.dialog-close {
    position: absolute;
    top: 30px;
    right: 26px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: var(--white);
    color: var(--navy);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(12, 46, 62, .08);
}
.dialog-close:hover { background: var(--cream); }

.eyebrow {
    margin: 0 0 14px;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--dark-gold);
}
.referral-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 2.1rem;
    color: var(--navy);
    margin: 0 0 6px;
}
.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--navy);
    margin: 24px 0 6px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
}
.field { margin-bottom: 10px; }
.field label {
    display: block;
    font-weight: 700;
    font-size: .95rem;
    color: var(--navy);
    margin-bottom: 6px;
}
.field input,
.field select {
    width: 100%;
    height: 56px;
    padding: 0 18px;
    border: 1px solid var(--beige);
    border-radius: 12px;
    background: var(--white);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--charcoal);
}
.field select { cursor: pointer; }
.field input::placeholder { color: var(--muted); }
.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(199, 143, 34, .18);
}

.btn-outline {
    background: var(--white);
    color: var(--navy);
    border: 1.5px solid var(--navy);
    border-radius: 12px;
}
.btn-outline:hover { background: var(--cream); }
.btn-outline:disabled { opacity: .45; cursor: not-allowed; }
.btn-outline span { font-size: 1.3rem; font-weight: 400; line-height: 1; }
.btn-lg { padding: 16px 32px; font-size: 1.15rem; }

.hint { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }

.file-list { list-style: none; padding: 0; margin: 10px 0 0; }
.file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    max-width: 480px;
    padding: 8px 8px 8px 14px;
    margin-bottom: 6px;
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: 10px;
    font-size: .9rem;
}
.file-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-remove {
    flex: none;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: var(--cream);
    color: var(--navy);
    font-size: 1.1rem;
    cursor: pointer;
}
.file-remove:hover { background: #FBE9E7; color: #9B2C1F; }

.referral-dialog > div > form > .btn-lg { margin-top: 26px; }

.confirm {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 18px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
}
.confirm input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--dark-gold); }
.confirm + .hint { margin-top: 2px; }

.referral-footer { display: flex; justify-content: flex-end; margin-top: 30px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.referral-success { text-align: center; padding: 40px 10px 10px; }
.referral-success p { color: var(--charcoal); }
.success-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bright-gold), var(--dark-gold));
    color: var(--white);
    font-size: 2.2rem;
    line-height: 72px;
}

.hipaa-dialog { width: min(760px, 94vw); }
.hipaa-dialog .referral-title { font-size: 1.7rem; padding-right: 60px; }
.hipaa-body {
    max-height: 55vh;
    overflow-y: auto;
    padding: 18px 22px;
    margin-top: 14px;
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: 12px;
    color: var(--charcoal);
    line-height: 1.6;
}
.hipaa-body p { margin: 0 0 12px; }
.hipaa-body p:last-child { margin-bottom: 0; }

@media (max-width: 700px) {
    .grid-2 { grid-template-columns: 1fr; }
    .referral-dialog { padding: 22px 18px; }
    .referral-title { font-size: 1.6rem; padding-right: 50px; }
    .dialog-close { top: 20px; right: 16px; }
    .btn-lg { width: 100%; justify-content: center; }
}

/* ---------- Admin sidebar layout (HRIS) ---------- */
.admin-body { flex-direction: row; }

.sidebar {
    position: sticky;
    top: 0;
    flex: none;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--navy);
    color: var(--white);
    padding: 24px 16px;
    /* Fallback: if the menu cannot shrink, the whole sidebar scrolls instead of being cut off */
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .4) transparent;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 22px;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    text-decoration: none;
}
.sidebar-brand img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--white);
}
.sidebar-brand .brand-name { color: var(--white); font-size: 1.45rem; }
.sidebar-brand .brand-sub { color: var(--bright-gold); margin-top: 5px; }

.sidebar-brand, .sidebar-user { flex: none; }
/* Only the menu scrolls; the logo and the signed-in user stay in place. */
.sidebar-nav {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0 -8px 12px;
    padding: 0 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .4) transparent;
}
.sidebar-nav > * { flex: none; }
.sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .4); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .6); }
.sidebar::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
/* Short screens or zoomed-in browsers: scroll the whole sidebar so the account links and logout are always reachable */
@media (max-height: 760px) {
    .sidebar-nav { flex: none; overflow: visible; }
    .sidebar-user { padding-bottom: 8px; }
}
.sidebar-label {
    margin: 0 0 8px 12px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, .78);
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}
.sidebar-link svg { width: 20px; height: 20px; flex: none; }
.sidebar-link:hover { background: rgba(255, 255, 255, .07); color: var(--white); }
.sidebar-link.active {
    background: rgba(214, 157, 47, .16);
    border-left-color: var(--bright-gold);
    color: var(--white);
    font-weight: 600;
}
.sidebar-link.active svg { color: var(--bright-gold); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, .12);
}
.avatar {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--bright-gold), var(--dark-gold));
    font-weight: 700;
    font-size: .9rem;
}
.sidebar-user-info { flex: 1; min-width: 0; line-height: 1.25; }
.sidebar-user-info strong { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info small { color: rgba(255, 255, 255, .6); }
.sidebar-logout {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: rgba(255, 255, 255, .7);
}
.sidebar-logout:hover { background: rgba(255, 255, 255, .1); color: var(--white); }
.sidebar-logout svg { width: 18px; height: 18px; }

.admin-content { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 40px;
    background: var(--white);
    border-bottom: 1px solid var(--beige);
}
.admin-crumb {
    margin: 0;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--dark-gold);
}
.admin-title {
    margin: 2px 0 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.8rem;
    color: var(--navy);
}
.admin-main { max-width: 1200px; margin: 0; }
.admin-intro { margin: 0 0 20px; color: var(--muted); }
.admin-intro-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 20px; }
.admin-intro-row .admin-intro { margin: 0 0 0 auto; text-align: right; }
.sidebar-toggle { display: none; flex: none; }
.sidebar-scrim { display: none; }

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .sidebar-scrim.show {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(8, 39, 53, .45);
    }
    .sidebar-toggle { display: inline-flex; }
    .admin-topbar { padding: 16px 18px; }
    .admin-title { font-size: 1.4rem; }
}

/* ---------- Accept Referrals pop-up (admin) ---------- */
.pill {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    margin-left: 4px;
    border-radius: 999px;
    background: var(--white);
    color: var(--dark-gold);
    font-size: .8rem;
    font-weight: 700;
}

.referrals-admin { width: min(1240px, 96vw); }
.referrals-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 18px 0 16px;
}
.toggle .count {
    display: inline-block;
    min-width: 20px;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(12, 46, 62, .08);
    font-size: .75rem;
}
.toggle button.active .count { background: rgba(255, 255, 255, .2); }
.search-input {
    flex: 0 1 320px;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--beige);
    border-radius: 10px;
    background: var(--white);
    font-family: var(--font-body);
    font-size: .95rem;
}
.search-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199, 143, 34, .18); }

.referrals-table-wrap {
    max-height: 58vh;
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: 12px;
}
.referrals-table-wrap th:first-child,
.referrals-table-wrap th:last-child { border-radius: 0; }
.referrals-table-wrap td { vertical-align: middle; }
.referrals-table-wrap .row-actions { white-space: nowrap; }

.badge-ref-pending { background: #F6ECD6; color: #8A5F0C; }
.badge-ref-accepted { background: #E3F1E6; color: #2D6B3A; }
.badge-ref-declined { background: #FBE9E7; color: #9B2C1F; }

.referral-detail { width: min(820px, 94vw); }
.referral-detail .referral-title { padding-right: 60px; }
.detail-meta { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 20px;
    margin: 8px 0 0;
    padding: 18px 20px;
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: 12px;
}
.detail-grid dt {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}
.detail-grid dd { margin: 3px 0 0; color: var(--charcoal); font-weight: 500; overflow-wrap: anywhere; }
.detail-grid a { color: var(--navy); }
.referral-detail .file-list li { max-width: none; }
.detail-actions { gap: 10px; }

@media (max-width: 700px) {
    .detail-grid { grid-template-columns: 1fr; }
    .search-input { flex-basis: 100%; }
}

/* ---------- Referral date filter ---------- */
.date-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: -4px 0 16px;
    padding: 10px 14px;
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: 12px;
    color: var(--muted);
}
.date-filter > svg { width: 18px; height: 18px; flex: none; color: var(--dark-gold); }
.date-filter select,
.date-filter input[type="date"] {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--beige);
    border-radius: 8px;
    background: var(--ivory);
    color: var(--charcoal);
    font-family: var(--font-body);
    font-size: .9rem;
    font-weight: 500;
}
.date-filter select:focus,
.date-filter input[type="date"]:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199, 143, 34, .18); }
.date-custom { display: inline-flex; flex-wrap: wrap; gap: 10px; }

/* ---------- System log filters ---------- */
.log-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin: 0 0 16px;
}
.log-filters label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--navy); }
.log-filters select,
.log-filters input {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--beige);
    border-radius: 8px;
    background: var(--ivory);
    color: var(--charcoal);
    font-family: var(--font-body);
    font-size: .9rem;
}
.log-filters select:focus,
.log-filters input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199, 143, 34, .18); }
.log-filters .log-filter-summary { flex: 1 1 200px; }
.log-filters .btn-sm { height: 38px; }
.confirm-dialog { width: min(460px, 92vw); }
.confirm-dialog button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- System logs layout + who's signed in ---------- */
.admin-main.admin-main-wide { max-width: none; }
.logs-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.logs-main { min-width: 0; }
.login-counter { position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.login-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.login-list li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--beige); }
.login-list li > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.login-list small { font-size: .78rem; }
.login-name { font-weight: 600; color: var(--navy); }
.login-dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: #A8A29A; }
.login-state { align-self: flex-start; margin: 2px 0; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--cream); color: var(--muted); }
.login-status-online .login-dot { background: #2D9B4A; box-shadow: 0 0 0 3px rgba(45, 155, 74, .2); }
.login-status-online .login-state { background: #E3F1E6; color: #2D6B3A; }
.login-status-expired .login-dot { background: #D9A02B; }
.login-status-expired .login-state { background: #F6ECD6; color: #8A5F0C; }
.login-status-auto .login-state,
.login-status-offline .login-state { background: #F7E9E1; color: #8F472D; }

/* ---------- Idle logout warning ---------- */
.idle-warning {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 40px);
    padding: 14px 16px;
    border: 1px solid var(--gold);
    border-radius: 12px;
    background: var(--white);
    color: var(--navy);
    box-shadow: 0 10px 30px rgba(8, 39, 53, .2);
}
@media (max-width: 1100px) {
    .logs-layout { grid-template-columns: 1fr; }
    .login-counter { position: static; max-height: none; }
}
.date-custom label { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--navy); }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Sidebar extras (all signed-in users) ---------- */
.sidebar-label-gap { margin-top: 18px; }
/* ---------- Notification bell ---------- */
.notif { position: relative; margin-left: auto; }
.notif-bell {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--beige);
    border-radius: 50%;
    background: var(--white);
    color: var(--navy);
    cursor: pointer;
}
.notif-bell:hover, .notif-bell[aria-expanded="true"] { background: var(--cream); }
.notif-bell svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notif-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid var(--white);
    border-radius: 999px;
    background: #C0392B;
    color: var(--white);
    font-size: .68rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}
.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 50;
    width: min(380px, calc(100vw - 32px));
    border: 1px solid var(--beige);
    border-radius: 14px;
    background: var(--white);
    box-shadow: 0 16px 40px rgba(8, 39, 53, .18);
    overflow: hidden;
}
.notif-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--beige);
    color: var(--navy);
}
.notif-panel-head > span { display: flex; gap: 12px; }
.notif-list { max-height: 60vh; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.notif-list li + li { border-top: 1px solid var(--cream); }
.notif-item {
    display: flex;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    background: var(--white);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.notif-item:hover { background: var(--ivory); }
.notif-item.unread { background: #FBF4E6; }
.notif-item.unread:hover { background: #F6ECD6; }
.notif-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #E1EEF5;
    color: #125A80;
}
.notif-item[data-kind="Announcement"] .notif-icon,
.notif-item[data-kind="Discharge"] .notif-icon { background: #F6ECD6; color: #8A5F0C; }
.notif-item[data-kind="Alert"] .notif-icon,
.notif-item[data-kind="Urgent"] .notif-icon,
.notif-item[data-kind="Urgent for you"] .notif-icon { background: #FBE9E7; color: #9B2C1F; }
.notif-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notif-text { display: grid; gap: 2px; min-width: 0; }
.notif-kind { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dark-gold); }
.notif-text strong { color: var(--navy); font-size: .9rem; overflow-wrap: anywhere; }
.notif-body { color: var(--charcoal); font-size: .84rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.notif-text .muted { font-size: .75rem; }
.notif-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--muted); }
.notif-detail { width: min(560px, 92vw); }
.notif-detail-kind { margin: 0 0 4px; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--dark-gold); }
.notif-detail .card-title { margin-bottom: 4px; }
.notif-detail-body { white-space: pre-wrap; color: var(--charcoal); line-height: 1.55; overflow-wrap: anywhere; }
#announceDialog { width: min(560px, 92vw); }
#announceDialog textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--beige);
    border-radius: 10px;
    background: var(--ivory);
    font: inherit;
    resize: vertical;
}

.sidebar-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: auto;
    border-radius: 999px;
    background: var(--bright-gold);
    color: var(--white);
    font-size: .72rem;
    font-weight: 700;
}
a.avatar { color: var(--white); text-decoration: none; }

/* ---------- Login + Register ---------- */
.auth-split {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 560px);
    gap: 24px;
    align-items: start;
    width: 100%;
    justify-content: center;
}
.auth-split .auth-card { max-width: none; }
.register-card { text-align: left; }
.register-card .eyebrow { font-size: .8rem; margin-bottom: 6px; }
.register-card h1 { margin-top: 0; }
.register-form .form-row { gap: 12px; }
.register-hint { margin: -6px 0 6px; }
.register-submit { width: 100%; justify-content: center; margin-top: 16px; }
.confirm-sm { font-size: .9rem; font-weight: 600; color: var(--navy); margin-top: 12px; }
.register-dialog { width: min(640px, 94vw); }
.register-dialog .referral-title { font-size: 1.7rem; padding-right: 60px; }
.register-lead { color: var(--muted); margin: 0 0 18px; }
.register-lead a { color: var(--dark-gold); font-weight: 600; }
.confirm-sm a { color: var(--dark-gold); text-decoration: underline; }
.policy-content {
    width: min(900px, calc(100% - 40px));
    margin: 36px auto;
    padding: 32px;
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: var(--radius);
    color: var(--charcoal);
    line-height: 1.7;
}
.policy-content h1,
.policy-content h2 { color: var(--navy); }
.policy-content h1 { font-family: var(--font-display); }
.policy-content h2 { margin: 28px 0 8px; font-size: 1.15rem; }
.policy-content a:not(.btn) { color: var(--dark-gold); }
.policy-content .muted { color: var(--muted); }
.guest-policy { margin-top: 40px; margin-bottom: 40px; }

@media (max-width: 960px) {
    .auth-split { grid-template-columns: minmax(0, 560px); }
}
@media (max-width: 560px) {
    .form-row { flex-direction: column; gap: 0; }
}

/* ---------- Settings + Profile ---------- */
.form-group input:disabled { color: var(--muted); cursor: not-allowed; }
.form-group input[type="file"] { padding: 9px 12px; background: var(--white); }

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--beige);
}
.tabs a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin-bottom: -1px;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}
.tabs a:hover { color: var(--navy); }
.tabs a.active { color: var(--navy); border-bottom-color: var(--bright-gold); }
.settings-card { max-width: 820px; }
.settings-card > .muted { margin: 0 0 18px; line-height: 1.5; }
.narrow-form { max-width: 420px; }

.badge-kyc-not-submitted { background: var(--cream); color: var(--muted); }
.badge-kyc-pending { background: #F6ECD6; color: #8A5F0C; }
.badge-kyc-verified { background: #E3F1E6; color: #2D6B3A; }
.badge-kyc-rejected { background: #FBE9E7; color: #9B2C1F; }
.badge-role { background: #E1EEF5; color: #125A80; }

.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; color: var(--white); }
.profile-name { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; color: var(--navy); margin: 0 0 6px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.profile-edit { margin-left: auto; }
.profile-alert { margin: 18px 0 0; }
.profile-alert a { color: inherit; font-weight: 700; margin-left: 6px; }
.profile-section, .hris-section { margin-top: 22px; }
.empty-state-sm { padding: 30px 20px; }
.empty-state-sm .btn { margin-top: 8px; }

@media (max-width: 600px) {
    .profile-head { flex-wrap: wrap; }
    .profile-edit { margin-left: 0; }
}

/* ---------- HRIS: KYC review ---------- */
.pill-gold { background: #F6ECD6; font-size: .75rem; vertical-align: middle; }
.kyc-docs a { display: block; color: var(--navy); font-weight: 600; }
.kyc-review { display: flex; flex-direction: column; gap: 6px; min-width: 210px; }
.kyc-review input {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--beige);
    border-radius: 8px;
    background: var(--ivory);
    font-family: var(--font-body);
    font-size: .85rem;
}
.kyc-review .row-actions { justify-content: flex-start; }
#kyc .card-toolbar { flex-wrap: wrap; gap: 12px; }
.kyc-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.kyc-filters .toggle button { padding: 7px 16px; font-size: .88rem; }
.kyc-filters .search-input { height: 40px; }
#kycEmpty { margin: 14px 0 0; text-align: center; }
.kyc-preview { width: min(900px, 94vw); }
.kyc-preview .referral-title { padding-right: 60px; }
.kyc-preview-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0; }
.kyc-preview-bar .toggle { flex-wrap: wrap; }
.kyc-preview-bar .toggle button { padding: 7px 14px; font-size: .88rem; }
.kyc-preview-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    height: min(65vh, 640px);
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: 12px;
    overflow: hidden;
}
.kyc-preview-frame img { max-width: 100%; max-height: 100%; object-fit: contain; }
.kyc-preview-frame iframe { width: 100%; height: 100%; border: 0; }

/* ---------- Chat ---------- */
.chat {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100vh - 260px);
    min-height: 460px;
    padding: 0;
    overflow: hidden;
}
.chat-contacts {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--beige);
    background: var(--ivory);
}
.chat-contacts .search-input { flex: none; margin: 14px; }
.chat-filter { flex: none; display: flex; margin: -4px 14px 10px; }
.chat-filter { flex-wrap: wrap; gap: 2px; }
.chat-filter button { flex: 1 1 auto; padding: 7px 8px; font-size: .85rem; white-space: nowrap; }
.contact-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; }
.contact {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-family: var(--font-body);
    text-align: left;
    cursor: pointer;
}
.contact:hover { background: var(--cream); }
.contact.active { background: var(--white); box-shadow: 0 2px 8px rgba(12, 46, 62, .08); }
.contact .avatar { color: var(--white); }
.contact-info { flex: 1; min-width: 0; line-height: 1.3; }
.contact-info strong, .contact-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-info strong { color: var(--navy); font-size: .92rem; }
.contact-info small { color: var(--muted); font-size: .8rem; }
.contact.has-unread .contact-info small { color: var(--charcoal); font-weight: 600; }
.contact-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.contact-side time { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.chat-empty-note { padding: 0 22px; color: var(--muted); font-size: .9rem; }

.chat-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-placeholder { margin: auto; padding: 20px; text-align: center; color: var(--muted); }
.chat-placeholder svg { width: 52px; height: 52px; color: var(--gold); }
.chat-placeholder h3 { font-family: var(--font-display); color: var(--navy); font-weight: 600; margin: 10px 0 6px; }
.chat-active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--beige);
}
.chat-header .avatar { color: var(--white); }
.chat-header strong { display: block; color: var(--navy); }
.chat-header small { color: var(--muted); }
.chat-back { display: none; width: 36px; height: 36px; flex: none; }

.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    overflow-y: auto;
    background: var(--ivory);
}
.chat-day {
    align-self: center;
    margin: 10px 0 4px;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--cream);
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
}
.bubble {
    max-width: min(70%, 520px);
    padding: 9px 14px 6px;
    border-radius: 14px;
    line-height: 1.45;
}
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-sender { display: block; margin-bottom: 3px; font-size: .72rem; font-weight: 700; }
.bubble time { display: block; margin-top: 2px; font-size: .7rem; text-align: right; opacity: .7; }
.bubble-theirs {
    align-self: flex-start;
    background: var(--white);
    border: 1px solid var(--beige);
    border-bottom-left-radius: 4px;
    color: var(--charcoal);
}
.bubble-mine {
    align-self: flex-end;
    background: var(--navy);
    color: var(--white);
    border-bottom-right-radius: 4px;
}
.bubble-mine.is-read time::after { content: " \00B7  Seen"; }

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px 4px;
    border-top: 1px solid var(--beige);
}
.chat-composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    padding: 11px 14px;
    border: 1px solid var(--beige);
    border-radius: 12px;
    background: var(--ivory);
    font-family: var(--font-body);
    font-size: .95rem;
    resize: none;
}
.chat-composer textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199, 143, 34, .18); }
.chat-composer .btn:disabled { opacity: .6; cursor: wait; }
.chat-hint { padding: 0 16px 12px; margin-top: 4px; font-size: .75rem; }

@media (max-width: 760px) {
    .chat { grid-template-columns: 1fr; height: calc(100vh - 200px); }
    .chat .chat-thread { display: none; }
    .chat.thread-open .chat-contacts { display: none; }
    .chat.thread-open .chat-thread { display: flex; }
    .chat-back { display: inline-flex; }
    .bubble { max-width: 85%; }
}

/* ---------- Notes Summary ---------- */
.notes-main { max-width: 1400px; }
.notes { padding: 0; overflow: hidden; }
.notes-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--beige);
}
.notes-toolbar .toggle button { padding: 7px 14px; font-size: .88rem; }
.notes-toolbar-actions { display: flex; gap: 8px; }
.notes-body {
    display: grid;
    grid-template-columns: minmax(300px, 420px) 1fr;
    height: calc(100vh - 290px);
    min-height: 480px;
}
.notes-list-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--beige);
    background: var(--ivory);
}
.notes-list-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.notes-list-head .card-title { margin: 0; }
.notes-filters { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 12px 16px 0; }
.notes-filters .search-input { flex: 1 1 100%; height: 38px; }
.notes-check { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--navy); cursor: pointer; }
.notes-check input { accent-color: var(--dark-gold); }
.notes-read-tabs { margin: 10px 0 0; padding: 0 8px; }
.notes-read-tabs a { flex: 1; justify-content: center; padding: 10px 8px; font-size: .88rem; }

.note-list { list-style: none; margin: 0; padding: 10px; overflow-y: auto; display: grid; gap: 10px; align-content: start; flex: 1; }
.note-card {
    padding: 12px 14px;
    background: var(--white);
    border: 1px solid var(--beige);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.note-card:hover { border-color: var(--gold); }
.note-card:focus-visible { outline: 2px solid var(--gold); }
.note-card.active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199, 143, 34, .18); }
.note-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-card-head strong { color: var(--navy); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: #C0392B; vertical-align: middle; }
.note-share { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); cursor: pointer; flex: none; }
.note-share input { width: 15px; height: 15px; accent-color: var(--dark-gold); }
.note-card-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 2px; font-size: .76rem; color: var(--muted); }
.note-card-cat { font-size: .76rem; color: var(--muted); }
.note-card-body {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 8px 0 10px;
    font-size: .86rem;
    color: var(--charcoal);
    white-space: pre-line;
}
.note-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-chips { display: inline-flex; align-items: center; gap: 6px; }
.note-chip {
    padding: 3px 9px;
    border: 1px solid var(--beige);
    border-radius: 6px;
    background: var(--white);
    font-size: .74rem;
    font-weight: 600;
    color: var(--navy);
}
.note-chip-urgent { background: #FBE9E7; border-color: #E3B4AD; color: #9B2C1F; }
.note-flag {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.note-flag:hover { background: var(--cream); }
.note-flag svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.note-flag.is-flagged { color: #C0392B; }
.note-flag.is-flagged svg { fill: currentColor; }

.note-reader { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow-y: auto; }
.note-detail { padding: 26px 30px; }
.note-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.note-detail-head .referral-title { font-size: 1.6rem; }
.note-detail-body {
    margin-top: 18px;
    padding: 18px 20px;
    background: var(--ivory);
    border: 1px solid var(--beige);
    border-radius: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* New Note dialog: drafts on the left, composer on the right */
.note-dialog {
    position: relative;
    width: min(1100px, 96vw);
    height: min(720px, 92vh);
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: var(--white);
    box-shadow: 0 20px 60px rgba(8, 39, 53, .35);
}
.note-dialog::backdrop { background: rgba(8, 39, 53, .55); }
.note-dialog .dialog-close { top: 18px; right: 18px; width: 40px; height: 40px; }
.note-composer { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
.note-drafts {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--beige);
    background: var(--ivory);
}
.note-drafts-head { display: flex; align-items: center; gap: 8px; padding: 22px 16px 6px; }
.note-drafts-head .card-title { margin: 0; }
.note-drafts-head .btn { margin-left: auto; }
.draft-list { overflow-y: auto; }
.note-drafts .chat-empty-note { padding: 10px 18px; }
.note-form { display: flex; flex-direction: column; min-height: 0; padding: 24px 30px; overflow-y: auto; }
.note-form .referral-title { font-size: 1.7rem; margin-bottom: 14px; padding-right: 50px; }
.note-form .form-group { margin-bottom: 12px; }
.note-form textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--beige);
    border-radius: 10px;
    background: var(--ivory);
    font-family: var(--font-body);
    font-size: .95rem;
    resize: vertical;
}
.note-form textarea:focus,
.note-form select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.note-form .alert { margin: 12px 0 0; }
.note-form-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 16px; }
.note-form-spacer { flex: 1; }
.note-form button:disabled { opacity: .6; cursor: wait; }

@media (max-width: 860px) {
    .notes-body { grid-template-columns: 1fr; height: auto; }
    .notes-list-panel { max-height: 60vh; border-right: 0; border-bottom: 1px solid var(--beige); }
    .note-composer { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
    .note-drafts { border-right: 0; border-bottom: 1px solid var(--beige); }
    .note-dialog { height: 94vh; }
}

/* ---------- Medication Administration ---------- */
.med-main { max-width: 1400px; }
.med-toolbar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 16px; }
.med-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.med-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.med-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.med-card { display: flex; flex-direction: column; min-height: 240px; padding: 16px 18px; }
.med-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.med-card-head h2 { flex: 1; margin: 0; font-size: 1rem; font-weight: 700; color: var(--navy); }
.med-card-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--navy);
    color: var(--white);
}
.med-card-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.med-count { font-weight: 700; color: var(--navy); }
.med-link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--dark-gold);
    font: inherit;
    font-size: .86rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.med-link:hover { text-decoration: underline; }
.med-total { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--cream); color: var(--muted); font-size: .88rem; }
.med-total strong { margin-right: 6px; font-family: var(--font-display); font-size: 2rem; color: var(--navy); }
.med-clear { margin: auto; padding: 20px 0; text-align: center; color: var(--muted); font-size: .88rem; }
.med-clear svg { width: 30px; height: 30px; fill: none; stroke: var(--navy); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.med-clear p { margin: 6px 0 0; }
.med-alert-group { border-bottom: 1px solid var(--cream); }
.med-alert-group summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 2px;
    font-size: .9rem;
    cursor: pointer;
    list-style: none;
}
.med-alert-group summary::-webkit-details-marker { display: none; }
.med-alert-group summary::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform .15s;
}
.med-alert-group[open] summary::after { transform: rotate(-135deg); }
.med-alert-group ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.med-alert-group li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--ivory);
    font-size: .85rem;
}
.med-alert-group li div { display: grid; gap: 2px; min-width: 0; }
.med-alert-group li strong { color: var(--navy); }
.med-alert-group form { margin: 0; flex: none; }
.med-empty-box {
    margin: 4px 0 0;
    padding: 14px;
    border: 1px solid var(--beige);
    border-radius: 8px;
    text-align: center;
    font-size: .88rem;
    color: var(--muted);
}
.med-note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 280px; overflow-y: auto; }
.med-note-list li > a,
.med-note-list li > div {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid var(--beige);
    border-radius: 8px;
    font-size: .86rem;
    text-decoration: none;
}
.med-note-list li > a:hover { border-color: var(--gold); }
.med-note-list strong { color: var(--navy); }

@media (max-width: 1100px) {
    .med-grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Residence Tracker ---------- */
.residence-main { max-width: 1400px; }
.residence-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.residence-toolbar .search-input { margin-left: auto; height: 40px; }
.residence-table-wrap { max-height: 60vh; }
.residence-table-wrap td { vertical-align: top; }
.resident-name { display: block; color: var(--navy); }
.resident-meta { display: block; margin-top: 2px; font-size: .78rem; }
.staff-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.staff-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: #E1EEF5;
    color: #125A80;
    font-size: .82rem;
    font-weight: 600;
}
.staff-chip .warning-indicator { margin-left: 2px; }
.staff-chip form { display: inline; margin: 0; }
.staff-chip-remove {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.staff-chip-remove:hover { background: rgba(18, 90, 128, .15); }
.assign-form { display: flex; gap: 6px; }
.assign-form select {
    min-width: 0;
    max-width: 200px;
    padding: 6px 10px;
    border: 1px solid var(--beige);
    border-radius: 8px;
    background: var(--ivory);
    font: inherit;
    font-size: .85rem;
}
.view-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--beige); border-radius: 10px; background: var(--white); }
.view-switch button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 32px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.view-switch button.active { background: var(--navy); color: var(--white); }
.view-switch svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.resident-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.resident-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--beige);
    border-radius: 14px;
    background: var(--white);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(12, 46, 62, .05);
}
.resident-card.is-discharged { opacity: .8; }
.resident-card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--cream); }
.resident-card-head .avatar { color: var(--white); width: 44px; height: 44px; }
.resident-card-head > div { flex: 1; min-width: 0; }
.resident-card-head h3 { margin: 0; color: var(--navy); font-size: 1.05rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; overflow-wrap: anywhere; }
.resident-card-head small { display: block; margin-top: 2px; }
.resident-card-bed {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 18px 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #E1EEF5;
    color: #125A80;
    font-size: .88rem;
}
.resident-card-bed.is-empty { background: #F6ECD6; color: #8A5F0C; }
.resident-card-bed svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.resident-card-bed small { display: block; font-weight: 600; }
.resident-card-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; padding: 14px 18px; }
.resident-card-facts .span-2 { grid-column: 1 / -1; }
.resident-card-facts dt { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.resident-card-facts dd { margin: 2px 0 0; color: var(--charcoal); font-size: .9rem; font-weight: 500; overflow-wrap: anywhere; }
.resident-card-section { padding: 12px 18px; border-top: 1px solid var(--beige); }
.resident-card-section h4 { margin: 0 0 8px; color: var(--navy); font-size: .85rem; font-weight: 700; }
.resident-card-section p { margin: 0; font-size: .88rem; }
.service-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.service-tags span { padding: 3px 10px; border-radius: 999px; background: var(--ivory); border: 1px solid var(--beige); font-size: .8rem; color: var(--charcoal); }
.resident-referrer { display: grid; gap: 2px; }
.resident-referrer strong { color: var(--navy); }
.resident-referrer a { color: var(--navy); overflow-wrap: anywhere; }
.resident-files { display: grid; gap: 4px; margin-top: 8px; }
.resident-files a { color: var(--navy); font-size: .85rem; font-weight: 600; overflow-wrap: anywhere; }
.resident-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding: 12px 18px;
    border-top: 1px solid var(--beige);
    background: var(--ivory);
}
.resident-card-actions .assign-form select { max-width: 170px; }

/* Resident cards open the resident chart */
.resident-card { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.resident-card:hover { border-color: var(--gold); box-shadow: 0 6px 18px rgba(12, 46, 62, .1); }
.resident-card .resident-card-head h3 a, .resident-name a { color: inherit; text-decoration: none; }
.resident-card .resident-card-head h3 a:hover, .resident-name a:hover { text-decoration: underline; }
.resident-open { font-size: .78rem; font-weight: 700; color: var(--dark-gold); white-space: nowrap; }

/* ---------- Resident chart ---------- */
.chart-back { display: inline-block; margin-bottom: 12px; color: var(--muted); font-weight: 600; text-decoration: none; }
.chart-back:hover { color: var(--navy); }
.chart-head-main { display: flex; align-items: center; gap: 16px; }
.chart-head-main h2 { margin: 0; font-family: var(--font-display); color: var(--navy); font-size: 1.6rem; }
.chart-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 0; }
.badge-in { background: #E3F1E6; color: #2D6B3A; }
.badge-out { background: #E1EEF5; color: #125A80; }
.badge-late { background: #FBE9E7; color: #9B2C1F; }
.chart-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 20px; margin: 18px 0 0; }
.chart-facts .span-2 { grid-column: span 2; }
.chart-facts dt { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chart-facts dd { margin: 3px 0 0; color: var(--charcoal); font-weight: 500; }
.chart-readonly { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--cream); color: var(--muted); font-size: .88rem; }
.chart-readonly svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.mar { margin-top: 20px; border-top: 4px solid #1670A0; }
.mar-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.mar-head .card-title { margin: 0; color: #1670A0; }
.mar-head p { margin: 4px 0 0; font-size: .88rem; }
.mar-toolbar { display: flex; align-items: center; gap: 12px; margin: 16px 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--beige); }
.mar-date { display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border: 1px solid var(--beige); border-radius: 8px; background: var(--white); }
.mar-date svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; }
.mar-date input { border: 0; background: transparent; font: inherit; color: var(--charcoal); }
.mar-timebar { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.mar-scroll {
    flex: none;
    width: 30px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.mar-scroll:hover { background: var(--cream); color: var(--navy); }
.mar-slots { display: flex; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.mar-slots::-webkit-scrollbar { display: none; }
/* Time chips: navy when nothing is due, glowing when something is still to do */
.mar-slots { padding: 8px 4px; }
.mar-slots button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    height: 36px;
    padding: 0 12px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--navy);
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, .85);
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.mar-slots button:hover { transform: translateY(-1px); color: var(--white); }
.mar-slots .mar-slot-all { background: var(--white); border-color: var(--beige); color: var(--charcoal); }
.mar-slots .mar-slot.is-open,
.mar-slots .mar-slot.is-missed {
    background: linear-gradient(135deg, var(--bright-gold), var(--dark-gold));
    color: var(--white);
    animation: mar-glow 1.8s ease-in-out infinite;
}
.mar-slots .mar-slot.is-missed { background: linear-gradient(135deg, #E5533F, #B3261E); animation-name: mar-glow-missed; }
.mar-slots button.active { border-color: var(--white); box-shadow: 0 0 0 3px #1670A0; color: var(--white); }
.mar-slots .mar-slot-all.active { background: #1670A0; border-color: #1670A0; box-shadow: none; }
@keyframes mar-glow {
    0%, 100% { box-shadow: 0 0 4px 1px rgba(214, 157, 47, .45); }
    50% { box-shadow: 0 0 14px 4px rgba(214, 157, 47, .85); }
}
@keyframes mar-glow-missed {
    0%, 100% { box-shadow: 0 0 4px 1px rgba(217, 48, 37, .45); }
    50% { box-shadow: 0 0 14px 4px rgba(217, 48, 37, .85); }
}
@media (prefers-reduced-motion: reduce) {
    .mar-slots .mar-slot.is-open { animation: none; box-shadow: 0 0 10px 3px rgba(214, 157, 47, .7); }
    .mar-slots .mar-slot.is-missed { animation: none; box-shadow: 0 0 10px 3px rgba(217, 48, 37, .7); }
}
.mar-head-actions { display: flex; align-items: center; gap: 10px; }
.chart-med-link { margin-left: auto; }
.task-category { margin: 8px 0 0; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #1670A0; }
.task-card .dose-head h3 { margin-top: 2px; text-transform: none; }
.status-done .dose-badge { border-color: #2D6B3A; color: #2D6B3A; background: #E3F1E6; }
.status-done .dose-head { background: #EDF6EF; }
.status-skipped .dose-badge { border-color: #B47D12; color: #8A5F0C; background: #F6ECD6; }
.status-skipped .dose-head { background: #FBF4E6; }
.status-skipped .dose-given-time { background: #F6ECD6; color: #8A5F0C; }
.mar-dot { width: 7px; height: 7px; border-radius: 50%; background: #E0A33A; }
.mar-dot.missed { background: #D93025; }

.dose-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.dose-card { display: flex; flex-direction: column; border: 1px solid var(--beige); border-radius: 10px; background: var(--white); overflow: hidden; }
.dose-head { position: relative; padding: 14px 16px; background: #EEF2FA; }
.dose-head h3 { margin: 8px 0 0; font-size: 1.05rem; font-weight: 800; color: #111; letter-spacing: .01em; }
.dose-generic { margin: 4px 0 0; font-size: .85rem; font-weight: 700; color: #111; }
.dose-time { position: absolute; top: 14px; right: 16px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.dose-badge { display: inline-block; padding: 2px 10px; border: 1px solid; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.status-due .dose-badge { border-color: #D93025; color: #D93025; background: var(--white); }
.status-missed .dose-badge { border-color: #D93025; color: var(--white); background: #D93025; }
.status-dispensed .dose-badge { border-color: #2D6B3A; color: #2D6B3A; background: #E3F1E6; }
.status-exception .dose-badge { border-color: #B47D12; color: #8A5F0C; background: #F6ECD6; }
.status-out .dose-badge { border-color: #1670A0; color: #125A80; background: #E1EEF5; }
.status-dispensed .dose-head { background: #EDF6EF; }
.status-missed .dose-head { background: #FCEDEB; }
.dose-facts { margin: 0; padding: 12px 16px 4px; font-size: .85rem; }
.dose-facts div { display: flex; gap: 6px; padding: 1px 0; }
.dose-facts dt { color: var(--charcoal); }
.dose-facts dd { margin: 0; color: var(--charcoal); font-weight: 600; }
.dose-section { margin: 0 16px; padding: 10px 0; border-top: 1px solid var(--beige); }
.dose-section h4 { margin: 0 0 4px; font-size: .9rem; color: #111; }
.dose-section p { margin: 0; min-height: 1em; font-size: .82rem; color: var(--charcoal); }
.dose-foot { display: flex; gap: 10px; margin-top: auto; padding: 14px 16px 16px; }
.dose-foot form { flex: 1; display: flex; }
.dose-btn { flex: 1; justify-content: center; padding: 8px 12px; border: 1px solid #C7CDD3; background: var(--white); color: var(--muted); font-size: .88rem; font-weight: 600; }
.dose-btn:hover:not(:disabled) { background: var(--ivory); }
.dose-btn-primary { border-color: #1670A0; color: #1670A0; }
.dose-btn-primary:hover:not(:disabled) { background: #EEF2FA; }
.dose-btn:disabled { opacity: .5; cursor: not-allowed; }
.dose-given { display: flex; align-items: center; gap: 12px; flex: 1; font-size: .84rem; color: var(--charcoal); text-align: left; }
.status-exception .dose-head { background: #FBF4E6; }
.dose-given-time {
    flex: none;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 800;
    background: #E3F1E6;
    color: #2D6B3A;
}
.status-exception .dose-given-time { background: #F6ECD6; color: #8A5F0C; }
.dose-given small { display: block; color: var(--muted); }

/* All-residents view on Medication Administration */
.mar-all { margin-bottom: 20px; }
.mar-residents { display: flex; gap: 4px; margin: -4px 0 16px; padding-bottom: 12px; overflow-x: auto; border-bottom: 1px solid var(--beige); }
.mar-residents button {
    flex: none;
    max-width: 120px;
    padding: 8px 14px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--charcoal);
    cursor: pointer;
}
.mar-residents button:hover { color: var(--navy); }
.mar-residents button.active { border-bottom-color: #1670A0; color: #1670A0; }
.mar-resident + .mar-resident { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--beige); }
.mar-resident-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.mar-resident-head .avatar { color: var(--white); width: 36px; height: 36px; font-size: .8rem; }
.mar-resident-head a { color: var(--charcoal); font-size: 1.05rem; font-weight: 600; text-decoration: none; }
.mar-resident-head a:hover { color: var(--navy); text-decoration: underline; }
.mar-resident-head .mar-dot { background: #D93025; }
.mar-collapse { margin-left: auto; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.mar-collapse:hover { background: var(--cream); }
.mar-collapse svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .15s; }
.mar-resident.collapsed .dose-grid { display: none; }
.mar-resident.collapsed .mar-collapse svg { transform: rotate(180deg); }

.dose-record { flex: 1; margin: 0; font-size: .84rem; color: var(--charcoal); }
.dose-record small { display: block; margin-top: 2px; color: var(--muted); }
#marTable tr.status-missed td:first-child { color: #D93025; font-weight: 700; }

.log-current { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #E1EEF5; color: #125A80; font-size: .9rem; }
.med-times { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.med-time { display: inline-flex; align-items: center; gap: 2px; }
.med-time input { width: auto; padding: 8px 10px; border: 1px solid var(--beige); border-radius: 8px; background: var(--ivory); font: inherit; }
.chart-dialog { width: min(760px, 94vw); }
.chart-dialog-sm { width: min(560px, 92vw); }
.chart-dialog textarea, .chart-dialog-sm textarea,
.chart-dialog-sm select, .chart-dialog select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--beige);
    border-radius: 10px;
    background: var(--ivory);
    font: inherit;
}
.chart-dialog textarea, .chart-dialog-sm textarea { resize: vertical; }
@media (max-width: 700px) {
    .mar-toolbar { flex-direction: column; align-items: stretch; }
    .chart-facts .span-2 { grid-column: auto; }
    .dose-grid { grid-template-columns: 1fr; }
}

.caseload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.caseload-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--beige);
    border-radius: 12px;
    background: var(--ivory);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.caseload-card:hover { border-color: var(--gold); }
.caseload-head { display: flex; align-items: center; gap: 10px; }
.caseload-head .avatar { color: var(--white); width: 36px; height: 36px; font-size: .8rem; }
.caseload-head strong, .caseload-head small { display: block; }
.caseload-head strong { color: var(--navy); }
.caseload-names { font-size: .85rem; color: var(--charcoal); }
@media (max-width: 700px) {
    .residence-toolbar .search-input { margin-left: 0; }
    .assign-form { flex-direction: column; }
    .resident-cards { grid-template-columns: 1fr; }
    .resident-card-actions .assign-form { flex-direction: row; }
}
@media (max-width: 800px) {
    .med-grid-2 { grid-template-columns: 1fr; }
}

/* System Logs: honeypot security alerts */
.security-table td { vertical-align: top; }
.security-table details summary { cursor: pointer; color: var(--navy); }
.security-detail { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: .85rem; max-width: 520px; }
.security-detail dt { color: var(--muted); }
.security-detail dd { margin: 0; overflow-wrap: anywhere; white-space: normal; }

/* Category tag on Notes cards (Medication: Medical/Pharmacy, Residence: Behavior/Incident) */
.note-cat-pill { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--cream); color: var(--navy); font-size: .72rem; font-weight: 600; vertical-align: middle; }

.note-detail-tools { display: flex; align-items: center; gap: 10px; }
.note-card-delete { padding: 3px 10px; font-size: .78rem; }

/* Upload Individual Contact */
#openContactUpload { margin-left: auto; }
.contact-select-all { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
#contactUploadDialog .referral-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Resident Forms */
.doc-people { display: grid; gap: 16px; }
.doc-person { border: 1px solid var(--beige); border-radius: var(--radius); padding: 16px; background: var(--white); scroll-margin-top: 16px; }
.doc-person:target { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199, 143, 34, .18); }
.doc-person-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.doc-person-head > div { flex: 1; min-width: 0; }
.doc-person-head h3 { margin: 0; font-size: 1.02rem; color: var(--navy); }
.doc-person-head h3 a { color: inherit; }
.doc-person-head small { display: block; overflow-wrap: anywhere; }
.doc-person-head .doc-source { margin-top: 2px; }
.doc-person-head .doc-source strong { color: var(--navy); font-weight: 600; }
.doc-table td { vertical-align: middle; }
.doc-table td small { display: block; }
.doc-name { display: block; color: var(--navy); overflow-wrap: anywhere; }
.doc-category-form { margin: 0; }
.doc-category-form select,
.doc-upload select { padding: 6px 8px; border: 1px solid var(--beige); border-radius: 8px; background: var(--white); font: inherit; font-size: .85rem; }
.doc-none { margin: 0 0 8px; }
.doc-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--beige); }
.doc-upload input[type="file"] { font-size: .85rem; max-width: 100%; }
@media (max-width: 640px) {
    .doc-person-head { flex-wrap: wrap; }
    .doc-upload > * { width: 100%; }
}

/* Resident Forms filter row: one aligned row; the search fills what is left and wraps as a whole */
.doc-toolbar { align-items: center; gap: 12px 16px; }
.doc-toolbar .chart-branch-control { flex: 0 1 auto; min-width: 0; }
.doc-toolbar .chart-branch-control span { white-space: nowrap; }
.doc-toolbar .chart-branch-control select { height: 40px; width: 200px; max-width: 100%; }
.doc-toolbar .search-input { flex: 1 1 240px; min-width: 200px; margin-left: 0; height: 40px; }
.doc-table th.row-actions { display: table-cell; }
@media (max-width: 640px) {
    .doc-toolbar .chart-branch-control { flex: 1 1 100%; justify-content: space-between; }
    .doc-toolbar .chart-branch-control select { width: auto; flex: 1; }
    .doc-toolbar .search-input { flex-basis: 100%; }
}
