:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --secondary-blue: #1976D2;
    --light-accent: #64B5F6;
    --accent: #1976D2;
    --bg: #F4F8FC;
    --card-bg: #FFFFFF;
    --text: #1E293B;
    --muted: #64748B;
    --border: #E2E8F0;
    --danger: #B91C1C;
    --warning: #92400E;
    --success: #15803D;
    --radius: 8px;

    /* component-specific tokens */
    --table-header-bg: #E8F1FB;
    --input-border: #CBD5E1;
    --input-focus-ring: rgba(21, 101, 192, 0.16);
    --btn-secondary-border: #64748B;

    /* sidebar tokens */
    --sidebar-bg: #0D47A1;
    --sidebar-active-bg: #1565C0;
    --sidebar-text: #FFFFFF;
    --sidebar-active-text: #FFFFFF;
    --app-content-bg: #F4F8FC;
}

html {
    /* Slightly larger base than the browser default (16px) so every
       rem-sized element -- text, padding, buttons, inputs -- scales up
       together. This is the single highest-leverage change for making
       the system comfortable for users who aren't used to reading
       dense text on a screen, without having to touch every page. */
    font-size: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

.search-row { margin-bottom: 1.25rem; }
.search-row label {
    display: block;
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}
.search-row-inner { display: flex; gap: 0.6rem; max-width: 460px; flex-wrap: wrap; }
.search-row-inner input { flex: 1; min-width: 200px; }
.search-row-inner button { margin-top: 0; white-space: nowrap; }

.report-export-preview {
    margin-top: 1.25rem;
}

.report-export-preview iframe {
    display: block;
    width: 100%;
    min-height: 24rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.topbar {
    background: var(--primary-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    flex-wrap: wrap;
}

.brand-title { font-weight: 700; font-size: 1.2rem; margin-right: 0.5rem; }
.brand-sub { font-size: 0.85rem; opacity: 0.85; }

.mainnav a {
    color: #eafaf3;
    text-decoration: none;
    margin-left: 1.1rem;
    font-size: 0.95rem;
}
.mainnav a:hover { text-decoration: underline; color: #eafaf3; }
.mainnav a.logout { color: #ffd7d3; }

.content {
    max-width: 100% !important;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    min-height: 70vh;
}

.auth-page .content,
.auth-page .login-wrap {
    max-width: 480px !important;
    margin: 0 auto;
}

.content.dashboard-fluid {
    max-width: 100% !important;
    padding: 1.5rem 2rem;
}

.card {
    min-width: 0;
    max-width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.7rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(15, 41, 71, 0.06), 0 1px 3px rgba(15, 41, 71, 0.05);
}

h1, h2, h3 { color: var(--text); font-weight: 700; line-height: 1.3; }
h1 { font-size: 1.7rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1.02rem; font-weight: 600; }
p { color: var(--text); }

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

.stat-card { text-align: center; }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------
   Administrator dashboard: distinguishes the elevated role from
   BHW/Patient dashboards via a dark control-strip header and a
   gold accent used nowhere else in the system.
--------------------------------------------------------------- */
:root {
    --admin-accent: #C9971C;
}

.admin-strip {
    background: var(--primary-dark);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}
.admin-strip .eyebrow {
    display: inline-block;
    color: var(--admin-accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}
.admin-strip h1 { color: #fff; margin: 0; }
.admin-strip .strip-date {
    color: rgba(255,255,255,0.75);
    font-size: 0.88rem;
    text-align: right;
}

.admin-dashboard-workspace {
    padding: 1rem;
    border-radius: calc(var(--radius) + 4px);
    background: #f8f9fa;
}

.admin-activity-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.admin-metric-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    margin: 0;
    padding: 1.2rem 1.35rem;
    background: #ffffff;
}

.admin-metric-label {
    color: #526777;
    font-size: 0.85rem;
    font-weight: 600;
}

.admin-metric-value {
    color: #174a70;
    font-size: 1.9rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.admin-metric-detail {
    color: var(--muted);
    font-size: 0.78rem;
}

.admin-dashboard-primary {
    display: grid;
    gap: 1.25rem;
    min-width: 0;
}

.admin-dashboard-lower {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.medical-dashboard-container {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
    width: 100%;
    min-width: 0;
}

.analytics-split-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
}

.analytics-split-row > * {
    min-width: 0;
}

.announcement-banner-card {
    background: var(--sidebar-bg);
    color: #ffffff;
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
    width: 100%;
    box-shadow: 0 4px 12px rgba(13, 71, 161, 0.15);
}

.clinical-welcome-header {
    background: transparent;
    padding: 0.5rem 0 1.5rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    width: 100%;
}

.clinical-welcome-header h1 {
    margin: 0;
    color: var(--text);
    font-size: 1.8rem;
}

.clinical-welcome-header > span {
    display: inline-block;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.clinical-welcome-header p {
    margin: 0.4rem 0 0;
    color: var(--muted);
}

.announcement-banner-card h2 {
    color: #ffffff;
    margin-top: 0;
    font-size: 1.5rem;
}

.announcement-banner-card .announcement-banner-content {
    display: grid;
    gap: 0.75rem;
    max-width: 100%;
}

.announcement-banner-card p {
    color: #fff;
}

.announcement-banner-card .announcement-banner-date {
    margin: 0.25rem 0 0;
    color: rgba(255, 255, 255, 0.82);
}

.announcement-banner-item h2 {
    margin-top: 0;
    margin-bottom: 0.25rem;
    color: #fff;
    font-size: 1rem;
}

.announcement-banner-item p,
.announcement-banner-empty {
    margin: 0;
    overflow-wrap: anywhere;
}

.announcement-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.announcement-banner-card button,
.announcement-banner-card .btn {
    margin-top: 0;
}

.announcement-banner-actions .btn {
    background: #fff;
    color: var(--primary-dark);
    border: 1px solid #fff;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.announcement-banner-actions .btn:hover {
    background: #E8F1FB;
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transform: translateY(-1px);
}

.announcement-banner-actions .btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.admin-dashboard-secondary {
    min-width: 0;
}

.admin-dashboard-records,
.admin-dashboard-history {
    margin: 0;
}

.admin-dashboard-workflow-section {
    margin-top: 1rem;
}

.admin-dashboard-workflow-section .admin-dashboard-reference-heading {
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.admin-dashboard-workflow-section h3 {
    margin: 0;
    font-size: 0.95rem;
}

.admin-dashboard-workflow-section .admin-dashboard-reference-heading > a {
    font-size: 0.78rem;
}

.admin-dashboard-workflow-list {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.admin-dashboard-workflow-list li > a {
    display: grid;
    gap: 0.2rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.admin-dashboard-workflow-list li:last-child > a {
    border-bottom: 0;
}

.admin-dashboard-workflow-list li > a:hover strong {
    color: var(--primary-dark);
}

.admin-dashboard-workflow-list li > a > span:not(.badge) {
    color: var(--muted);
    font-size: 0.78rem;
}

.admin-dashboard-workflow-links {
    display: grid;
    gap: 0.55rem;
    margin-top: 1rem;
}

.admin-dashboard-workflow-links .action-tile {
    padding: 0.7rem 0.85rem;
}

.admin-dashboard-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-dashboard-table-wrap td {
    vertical-align: top;
}

.admin-dashboard-table-wrap td:nth-child(6) {
    min-width: 12rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

.admin-dashboard-table-wrap .actions .btn {
    margin-top: 0;
    white-space: nowrap;
}

.admin-dashboard-daily-summary {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.admin-dashboard-daily-summary h3,
.admin-dashboard-daily-summary p {
    margin: 0 0 0.45rem;
}

.admin-dashboard-daily-summary p {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.stat-card-icon {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    text-align: left;
}
.stat-card-icon .icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #E8F1FB;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-card-icon .icon-badge svg { width: 22px; height: 22px; color: var(--primary-dark); }
.stat-card-icon .stat-number { font-size: 1.6rem; }

.admin-accent-card {
    border-top: 3px solid var(--admin-accent);
}

.activity-feed-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.activity-feed-row:last-child { border-bottom: none; }
.activity-feed-time { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

.admin-dashboard-reference {
    display: grid;
    gap: 1.25rem;
}

.admin-dashboard-reference-banner {
    margin-bottom: 0;
}

.admin-dashboard-reference-chart {
    min-width: 0;
    margin: 0;
    padding: 0.5rem;
}

.admin-dashboard-reference-chart .dashboard-chart-card {
    margin: 0;
    border: 0;
    box-shadow: none;
}

.admin-dashboard-reference-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    gap: 1.25rem;
    align-items: stretch;
}

.admin-dashboard-history,
.admin-dashboard-support {
    min-width: 0;
    margin: 0;
}

.admin-dashboard-reference-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.admin-dashboard-reference-heading h2 {
    margin: 0.15rem 0 0;
}

.admin-dashboard-reference-heading > a {
    flex-shrink: 0;
    font-size: 0.84rem;
    font-weight: 600;
}

.admin-dashboard-reference-eyebrow {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.admin-dashboard-history-list {
    display: grid;
}

.admin-dashboard-history-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
}

.admin-dashboard-history-row:last-child {
    border-bottom: 0;
}

.admin-dashboard-history-main {
    display: flex;
    min-width: 0;
    gap: 0.75rem;
}

.admin-dashboard-history-marker {
    width: 0.65rem;
    height: 0.65rem;
    flex: 0 0 0.65rem;
    margin-top: 0.38rem;
    border-radius: 50%;
    background: var(--secondary-blue);
    box-shadow: 0 0 0 4px #e8f1fb;
}

.admin-dashboard-history-copy {
    min-width: 0;
}

.admin-dashboard-history-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.88rem;
}

.admin-dashboard-history-copy p {
    margin: 0.3rem 0 0;
    color: #475569;
    font-size: 0.88rem;
    overflow-wrap: anywhere;
}

.admin-dashboard-history-time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.admin-dashboard-reference-empty {
    margin: 0;
    color: var(--muted);
}

.admin-dashboard-chat {
    display: flex;
    flex-direction: column;
}

.admin-dashboard-chat-preview {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: #eff6ff;
    color: var(--primary-dark);
    font-size: 0.72rem;
    font-weight: 700;
}

.admin-dashboard-clinician {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.admin-dashboard-clinician img {
    display: block;
    flex: 0 0 48px;
    border-radius: 50%;
    object-fit: cover;
}

.admin-dashboard-clinician-details {
    display: grid;
    min-width: 0;
    gap: 0.15rem;
}

.admin-dashboard-clinician-details strong {
    color: var(--text);
    font-size: 0.9rem;
}

.admin-dashboard-clinician-details span {
    color: var(--muted);
    font-size: 0.78rem;
}

.admin-dashboard-support-badge {
    margin-left: auto;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: #e8f7ef;
    color: #166534;
    font-size: 0.7rem;
    font-weight: 700;
}

.admin-dashboard-chat-preview-thread {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.admin-dashboard-chat-caption {
    margin: 0;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

.admin-dashboard-chat-bubble {
    max-width: 92%;
    padding: 0.7rem 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px 12px 12px 4px;
    background: #f8fafc;
}

.admin-dashboard-chat-bubble > span {
    color: var(--primary-dark);
    font-size: 0.72rem;
    font-weight: 700;
}

.admin-dashboard-chat-bubble p {
    margin: 0.2rem 0 0;
    color: #334155;
    font-size: 0.82rem;
    line-height: 1.45;
}

.admin-dashboard-chat-bubble-outgoing {
    justify-self: end;
    border-color: #cbdcf0;
    border-radius: 12px 12px 4px 12px;
    background: #edf5fd;
}

.admin-dashboard-chat-disclaimer {
    margin: auto 0 0;
    padding-top: 1rem;
    color: var(--muted);
    font-size: 0.72rem;
}

/* ---------------------------------------------------------------
   Quick Actions / Quick Links tiles. Uses auto-fit (not auto-fill)
   so a row of 2 items stretches to fill the same width as a row of
   4 -- prevents the "buttons stranded in a mostly-empty card" look.
--------------------------------------------------------------- */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-top: 0.9rem;
}
.action-tile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.action-tile:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(13, 71, 161, 0.1);
    transform: translateY(-1px);
    color: var(--text);
}
.action-tile .tile-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #E8F1FB;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.action-tile .tile-icon svg { width: 18px; height: 18px; color: var(--primary-dark); }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}
th, td {
    text-align: left;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}
th { background: var(--table-header-bg); color: var(--primary-dark); font-weight: 700; }
tr:hover td { background: #F7FAFD; }

.user-actions-dropdown {
    position: relative;
    display: inline-block;
}

.user-actions-dropdown > summary {
    cursor: pointer;
    color: var(--primary-dark);
    font-weight: 600;
}

.user-actions-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 14rem;
    max-height: 70vh;
    overflow-y: auto;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
}

.user-actions-menu > form { margin: 0; }
.user-actions-menu > form > button { width: 100%; }
.user-actions-menu details > summary {
    cursor: pointer;
    font-weight: 600;
}

.user-actions-menu details > summary.user-edit-toggle {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--btn-secondary-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--btn-secondary-border);
}

.user-actions-menu details > summary.user-edit-toggle:hover {
    background: #F1F5F9;
}

form.stacked label {
    display: block;
    margin: 0.9rem 0 0.35rem;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
}
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=tel], input[type=number], select, textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--input-focus-ring);
}
textarea { resize: vertical; min-height: 90px; }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0 1rem;
    border-radius: var(--radius);
    font-size: 0.98rem;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    margin-top: 1rem;
    height: 44px;
    min-height: 44px;
    white-space: nowrap;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button:focus-visible, .btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--input-focus-ring);
}
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #991616; }
.btn-secondary {
    background: #fff;
    color: var(--btn-secondary-border);
    border: 1px solid var(--btn-secondary-border);
}
.btn-secondary:hover { background: #F1F5F9; }

.badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}
.badge-pending { background: #FEF3C7; color: var(--warning); }
.badge-approved, .badge-active, .badge-ready, .badge-released { background: #DCFCE7; color: var(--success); }
.badge-rejected, .badge-denied, .badge-inactive, .badge-deleted { background: #FEE2E2; color: var(--danger); }
.badge-reviewed, .badge-processing { background: #DBEAFE; color: var(--primary-dark); }

.confirm-dialog {
    width: min(100% - 2rem, 440px);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 18px;
    padding: 2rem;
    color: var(--text);
    background: var(--card-bg);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}
.confirm-dialog::backdrop {
    background: rgba(15, 23, 42, 0.58);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.confirm-dialog-icon {
    display: grid;
    place-items: center;
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: 1rem;
    border-radius: 50%;
    color: var(--warning);
    background: #FEF3C7;
}
.confirm-dialog-icon svg { width: 1.7rem; height: 1.7rem; }
.confirm-dialog h2 { margin: 0 0 0.55rem; font-size: 1.3rem; }
.confirm-dialog p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 1.6rem;
}
.confirm-dialog-actions button { margin-top: 0; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
@media (max-width: 480px) {
    .confirm-dialog { padding: 1.4rem; }
    .confirm-dialog-actions { flex-direction: column-reverse; }
    .confirm-dialog-actions button { width: 100%; }
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.alert-success { background: #DCFCE7; color: var(--success); border: 1px solid #BBF0CE; }
.alert-error   { background: #FEE2E2; color: var(--danger); border: 1px solid #FBC9C9; }
.alert-warning { background: #FEF3C7; color: var(--warning); border: 1px solid #FDE59A; }

.login-wrap {
    max-width: 380px;
    margin: 6vh auto;
}
.login-wrap .card { box-shadow: 0 4px 18px rgba(13, 71, 161, 0.10); }

/* ---------------------------------------------------------------
   Auth pages (login / register / forgot password)
--------------------------------------------------------------- */
body.auth-page {
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--secondary-blue) 100%) !important;
    min-height: 100vh;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    box-sizing: border-box;
}

body.auth-page .app-shell {
    width: 100%;
    min-height: 0;
}

body.auth-page .app-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    max-width: none;
    padding: 0;
}

div.auth-page {
    position: fixed;
    inset: 0 auto auto 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: safe center;
    justify-content: center;
    padding: 2rem 1rem;
    box-sizing: border-box;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--secondary-blue) 100%) !important;
}

body.auth-logo-background div.auth-page {
    background: transparent !important;
}

body.auth-logo-background div.auth-page::before {
    content: "";
    position: fixed;
    inset: -6px;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(13, 49, 76, 0.4), rgba(24, 99, 131, 0.4)),
        url("/assets/img/logo.png") center / cover no-repeat;
    filter: blur(3px);
}

body.auth-page .login-wrap {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

body.auth-page .card {
    background: rgba(255, 255, 255, 0.78) !important;
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--radius);
    padding: 2.2rem 2.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.55);
    width: 100%;
    box-sizing: border-box;
}

body.auth-page form.stacked label {
    margin-top: 0.75rem;
    margin-bottom: 0.3rem;
}

body.auth-page button[type="submit"] {
    margin-top: 1.5rem;
    width: 100%;
    padding: 0.75rem;
    font-weight: 600;
}

@media (max-width: 480px) {
    body.auth-page .card {
        padding: 1.5rem 1.25rem;
    }
}

@media (max-height: 720px) {
    div.auth-page {
        align-items: flex-start;
    }
}

/* ---------------------------------------------------------------
   App shell: left sidebar navigation + top bar
--------------------------------------------------------------- */
html, body.app-body { height: 100%; margin: 0; background: var(--app-content-bg); }

body.app-body.auth-page {
    height: auto;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    overflow-y: auto;
    width: 220px;
    flex-shrink: 0;
    z-index: 20;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem 0;
    box-sizing: border-box;
}

.app-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.app-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.4rem;
    border-radius: 0;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background-color 0.15s ease;
}
.app-sidebar nav a svg { width: 19px; height: 19px; flex-shrink: 0; color: var(--sidebar-text); }
.app-sidebar nav a:hover { background: rgba(255,255,255,0.14); }
.app-sidebar nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}
.app-sidebar nav a.active svg { color: var(--sidebar-active-text); }

.app-sidebar .sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 1.1rem;
}
.app-sidebar .sidebar-bottom a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: #fff;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 999px;
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-decoration: none;
    transition: background-color 0.15s ease;
}
.app-sidebar .sidebar-bottom a:hover { background: #EAF2FE; }
.app-sidebar .sidebar-bottom a svg { width: 17px; height: 17px; color: var(--primary-dark); }

.app-main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: 220px;
}

.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.75rem;
    gap: 0.75rem;
}
.app-topbar .brand-block {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0; /* required for text-overflow ellipsis to work inside a flex item */
}
.app-topbar .brand-block .brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-topbar .user-block {
    min-width: 0;
    flex-shrink: 0;
}
.app-topbar .user-block span:not(.user-avatar) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 32vw;
}
.app-topbar .brand-block .logo-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #E8F1FB;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.app-topbar .brand-block .logo-badge img { width: 100%; height: 100%; object-fit: contain; }
.app-topbar .brand-block .brand-text { font-weight: 700; font-size: 0.95rem; color: var(--text); line-height: 1.2; }
.app-topbar .user-block {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.88rem;
    color: var(--text);
}
.app-topbar .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #E8F1FB;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    line-height: 0;
}
.app-topbar .user-avatar svg {
    display: block;
}

.app-content {
    flex: 1;
    padding: 1.85rem;
    max-width: 1100px;
    width: 100%;
}

.app-content.dashboard-fluid {
    max-width: none;
}

.dashboard-fluid-page .app-content {
    max-width: none;
    padding: 0;
}

@media (max-width: 820px) {
    .app-shell { flex-direction: column; }
    .app-sidebar {
        position: static;
        align-self: auto;
        height: auto;
        overflow-y: visible;
        width: 100%;
        flex-direction: column;
        padding: 0.6rem 0;
        gap: 0;
    }
    .app-main-wrap { margin-left: 0; }
    /* Plain vertical list, same as desktop -- just full width instead
       of a fixed side column. One item per line, nothing to swipe or
       discover, same familiar icon + label rows the user already
       knows from the desktop version. */
    .app-sidebar nav {
        flex-direction: column;
        gap: 0.1rem;
    }
    .app-sidebar nav a {
        padding: 0.7rem 1.1rem;
    }
    .app-sidebar .sidebar-bottom {
        flex-direction: column;
        padding: 0.75rem 1.1rem 0;
        margin-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.15);
        gap: 0.5rem;
    }
    .app-content { padding: 1.1rem; }
    .card { padding: 1.15rem 1.25rem; }
}

/* ---------------------------------------------------------------
   Patient bottom tab bar. Patients get a small, flat set of
   destinations (Home, Records, Documents, News, Log out), which
   fits naturally as a fixed bottom bar -- a pattern most people
   already know from banking/shopping apps. Desktop is untouched;
   this only replaces the sidebar for patients on narrow screens,
   never shows alongside it.
--------------------------------------------------------------- */
.mobile-tab-bar { display: none; }

@media (max-width: 820px) {
    /* Hide the regular stacked nav for patients on mobile -- the
       bottom tab bar replaces it entirely rather than duplicating
       navigation in two places on the same screen. */
    body.role-patient .app-sidebar { display: none; }

    body.role-patient .mobile-tab-bar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 50;
        background: var(--sidebar-bg);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
    }
    .mobile-tab-bar a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        padding: 0.5rem 0.2rem 0.65rem;
        color: var(--sidebar-text);
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 700;
    }
    .mobile-tab-bar a svg { width: 20px; height: 20px; }
    .mobile-tab-bar a.active {
        background: var(--sidebar-active-bg);
        color: var(--sidebar-active-text);
    }

    /* Room at the bottom of the page so the fixed bar never covers
       the last bit of content. */
    body.role-patient .app-content { padding-bottom: 5.5rem; }
}

