:root {
    /* Color Palette - Refined HSL Colors */
    --primary-h: 172;
    --primary-s: 66%;
    --primary-l: 35%;
    
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-light: hsl(var(--primary-h), var(--primary-s), 95%);
    --primary-dark: hsl(var(--primary-h), var(--primary-s), 25%);
    --primary-soft: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.1);
    
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #0f172a;
    --text-light: #64748b;
    --muted: #94a3b8;
    --line: #e2e8f0;
    --accent: #6366f1; /* Indigo accent */
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text);
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 0.5em;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #eef7f5;
}

.login-card {
    width: min(460px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    margin: 16px 0 8px;
    font-size: 30px;
}

.login-card p {
    color: var(--muted);
    line-height: 1.55;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px 1fr;
}

.sidebar-backdrop {
    display: none;
}

.sidebar {
    background: #ffffff;
    border-right: 1px solid var(--line);
    padding: 12px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.mobile-bar {
    display: none;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--deep);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
}

.mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 900;
}

.desktop-sidebar-toggle {
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 16px;
    padding: 0 4px;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-top: 2px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 4px 12px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.3);
}

.nav {
    display: grid;
    gap: 4px;
}

.nav a,
.logout {
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--text-light);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    transition: all 0.2s ease;
}

.nav a:hover,
.logout:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.nav a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.25);
}

.logout {
    margin-top: auto;
    color: var(--danger);
}

.main {
    padding: 12px;
    min-width: 0;
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: 74px 1fr;
}

body.sidebar-collapsed .sidebar {
    padding-left: 10px;
    padding-right: 10px;
}

body.sidebar-collapsed .brand span:last-child,
body.sidebar-collapsed .nav span,
body.sidebar-collapsed .logout span {
    display: none;
}

body.sidebar-collapsed .brand {
    justify-content: center;
}

body.sidebar-collapsed .nav a,
body.sidebar-collapsed .logout {
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.topbar h1 {
    margin: 0 0 2px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-light);
    font-size: 15px;
    margin: 0;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
}

.top-actions,
.actions,
.quick-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.actions input,
.actions select {
    width: auto;
}

.actions input[name="q"] {
    min-width: 280px;
    flex: 1 1 320px;
}

.actions select[name="limit"] {
    min-width: 118px;
    flex: 0 0 auto;
}

.quick-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 5px solid var(--primary);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.quick-panel h2 {
    margin: 4px 0 6px;
    font-size: 19px;
}

.grid {
    display: grid;
    gap: 10px;
}

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

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

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

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.metric {
    display: grid;
    gap: 4px;
    min-height: auto;
}

.metric span {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric strong {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
}

.metric-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--primary-soft);
    width: 32px;
    height: 32px;
    opacity: 0.5;
}

.card.metric {
    position: relative;
    overflow: hidden;
}

.toolbar {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.toolbar h2 {
    margin-bottom: 0;
}

/* Colorful Metric Cards */
.card-sky { background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%); color: #fff; border: none; }
.card-emerald { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); color: #fff; border: none; }
.card-amber { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); color: #fff; border: none; }
.card-violet { background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%); color: #fff; border: none; }

.metric-white span { color: rgba(255,255,255,0.8); }
.metric-white strong { color: #fff; }
.metric-white .icon-box {
    background: rgba(255,255,255,0.2);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    position: absolute;
    top: 16px;
    right: 16px;
}

.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-body);
}