@media (max-width: 480px) {
    .app-topbar { padding: 0.65rem 1rem; }
    .app-topbar .brand-block .brand-text { max-width: 38vw; font-size: 0.85rem; }
    .app-topbar .user-block span:not(.user-avatar) { max-width: 24vw; font-size: 0.85rem; }
    .app-content { padding: 0.85rem; }
    .card { padding: 1rem; }
    .grid-3 { grid-template-columns: 1fr; }
}

/* Wide data tables become horizontally scrollable within their own
   box on tablets/phones, rather than breaking the whole page layout
   or squeezing every column unreadably. Applies everywhere with no
   markup changes needed. */
@media (max-width: 820px) {
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    th, td { white-space: nowrap; }
    .user-actions-menu { position: static; }
}

.sitefooter {
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
    padding: 1.25rem;
}

.actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.actions a,
.actions button {
    margin: 0;
}
.actions > a.btn,
.actions > form {
    flex: 1 1 7.5rem;
}
.actions > form button {
    width: 100%;
}
.actions.portal-account-form-actions > button,
.actions.portal-account-form-actions > a.btn {
    flex: 0 0 14rem;
    width: 14rem;
    max-width: 100%;
}
.actions form {
    display: inline-flex;
    margin: 0;
}

/* Patient dashboard */
body.patient-dashboard {
    background: #f8f9fa;
    color: #263238;
}

.patient-dashboard .patient-dashboard-content {
    max-width: 900px;
    margin: 0 auto;
}

.patient-dashboard .dashboard-heading {
    margin: 0 0 1.5rem;
}

.patient-dashboard .dashboard-eyebrow {
    margin: 0 0 0.35rem;
    color: #526777;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.patient-dashboard .dashboard-heading h1 {
    margin: 0;
    color: #263238;
}

.patient-dashboard .dashboard-intro {
    max-width: 42rem;
    margin: 0.55rem 0 0;
    color: #526777;
}

.patient-dashboard .dashboard-overview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.patient-dashboard .dashboard-overview-single {
    grid-template-columns: 1fr;
}

.patient-dashboard .dashboard-card {
    margin-bottom: 1rem;
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(38, 50, 56, 0.05);
}

.patient-dashboard .dashboard-card h2 {
    margin: 0 0 1rem;
    color: #263238;
}

.patient-dashboard .followup-list {
    display: grid;
    gap: 0.65rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.patient-dashboard .followup-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid #e8edf2;
}

.patient-dashboard .followup-list li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.patient-dashboard .followup-label {
    color: #526777;
    font-size: 0.92rem;
}

.patient-dashboard .followup-date {
    color: #263238;
    font-weight: 700;
}

.patient-dashboard .quick-links-card {
    display: flex;
    flex-direction: column;
}