.btn:hover {
    border-color: var(--primary);
    background: #fafafa;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

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

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

.btn-soft {
    background: var(--soft);
    color: var(--primary-dark);
    border-color: var(--soft);
}

.btn-icon {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px;
}

.btn-icon .icon {
    margin-right: 0;
}

.btn-edit {
    background: #e0f2fe;
    border-color: #bae6fd;
    color: #0369a1;
}

.btn-delete {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.btn-call {
    background: #ecfdf5;
    border-color: #d1fae5;
    color: #059669;
}

.btn-whatsapp {
    background: #f0fdf4;
    border-color: #dcfce7;
    color: #15803d;
}

form {
    margin: 0;
}

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

.field {
    display: grid;
    gap: 5px;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font: inherit;
    font-size: 14.5px;
    background: #fff;
    color: var(--text);
    min-height: 40px;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

input:disabled {
    background: #f6faf9;
    color: var(--muted);
}

textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.5;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    min-width: 760px;
}

th,
td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    line-height: 1.4;
}

th {
    background: #f8fafc;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.05em;
}

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

tbody tr:hover td {
    background: #fbfefd;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-old {
    background: var(--soft-blue);
    color: #175cd3;
}

.muted {
    color: var(--muted);
    line-height: 1.5;
}

.empty-cell {
    text-align: center;
    color: var(--muted);
    padding: 28px 14px;
    background: #fbfefd;
}

.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 600;
    font-size: 14.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    border-color: #6ee7b7;
    color: #065f46;
    background: #ecfdf5;
}

.alert-error {
    border-color: #fca5a5;
    color: #991b1b;
    background: #fef2f2;
}

.alert-info {
    border-color: #b9e6fe;
    color: #026aa2;
    background: #f0f9ff;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(140px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.day {
    min-height: 120px;
    background: #fff;
    padding: 10px;
    transition: background 0.2s ease;
}

.day:hover {
    background: #fdfdfd;
}

.day strong {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 700;
}

.day-muted {
    background: #f8fafc;
}

.day-today {
    background: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.03);
}

.day-today strong {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-full);
}

.weekday {
    background: #f1f5f9;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    padding: 12px 4px;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--line);
}

.event {
    display: block;
    padding: 4px 8px;
    margin-top: 4px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid var(--primary);
}

.event .badge {
    padding: 1px 4px;
    font-size: 9px;
    margin-left: 4px;
    background: rgba(255, 255, 255, 0.5);
}

.icon {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.nav .icon,
.logout .icon {
    width: 18px;
    height: 18px;
}

.btn .icon {
    margin-right: 6px;
}

.filter-stack {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1 1 auto;
    width: auto;
}

.range-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.range-bar a,
.pagination a,
.pagination span {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--deep);
}

.compact-range {
    flex-wrap: nowrap;
    gap: 6px;
}

.compact-range input[type="date"] {
    width: 145px;
    min-width: 145px;
}

.compact-range .btn {
    min-width: auto;
}

.range-bar a.active,
.pagination a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pagination {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 12px;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    font-weight: 700;
}

.sort-link .icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 20;
}

.modal:target,
.modal.is-open {
    display: flex;
}

.modal-card {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 16px;
    box-shadow: 0 20px 50px rgba(17, 24, 39, .20);
}

.profile-photo-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfc;
}

.doctor-photo {
    width: 88px;
    height: 88px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--deep);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 24px;
    flex: 0 0 auto;
}

.doctor-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.calendar-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.calendar-title {
    display: grid;
    justify-items: center;
    gap: 6px;
}

.calendar-title strong {
    font-size: 20px;
}

.table-toolbar {
    padding: 10px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--line);
}

.patient-hero {
    background: #fff;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.patient-main {
    display: flex;
    gap: 14px;
    align-items: center;
    min-width: 0;
}

.patient-avatar {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 28px;
    font-weight: 900;
    flex: 0 0 auto;
}

.patient-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.patient-title-row h2 {
    margin: 0;
    font-size: 24px;
}

.patient-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.patient-meta span {
    background: var(--soft-blue);
    color: var(--deep);
    border: 1px solid #c8e6f7;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 13px;
    font-weight: 600;
}

.patient-address {
    margin: 0;
}

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

.patient-stats {
    margin-bottom: 12px;
}

.patient-stats .metric strong {
    font-size: 20px;
}

.patient-history-card {
    padding: 0;
    overflow: hidden;
}

.history-head {
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
}

.history-head h2 {
    margin: 3px 0 0;
}

.history-filter {
    justify-content: flex-end;
    flex: 1 1 520px;
}

.docs-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.docs-toc {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 6px;
}

.docs-toc a {
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 600;
}

.docs-toc a:hover {
    background: var(--soft-blue);
    color: var(--deep);
}

.docs-content {
    display: grid;
    gap: 14px;
}