.patient-dashboard .quick-links {
    display: grid;
    gap: 0.75rem;
}

.patient-dashboard .quick-link {
    display: flex;
    min-height: 48px;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd9e6;
    border-radius: var(--radius);
    background: #ffffff;
    color: #2b6cb0;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.patient-dashboard .quick-link:hover {
    border-color: #2b6cb0;
    background: #f2f7fc;
    color: #1e4e80;
}

.patient-dashboard .quick-link:focus-visible {
    outline: 3px solid rgba(43, 108, 176, 0.35);
    outline-offset: 2px;
}

.patient-dashboard .announcements-card {
    margin-top: 0.25rem;
}

.patient-dashboard .announcements-heading {
    margin-bottom: 0.35rem;
}

.patient-dashboard .announcements-heading h2 {
    margin-bottom: 0.5rem;
}

.patient-dashboard .announcement-item {
    padding: 1rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.patient-dashboard .announcement-item:last-of-type {
    border-bottom: 0;
}

.patient-dashboard .announcement-item h3 {
    margin: 0;
    color: #263238;
}

.patient-dashboard .announcement-item p {
    margin: 0.45rem 0;
    color: #34434c;
    overflow-wrap: anywhere;
}

.patient-dashboard .announcement-date {
    color: #64748b;
    font-size: 0.85rem;
}

.patient-dashboard .announcements-empty {
    margin: 0;
    color: #526777;
}

.patient-dashboard .dashboard-notice {
    padding: 1rem 1.15rem;
    border: 1px solid #c8dced;
    border-left: 4px solid #2b6cb0;
    border-radius: var(--radius);
    background: #f1f7fc;
    color: #263238;
}

.patient-dashboard .dashboard-notice p {
    margin: 0;
}

@media (max-width: 640px) {
    .patient-dashboard .dashboard-overview {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .patient-dashboard .dashboard-card {
        padding: 1.15rem;
    }
}

@media (max-width: 640px) {
    .admin-dashboard-reference-columns { grid-template-columns: 1fr; }
    .admin-dashboard-history-row { flex-direction: column; gap: 0.35rem; }
    .admin-dashboard-history-time { padding-left: 1.4rem; }
    .admin-dashboard-reference-chart { padding: 0.25rem; }
    .admin-dashboard-workspace { padding: 0.65rem; }
    .admin-activity-metrics { gap: 0.7rem; }
    .admin-metric-card { padding: 1rem 1.1rem; }
    .admin-dashboard-lower { grid-template-columns: 1fr; gap: 0; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .mainnav { margin-top: 0.5rem; }
    .mainnav a { margin-left: 0; margin-right: 0.9rem; }
}

@media (max-width: 1024px) {
    .medical-dashboard-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 399px) {
    .analytics-split-row {
        grid-template-columns: minmax(0, 1fr);
    }
}