.docs-section {
    scroll-margin-top: 20px;
}

.docs-section p code,
.docs-section .muted {
    line-height: 1.6;
}

.code-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;
    background: #0f172a;
}

.code-head {
    background: #f8fbfc;
    color: var(--deep);
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.copy-btn {
    min-height: 32px;
    padding: 6px 10px;
}

.code-card pre {
    margin: 0;
    padding: 13px;
    overflow-x: auto;
}

.code-card code {
    color: #e5edf5;
    /* font-family: Consolas, Monaco, monospace; */
    font-size: 13px;
    line-height: 1.55;
    white-space: pre;
}

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

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

    body.sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    .mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 25;
        background: rgba(255, 255, 255, 0.85);
        border-bottom: 1px solid var(--line);
        padding: 14px 18px;
        margin: -18px -18px 20px;
        backdrop-filter: blur(12px);
    }

    .hide-on-mobile {
        display: none;
    }

    .desktop-sidebar-toggle {
        display: none;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(82vw, 300px);
        height: 100vh;
        border-right: 1px solid var(--line);
        border-bottom: 0;
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: 18px 0 45px rgba(17, 24, 39, .20);
        overflow-y: auto;
    }

    body.sidebar-collapsed .brand span:last-child,
    body.sidebar-collapsed .nav span,
    body.sidebar-collapsed .logout span {
        display: inline;
    }

    body.sidebar-collapsed .brand {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .nav a,
    body.sidebar-collapsed .logout {
        justify-content: flex-start;
        padding: 10px 11px;
    }

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

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(17, 24, 39, .42);
        z-index: 29;
    }

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

    .logout {
        margin-top: 14px;
    }

    .grid-2,
    .grid-3,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .quick-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .top-actions,
    .quick-actions {
        width: 100%;
    }

    .patient-hero,
    .history-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .patient-actions,
    .history-filter {
        width: 100%;
        justify-content: flex-start;
    }

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

    .docs-toc {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .main {
        padding: 14px;
    }

    .sidebar {
        padding: 16px;
    }

    .login-card {
        padding: 22px;
    }

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

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

    .btn,
    .top-actions a,
    .quick-actions a,
    .actions .btn {
        width: 100%;
    }

    .actions {
        width: 100%;
    }

    .actions input,
    .actions select {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
    }

    .topbar h1 {
        font-size: 24px;
    }

.progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.progress {
    flex: 1;
    height: 6px;
    background: var(--line);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
}

.progress-val {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    min-width: 30px;
    text-align: right;
}

.report-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

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

    .mobile-bar {
        margin: -14px -14px 12px;
    }

    .topbar {
        gap: 10px;
        margin-bottom: 12px;
    }

    .page-subtitle {
        font-size: 14px;
    }

    .card {
        padding: 12px;
    }

    .metric {
        min-height: auto;
    }

    .filter-stack,
    .compact-range,
    .range-bar,
    .calendar-toolbar {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .range-bar a {
        text-align: center;
    }

    .compact-range input[type="date"] {
        width: 100%;
        min-width: 0;
    }

    .profile-photo-panel,
    .patient-main {
        align-items: flex-start;
        flex-direction: column;
    }

    .patient-avatar {
        width: 58px;
        height: 58px;
        font-size: 23px;
    }

    .patient-title-row h2 {
        font-size: 21px;
    }

    .table-wrap {
        border: 0;
        overflow: visible;
    }

    table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
        background: transparent;
    }

    thead {
        display: none;
    }

    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    tbody tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: 0 6px 18px rgba(17, 24, 39, .05);
        overflow: hidden;
    }

    td {
        border-bottom: 1px solid var(--line);
        padding: 9px 10px;
        display: flex;
        justify-content: space-between;
        gap: 14px;
        text-align: right;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 900;
        text-transform: uppercase;
        font-size: 11px;
        text-align: left;
        max-width: 45%;
    }

    td.empty-cell {
        display: block;
        text-align: center;
    }

    td.empty-cell::before {
        content: "";
    }

    .docs-toc {
        grid-template-columns: 1fr;
    }

    .code-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .copy-btn {
        width: 100%;
    }
}