:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #eef4fb;
    --text: #1b2430;
    --muted: #607085;
    --primary: #1769aa;
    --primary-dark: #0e4d7d;
    --success: #1c7c54;
    --error: #b42318;
    --border: #dbe4ee;
    --shadow: 0 12px 35px rgba(20, 42, 69, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #eef3f8 0%, var(--bg) 100%);
    color: var(--text);
}

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

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand a {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.nav {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e4eef8;
    color: var(--primary-dark);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.panel,
.card,
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 24px;
}

.card,
.auth-card {
    padding: 22px;
}

.auth-card {
    width: min(440px, 100%);
    margin: 72px auto;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.hero h1,
.panel h1,
.card h2,
.auth-card h1 {
    margin-top: 0;
}

.hero p,
.panel-header p,
.hint,
.empty,
small {
    color: var(--muted);
}

.hero-subtitle,
.field-help {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stats-tight {
    margin-top: 18px;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 2rem;
}

.panel-header,
.actions,
.timeline-item header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.grid-two {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 20px;
    margin-top: 18px;
}

.patients-layout {
    display: grid;
    gap: 20px;
    margin-top: 18px;
}

.patients-layout > .card:first-child {
    border-top: 4px solid #1769aa;
}

.patients-layout > .card:first-child .form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.patients-layout > .card:first-child .form input[type="hidden"],
.patients-layout > .card:first-child .form button,
.patients-layout > .card:first-child .form a {
    grid-column: 1 / -1;
}

.patients-layout > .card:first-child h2 {
    margin-bottom: 18px;
}

.users-layout {
    display: grid;
    gap: 20px;
    margin-top: 18px;
}

.users-panel {
    padding: 0;
    overflow: hidden;
}

.users-page-heading {
    padding: 28px 30px;
    background: linear-gradient(120deg, #0e4d7d 0%, #1769aa 68%, #2a9d8f 100%);
    color: #fff;
}

.users-page-heading h1 {
    margin: 4px 0 5px;
    color: #fff;
    font-size: clamp(1.55rem, 3vw, 2.05rem);
}

.users-page-heading p,
.users-page-heading .eyebrow {
    color: rgba(255, 255, 255, 0.78);
}

.users-page-heading .btn-secondary {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.users-layout > .card {
    margin: 0 30px;
}

.user-section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.user-section-heading h2 {
    margin: 0 0 3px;
    font-size: 1.2rem;
}

.user-section-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.user-section-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 11px;
    background: #e7f3fb;
    color: var(--primary);
    font-size: 1.35rem;
    font-weight: 800;
}

.user-mode-badge,
.user-count-badge {
    margin-left: auto;
    padding: 7px 11px;
    border-radius: 999px;
    background: #edf5fc;
    color: var(--primary-dark);
    font-size: 0.74rem;
    font-weight: 800;
    white-space: nowrap;
}

.user-count-badge {
    background: #e6f6f2;
    color: #17695f;
}

.user-form-card {
    border-top: 4px solid #1769aa;
}

.user-form-card .form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.user-form-card .form > input[type="hidden"],
.user-form-card .form > button,
.user-form-card .form > a,
.user-form-card .form > .role-guide {
    grid-column: 1 / -1;
}

.user-form-card #doctor-specialty-fields {
    display: grid;
    gap: 10px;
    align-content: start;
    padding: 14px;
    border: 1px solid #d6e4eb;
    border-radius: 12px;
    background: #f5fafc;
}

.user-form-card #doctor-specialty-fields[hidden] {
    display: none;
}

.user-form-card .role-guide {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 4px;
}

.user-list-card {
    border-top: 4px solid #2a9d8f;
    margin-bottom: 30px !important;
}

.user-list-card table tbody tr:hover {
    background: #f5fafc;
}

.user-list-heading {
    margin-bottom: 14px;
}

.appointments-layout {
    display: grid;
    gap: 20px;
    margin-top: 18px;
}

.appointments-layout > .card:first-child {
    border-top: 4px solid #2a9d8f;
}

.appointment-form-heading,
.appointment-agenda-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.appointment-form-heading h2,
.appointment-agenda-heading h2 {
    margin: 3px 0 0;
}

.duration-badge,
.agenda-count {
    padding: 8px 12px;
    border-radius: 999px;
    background: #e1f5f1;
    color: #17695f;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.appointment-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
}

.appointment-form textarea,
.appointment-form label:has(textarea),
.appointment-form button,
.appointment-form a {
    grid-column: 1 / -1;
}

.doctor-calendar {
    grid-column: 1 / -1;
    padding: 16px;
    border: 1px solid #cfe0e8;
    border-radius: 14px;
    background: linear-gradient(135deg, #f4fafc, #eef7f5);
}

.doctor-calendar-empty {
    padding: 14px;
    color: var(--muted);
    font-size: 0.88rem;
    text-align: center;
}

.calendar-warning {
    color: #996218;
    background: #fff8e8;
    border-radius: 9px;
}

.doctor-calendar-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 14px;
}

.doctor-calendar-header strong,
.doctor-calendar-header small {
    display: block;
}

.doctor-calendar-header small {
    margin-top: 3px;
    color: var(--muted);
}

.doctor-calendar-header > span {
    padding: 6px 10px;
    border-radius: 999px;
    background: #dcefe9;
    color: #17695f;
    font-size: 0.74rem;
    font-weight: 800;
    white-space: nowrap;
}

.calendar-days,
.time-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.calendar-day,
.time-slot {
    border: 1px solid #c8dbe4;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    transition: 0.15s ease;
}

.calendar-day {
    min-width: 82px;
    padding: 9px 10px;
    text-align: center;
}

.calendar-day span,
.calendar-day strong,
.calendar-day small {
    display: block;
}

.calendar-day span {
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
}

.calendar-day strong {
    margin: 3px 0;
    color: var(--primary-dark);
    font-size: 1.15rem;
}

.calendar-day small {
    color: var(--muted);
    font-size: 0.7rem;
}

.calendar-day:hover,
.calendar-day.selected,
.time-slot:hover,
.time-slot.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
}

.time-slot.occupied,
.time-slot.occupied:hover {
    border-color: #e4c9c5;
    background: #f8e9e7;
    color: #a83228;
    cursor: not-allowed;
    opacity: 0.78;
    transform: none;
}

.calendar-day.selected strong,
.calendar-day.selected span,
.calendar-day.selected small {
    color: #fff;
}

.calendar-slots {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed #c4d9e0;
}

.calendar-slots-label {
    margin-bottom: 9px;
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: capitalize;
}

.time-slot {
    min-width: 62px;
    padding: 7px 9px;
    font-size: 0.8rem;
    font-weight: 700;
}

.appointments-layout .table-wrap {
    border: 1px solid #dce8ee;
    border-radius: 12px;
}

.appointments-layout table {
    min-width: 900px;
}

.status-badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-scheduled { background: #e8f1fb; color: #1769aa; }
.status-confirmed { background: #e1f5f1; color: #17695f; }
.status-arrived { background: #fff4dd; color: #9a5b00; }
.status-completed { background: #e8f6ed; color: #23845a; }
.status-cancelled,
.status-missed { background: #fdebea; color: #a52b22; }

@media (max-width: 720px) {
    .patients-layout > .card:first-child .form {
        grid-template-columns: 1fr;
    }

    .appointment-form {
        grid-template-columns: 1fr;
    }

    .appointment-form-heading,
    .appointment-agenda-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

.specialty-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
    padding: 16px;
    border: 1px solid #cfe0ef;
    border-radius: 14px;
    background: linear-gradient(120deg, #edf6fc, #f9fcff);
}

.specialty-section strong,
.specialty-section span {
    display: block;
}

.specialty-section span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.92rem;
}

.specialty-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: min(520px, 100%);
}

.specialty-filter select {
    flex: 1;
}

.patient-header-card {
    margin-top: 18px;
    padding: 18px 20px;
    border: 1px solid #cfe0ef;
    border-radius: 16px;
    background: linear-gradient(135deg, #f8fcfe 0%, #eaf5f8 100%);
    box-shadow: 0 10px 24px rgba(16, 45, 66, 0.06);
}

.latest-attention-card {
    margin: 18px 0;
    padding: 20px;
    border: 1px solid #cfe0e8;
    border-left: 5px solid #2a9d8f;
    border-radius: 14px;
    background: linear-gradient(135deg, #f6fbfc, #eef8f5);
}

.latest-attention-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.latest-attention-heading h2 {
    margin: 3px 0 0;
    font-size: 1.15rem;
}

.latest-attention-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.latest-attention-grid div {
    padding: 11px 12px;
    border: 1px solid rgba(42, 157, 143, 0.18);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
}

.latest-attention-grid span,
.latest-attention-grid strong {
    display: block;
}

.latest-attention-grid span {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.latest-attention-grid strong {
    font-size: 0.88rem;
}

.latest-attention-wide {
    grid-column: 1 / -1;
}

.history-attachments {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 0.82rem;
}

.history-attachments strong {
    color: var(--muted);
}

.history-attachments a {
    padding: 5px 8px;
    border-radius: 7px;
    background: #edf5fc;
    color: var(--primary-dark);
    font-weight: 700;
}

.patient-header-main {
    display: flex;
    align-items: center;
    gap: 13px;
    padding-bottom: 16px;
    border-bottom: 1px solid #d6e7ed;
}

.patient-avatar-large {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 15px;
    background: #1769aa;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.patient-header-title {
    flex: 1;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.patient-header-title strong {
    color: #102d42;
    font-size: 1.15rem;
}

.readonly-label {
    color: #6d8796;
    font-size: 0.78rem;
}

.attention-badge {
    min-width: 175px;
    padding: 10px 13px;
    border: 1px solid #b8dfd9;
    border-radius: 11px;
    background: #e1f5f1;
    color: #17695f;
}

.attention-badge span,
.attention-badge strong {
    display: block;
}

.attention-badge span {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.attention-badge strong {
    margin-top: 4px;
    font-size: 0.88rem;
}

.patient-header-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.patient-header-grid div {
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e0ebf0;
}

.patient-header-grid span,
.patient-header-grid strong {
    display: block;
}

@media (max-width: 640px) {
    .patient-header-main {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .attention-badge {
        width: 100%;
        margin-left: 65px;
    }
}

.patient-header-grid span {
    color: #78909c;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.patient-header-grid strong {
    margin-top: 4px;
    color: #1b3547;
    font-size: 0.9rem;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.quick-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    box-shadow: var(--shadow);
}

.quick-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.quick-card p {
    margin-top: 0;
    color: var(--muted);
}

.quick-card .btn {
    margin-top: 8px;
}

.quick-access-card {
    position: relative;
    overflow: hidden;
    border: 1px solid #dce7ed !important;
    border-radius: 16px !important;
    background: #fff !important;
    box-shadow: 0 8px 20px rgba(16, 45, 66, 0.06) !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.quick-access-card::before {
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    content: '';
    background: var(--quick-color, #1769aa);
}

.quick-access-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 28px rgba(16, 45, 66, 0.12) !important;
}

.quick-access-card .card-body {
    display: flex;
    min-height: 212px;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 22px 20px;
}

.quick-access-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin-bottom: 18px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--quick-color, #1769aa) 14%, white);
    color: var(--quick-color, #1769aa);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.03em;
}

.quick-access-card h3 {
    margin-bottom: 8px;
    color: #102d42;
}

.quick-access-card p {
    min-height: 42px;
    margin-bottom: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.quick-access-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--quick-color, #1769aa);
    font-size: 0.82rem;
    font-weight: 800;
}

.quick-access-link:hover {
    color: var(--quick-color, #1769aa);
    text-decoration: none;
}

.quick-access-link span {
    font-size: 1rem;
    transition: transform 0.18s ease;
}

.quick-access-link:hover span {
    transform: translateX(4px);
}

.quick-access-patients { --quick-color: #1769aa; }
.quick-access-history { --quick-color: #7b4ca0; }
.quick-access-appointments { --quick-color: #218579; }
.quick-access-users { --quick-color: #c47b24; }

.dashboard-hero {
    background: linear-gradient(120deg, #0e4d7d 0%, #1769aa 58%, #2a9d8f 100%);
}

.dashboard-bootstrap .card {
    border-radius: 1rem;
}

.dashboard-bootstrap {
    max-width: 1280px;
    margin: 0 auto;
}

.dashboard-bootstrap > .row .card {
    border-top: 4px solid var(--primary) !important;
}

.signature-preview-card {
    min-height: 220px;
}

.backup-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 20px;
    border-top: 4px solid #1769aa;
}

.backup-card h2 {
    margin-bottom: 6px;
}

.audit-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 20px 0;
}

.audit-filters label {
    min-width: 180px;
}

.audit-card {
    padding: 14px;
    border-top: 4px solid #7b4ca0;
}

.audit-action {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    background: #edf5fc;
    color: #1769aa;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.audit-crear,
.audit-reactivar { background: #e6f6f2; color: #17695f; }
.audit-actualizar { background: #fff4dd; color: #996218; }
.audit-eliminar,
.audit-desactivar { background: #fde9e7; color: #a83228; }
.audit-descargar { background: #efe8f7; color: #68408b; }

.security-card {
    max-width: 760px;
    margin-top: 20px;
    border-top: 4px solid #1769aa;
}

.security-card-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.security-card-heading h2,
.security-card-heading p {
    margin: 0;
}

.security-card-heading p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.security-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #e7f3fb;
    color: var(--primary);
    font-weight: 900;
}

.report-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    margin: 20px 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f7fafc;
}

.report-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.report-stat {
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(135deg, #fff, #f3f8fb);
}

.report-stat span,
.report-stat strong {
    display: block;
}

.report-stat span {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.report-stat strong {
    margin-top: 7px;
    color: var(--primary-dark);
    font-size: 1.75rem;
}

.report-results-card {
    border-top: 4px solid #1769aa;
}

.labs-layout {
    display: grid;
    gap: 20px;
    margin: 0;
    padding: 24px 30px 30px;
}

.labs-panel {
    padding: 0;
    overflow: hidden;
    min-height: calc(100vh - 32px);
    background: #f7fafc;
}

.labs-page-heading {
    padding: 32px 36px;
    color: #fff;
    background: linear-gradient(120deg, #0b416c 0%, #1769aa 62%, #2a9d8f 100%);
}

.labs-page-heading h1 {
    margin: 4px 0 5px;
    color: #fff;
}

.labs-page-heading p,
.labs-page-heading .eyebrow {
    color: rgba(255, 255, 255, 0.8);
}

.labs-page-heading .btn-secondary {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.3);
}

.labs-layout > .card {
    margin: 0;
    box-shadow: 0 8px 24px rgba(20, 42, 69, 0.06);
}

.lab-section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e5edf3;
}

.lab-section-heading h2,
.lab-section-heading p {
    margin: 0;
}

.lab-section-heading p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
}

.lab-section-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
    background: #e1f5f1;
    color: #17695f;
    font-size: 0.72rem;
    font-weight: 900;
}

.lab-form-card .form input,
.lab-form-card .form select,
.lab-form-card .form textarea {
    border-color: #cbd9e5;
    background: #fbfdff;
}

.lab-list-card .table-wrap {
    margin-top: 16px;
}

.lab-list-card tbody tr:hover {
    background: #f1faf8;
}

.lab-order-card {
    border-top: 4px solid #2a9d8f;
}

.lab-orders-list-card {
    border-top: 4px solid #1769aa;
}

.lab-orders-timeline .timeline-item {
    border-left: 4px solid #2a9d8f;
}

.lab-order-document {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    border: 1px solid #dbe4ee;
    background: #fff;
}

.lab-order-brand,
.lab-order-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid #dbe4ee;
}

.lab-order-brand {
    justify-content: flex-start;
}

.lab-order-brand strong,
.lab-order-brand span {
    display: block;
}

.lab-order-brand span,
.lab-order-title span,
.lab-order-signature span {
    color: var(--muted);
    font-size: 0.86rem;
}

.lab-order-title {
    margin-top: 18px;
    color: #1769aa;
    font-size: 1.1rem;
}

.lab-order-patient,
.lab-order-test {
    margin-top: 26px;
    padding: 18px;
    border: 1px solid #dce8ee;
    border-radius: 12px;
    background: #f8fbfd;
}

.lab-order-patient h2,
.lab-order-test h2,
.lab-order-test h3 {
    margin-top: 0;
}

.lab-order-test-name {
    padding: 14px;
    border-radius: 10px;
    background: #e1f5f1;
    color: #17695f;
    font-size: 1.15rem;
    font-weight: 800;
}

.lab-order-signature {
    display: grid;
    justify-items: center;
    gap: 6px;
    width: 320px;
    margin: 70px auto 10px;
    text-align: center;
}

.lab-order-signature-image {
    display: block;
    max-width: 180px;
    max-height: 72px;
    object-fit: contain;
}

.recipes-panel {
    padding: 0;
    overflow: hidden;
    background: #f7fafc;
}

.recipes-page-heading {
    position: relative;
    padding: 32px 36px;
    color: #fff;
    background:
        radial-gradient(circle at 86% 18%, rgba(255, 255, 255, 0.18), transparent 27%),
        linear-gradient(120deg, #0b416c 0%, #1769aa 62%, #68408b 100%);
}

.recipes-page-heading::after {
    position: absolute;
    right: 32px;
    bottom: -18px;
    width: 160px;
    height: 52px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    content: '';
    transform: rotate(-8deg);
}

.recipes-page-heading h1 {
    margin: 4px 0 5px;
    color: #fff;
}

.recipes-page-heading p,
.recipes-page-heading .eyebrow {
    color: rgba(255, 255, 255, 0.8);
}

.recipes-page-heading .btn-secondary {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.3);
}

.recipes-layout {
    display: grid;
    gap: 20px;
    margin: 0;
    padding: 24px 30px 30px;
}

.recipes-layout > .card {
    margin: 0;
    box-shadow: 0 8px 24px rgba(20, 42, 69, 0.06);
}

.recipe-form-card {
    border-top: 4px solid #1769aa;
    background: #fff;
}

.recipe-list-card {
    margin-bottom: 0 !important;
    border-top: 4px solid #7b4ca0;
    background: #fff;
}

.recipe-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 16px 20px;
}

.recipe-form label {
    gap: 6px;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 800;
}

.recipe-form input,
.recipe-form select,
.recipe-form textarea {
    border-color: #cbd9e5;
    border-radius: 10px;
    background: #fbfdff;
    font-size: 0.92rem;
}

.recipe-form input:focus,
.recipe-form select:focus,
.recipe-form textarea:focus {
    border-color: #1769aa;
    box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
    background: #fff;
}

.recipe-form > input[type="hidden"],
.recipe-form > button,
.recipe-form > a,
.recipe-form > label:last-of-type {
    grid-column: 1 / -1;
}

.recipe-section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e5edf3;
}

.recipe-section-heading h2,
.recipe-section-heading p {
    margin: 0;
}

.recipe-section-heading p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
}

.recipe-section-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    background: #efe8f7;
    color: #68408b;
    font-size: 0.84rem;
    font-weight: 900;
}

.recipe-form .btn-primary {
    min-width: 150px;
    justify-self: start;
    box-shadow: 0 8px 16px rgba(23, 105, 170, 0.2);
}

.recipe-form .btn-secondary {
    justify-self: start;
}

.recipe-list-card .empty {
    padding: 18px;
    border: 1px dashed #cbd9e5;
    border-radius: 12px;
    background: #f8fbfd;
}

.recipe-list-card .timeline-item {
    border-left: 4px solid #7b4ca0;
    box-shadow: 0 5px 16px rgba(20, 42, 69, 0.04);
}

.recipe-list-card .timeline-item header strong {
    color: #1769aa;
}

.medication-code {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 7px;
    border-radius: 6px;
    background: #edf5fc;
    color: #1769aa;
    font-size: 0.76rem;
    font-weight: 800;
}

.medication-picker {
    position: relative;
    display: block;
}

.medication-picker > input[type="search"] {
    width: 100%;
}

.medication-results {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    z-index: 10;
    display: grid;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid #cbd9e5;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(20, 42, 69, 0.16);
}

.medication-result {
    padding: 10px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #243b53;
    cursor: pointer;
    text-align: left;
}

.medication-result:hover,
.medication-result:focus {
    background: #edf5fc;
    color: #1769aa;
    outline: 0;
}

.recipe-badge {
    margin-left: auto;
    padding: 7px 11px;
    border-radius: 999px;
    background: #edf5fc;
    color: var(--primary-dark);
    font-size: 0.74rem;
    font-weight: 800;
    white-space: nowrap;
}

.recipe-count-badge {
    background: #efe8f7;
    color: #68408b;
}

.lab-form-card {
    border-top: 4px solid #2a9d8f;
}

.lab-list-card {
    border-top: 4px solid #1769aa;
}

.catalog-panel {
    padding: 0;
    overflow: hidden;
    min-height: calc(100vh - 32px);
}

.catalog-heading {
    padding: 28px 30px;
    color: #fff;
    background: linear-gradient(120deg, #0b416c 0%, #1769aa 68%, #2a9d8f 100%);
}

.catalog-heading h1,
.catalog-heading p,
.catalog-heading .eyebrow {
    color: #fff;
}

.catalog-heading p,
.catalog-heading .eyebrow {
    color: rgba(255, 255, 255, 0.8);
}

.catalog-heading .btn-secondary {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.3);
}

.catalog-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 24px 30px 30px;
}

.catalog-layout > .card {
    margin: 0;
}

.catalog-form-card {
    align-self: start;
    border-top: 4px solid #2a9d8f;
}

.catalog-form-card > .form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
}

.catalog-form-card > .form .form-actions {
    justify-content: flex-start;
}

.catalog-import {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #e5edf3;
}

.catalog-import h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.catalog-import .btn-secondary {
    justify-self: start;
}

.catalog-list-card {
    border-top: 4px solid #1769aa;
}

.catalog-list-card .panel-header {
    align-items: flex-start;
}

.catalog-list-card .table-wrap {
    margin-top: 16px;
}

.catalog-list-card table {
    border-collapse: separate;
    border-spacing: 0 6px;
}

.catalog-list-card th,
.catalog-list-card td {
    border-bottom: 0;
}

.catalog-list-card tbody tr {
    background: #f8fbfd;
    transition: background 160ms ease, transform 160ms ease;
}

.catalog-list-card tbody tr:hover {
    background: #edf5fc;
    transform: translateX(2px);
}

.catalog-list-card tbody td:first-child {
    border-radius: 10px 0 0 10px;
}

.catalog-list-card tbody td:last-child {
    border-radius: 0 10px 10px 0;
}

.catalog-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
    gap: 12px;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid #dce8ee;
    border-radius: 12px;
    background: #f7fbfd;
}

.catalog-search label {
    margin: 0;
}

.catalog-pagination {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.catalog-list-card td strong {
    color: #1769aa;
}

.signature-preview,
.report-signature {
    display: block;
    max-width: 260px;
    max-height: 100px;
    object-fit: contain;
}

.report-signature {
    margin: 0 auto 6px;
}

.role-guide {
    display: grid;
    gap: 10px;
}

.role-guide-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fbfdff;
}

.role-guide-item.active {
    border-color: rgba(23, 105, 170, 0.4);
    background: #edf5fc;
}

.role-guide-item strong {
    display: block;
    margin-bottom: 4px;
}

.role-guide-item p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.form {
    display: grid;
    gap: 14px;
}

.form-section {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid #dce8ee;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfdfe, #f5fafc);
}

.history-form {
    gap: 10px;
    max-width: 980px;
    margin: 0 auto;
}

.history-form .form-section {
    gap: 10px;
    padding: 12px;
    border: 0;
    background: transparent;
}

.history-form label {
    gap: 4px;
    font-size: 0.88rem;
}

.history-form input,
.history-form select,
.history-form textarea {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.history-form input,
.history-form select {
    max-width: 360px;
}

.history-form textarea {
    max-width: 100%;
}

.history-form textarea {
    min-height: 58px;
}

.history-form .form-section-heading {
    padding-bottom: 8px;
    border-bottom: 0 !important;
}

.form-section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e1ebef;
}

.form-section-heading > span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #dff5f1;
    color: #17695f;
    font-size: 0.72rem;
    font-weight: 800;
}

.form-section-heading strong,
.form-section-heading small {
    display: block;
}

.form-section-heading strong {
    color: #173b50;
}

.form-section-heading small {
    margin-top: 2px;
    color: #78909c;
    font-size: 0.78rem;
}

.field-grid {
    display: grid;
    gap: 14px;
}

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

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

.agenda-list {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

.agenda-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #dce8ee;
    border-radius: 10px;
    background: #f8fbfc;
}

.agenda-list-item strong,
.agenda-list-item small {
    display: block;
}

.agenda-list-item small {
    margin-top: 3px;
    color: #78909c;
}

.form label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

.checkbox-label {
    display: flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 9px !important;
}

.checkbox-label input {
    width: auto;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: #fff;
    color: var(--text);
}

input[type="hidden"] {
    display: none !important;
}

.form-section input,
.form-section select,
.form-section textarea {
    background: #fff;
    border-color: #cbdde5;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(23, 105, 170, 0.18);
    border-color: var(--primary);
}

.btn,
.link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    font: inherit;
    transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.btn:hover,
.link:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--surface-soft);
    color: var(--text);
    border-color: var(--border);
}

.searchbar {
    display: flex;
    gap: 12px;
    margin: 18px 0;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.actions {
    align-items: center;
    flex-wrap: wrap;
}

.actions form {
    margin: 0;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.1;
    text-decoration: none;
    white-space: nowrap;
}

.action-btn:hover {
    color: #fff;
    text-decoration: none;
    filter: brightness(0.92);
    transform: translateY(-1px);
}

.action-blue { background: #1769aa; }
.action-purple { background: #7257a8; }
.action-teal { background: #218c87; }
.action-green { background: #23845a; }
.action-orange { background: #c77718; }
.action-red { background: #b42318; }

.link {
    background: transparent;
    color: var(--primary);
    padding: 0;
    min-height: auto;
    border: 0;
}

.danger {
    color: var(--error);
}

.alert {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success {
    background: #e9f8f1;
    border-color: #bdebd4;
    color: var(--success);
}

.alert-error {
    background: #fdecec;
    border-color: #f4b7b7;
    color: var(--error);
}

.timeline {
    display: grid;
    gap: 14px;
}

.specialty-history-list {
    display: grid;
    gap: 20px;
}

.specialty-history-group {
    padding: 14px;
    border: 1px solid #d5e5eb;
    border-radius: 14px;
    background: #f8fbfc;
}

.specialty-history-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dce9ee;
    color: #1769aa;
    font-weight: 800;
}

.specialty-history-heading small {
    color: #78909c;
    font-weight: 600;
}

.attendance-lock {
    padding: 18px;
    border: 1px solid #f0c5c1;
    border-radius: 12px;
    background: #fff4f3;
    color: #8e2019;
}

.attendance-lock strong,
.attendance-lock p {
    display: block;
}

.attendance-lock p {
    margin: 7px 0 0;
    color: #a0443d;
}

.timeline-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    background: linear-gradient(180deg, #fff, #fafdff);
}

.timeline-item header {
    margin-bottom: 10px;
}

.report-top {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.report-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.report-logo {
    width: 70px;
    height: 70px;
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 8px;
    flex: 0 0 auto;
}

.report-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--primary);
}

.report-header {
    align-items: flex-start;
}

.report-kicker {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 700;
}

.report-block + .report-block {
    margin-top: 22px;
}

.report-document .print-panel { max-width: 1040px; margin: 24px auto; padding: 34px; }
.report-document h1, .report-document h2, .report-document h3 { color: #19324b; }
.report-document .report-top { padding-bottom: 20px; border-bottom: 3px solid #1d6b78; }
.report-document .report-block { break-inside: avoid; }
.report-section-title { align-items: center; }
.report-status { color: #176b59; background: #e8f6f0; border: 1px solid #b9e4d4; border-radius: 999px; padding: 7px 12px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.report-clinical-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.report-clinical-grid p { margin: 0; padding: 10px 0; border-bottom: 1px solid #e5edf2; }
.report-clinical-grid p:nth-child(n+4), .report-clinical-grid .report-vitals { grid-column: 1 / -1; }
.report-vitals { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding: 13px; border-radius: 12px; background: #eff7f8; color: #19324b; }
.report-vitals strong { width: 100%; text-transform: uppercase; letter-spacing: .06em; font-size: .76rem; color: #1d6b78; }
.report-vitals span { padding-right: 15px; border-right: 1px solid #c9dfe2; font-size: .9rem; }
.report-vitals span:last-child { border-right: 0; }
.report-consent-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.report-consent-grid > div { padding: 16px; border: 1px solid #dce8ec; border-radius: 12px; background: #f7fbfc; }
.report-consent-grid p { margin: 7px 0 0; white-space: normal; }
.report-document .timeline-item { border-radius: 10px; padding: 13px 15px; break-inside: avoid; }
.report-document .signature-block { border-top: 1px solid #dce5ea; padding-top: 28px; }

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

.summary-grid div {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fafcff;
    padding: 14px;
    display: grid;
    gap: 6px;
}

.summary-grid strong {
    color: var(--muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.summary-grid span {
    font-size: 1rem;
    font-weight: 600;
}

.report-notes {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fafcff;
    padding: 16px;
    color: var(--muted);
}

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

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

.report-meta {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fafcff;
    padding: 14px;
    min-width: 170px;
    text-align: right;
    display: grid;
    gap: 4px;
}

.report-meta span {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.signature-block {
    margin-top: 30px;
    display: grid;
    justify-items: end;
    gap: 10px;
}

.signature-block strong {
    display: block;
}

.signature-block span,
.signature-label {
    color: var(--muted);
    font-size: 0.92rem;
}

.signature-line {
    width: 320px;
    border-top: 1px solid #3a4656;
}

.odontogram-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.odontogram-table td,
.odontogram-table th {
    padding: 10px 8px;
}

.form-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
}

.print-page {
    background: #fff;
}

.print-container {
    width: min(1040px, calc(100% - 30px));
}

.print-panel {
    box-shadow: none;
    border-color: #cfd8e3;
}

.no-print {
    display: flex;
}

@media (max-width: 960px) {
    .grid-two,
    .catalog-layout,
    .user-form-card .form,
    .recipe-form,
    .hero,
    .odontogram-grid,
    .report-top,
    .report-subheader {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .user-form-card .role-guide {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-meta,
    .signature-block {
        justify-items: start;
        text-align: left;
    }

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

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

    .catalog-form-card > .form,
    .catalog-search {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .topbar {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .container {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .searchbar {
        flex-direction: column;
    }

    .field-grid-three {
        grid-template-columns: 1fr;
    }

    .field-grid-two {
        grid-template-columns: 1fr;
    }

    .users-page-heading {
        padding: 22px 18px;
    }

    .recipes-page-heading {
        padding: 24px 18px;
    }

    .catalog-heading {
        padding: 24px 18px;
    }

    .labs-page-heading {
        padding: 24px 18px;
    }

    .catalog-layout {
        padding: 18px 14px 20px;
    }

    .labs-layout {
        padding: 18px 14px 20px;
    }

    .lab-section-heading {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .recipes-layout {
        padding: 18px 14px 20px;
    }

    .recipe-section-heading {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .recipe-badge {
        margin-left: 52px;
    }

    .latest-attention-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .latest-attention-grid {
        grid-template-columns: 1fr;
    }

    .report-filters,
    .report-stat-grid {
        grid-template-columns: 1fr;
    }

    .users-layout > .card {
        margin-right: 14px;
        margin-left: 14px;
    }

    .user-section-heading {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .user-mode-badge,
    .user-count-badge {
        margin-left: 50px;
    }

    .user-form-card .role-guide {
        grid-template-columns: 1fr;
    }

    .specialty-section,
    .specialty-filter {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar {
        width: 100%;
    }

    .report-brand {
        align-items: flex-start;
    }

    .signature-line {
        width: 100%;
    }
}

@media print {
    body {
        background: #fff;
    }

    .topbar,
    .no-print {
        display: none !important;
    }

    .container {
        width: 100%;
        margin: 0;
    }

    .panel,
    .card,
    .stat-card,
    .auth-card {
        box-shadow: none;
    }
    .print-container { width: 100%; }
    .report-document .print-panel { margin: 0; padding: 0; border: 0; }
    .report-document .report-block { margin-top: 14px; }
    .report-document .timeline-item { background: #fff; }
    .report-document .report-top { padding-top: 0; }
}

.consent-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; margin-top: 4rem; }
.consent-signature-image { display: block; max-width: 220px; max-height: 90px; margin-top: 1rem; object-fit: contain; }
.consent-document h3 { margin-top: 1.5rem; }
@media (max-width: 700px) { .consent-signatures { grid-template-columns: 1fr; gap: 2rem; } }
@media print { .consent-document { max-width: none; } .consent-document .card { box-shadow: none; border: 0; } }

/* Print layout: deliberately distinct from the application cards. */
.report-document { background: #e9eef1 !important; color: #263642; }
.report-document .print-container { max-width: 210mm !important; width: 100% !important; margin: 24px auto !important; }
.report-document .print-panel { background: #fff !important; border: 0 !important; border-radius: 0 !important; padding: 0 18mm 16mm !important; overflow: hidden; }
.report-document .report-top { margin: 0 -18mm 18px !important; padding: 16mm 18mm 12mm !important; background: #173f50 !important; border-bottom: 6px solid #e0a458 !important; color: #fff !important; }
.report-document .report-top h1, .report-document .report-top p, .report-document .report-top .report-kicker { color: #fff !important; }
.report-document .report-logo { border: 0; border-radius: 50%; width: 58px; height: 58px; }
.report-document .report-logo-fallback { background: #e0a458; color: #173f50 !important; }
.report-document .report-block { margin-top: 22px !important; padding-top: 0; }
.report-document .report-block > h2, .report-document .report-section-title { border-bottom: 2px solid #d6e2e7; padding-bottom: 9px; margin-bottom: 12px; }
.report-document .report-block > h2, .report-document .report-section-title h2 { font-size: 1.05rem; letter-spacing: .04em; text-transform: uppercase; }
.report-document .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid #d6e2e7; }
.report-document .summary-grid div { border: 0; border-right: 1px solid #d6e2e7; border-bottom: 1px solid #d6e2e7; border-radius: 0; background: #f7fafb; padding: 11px 13px; min-height: 55px; }
.report-document .summary-grid div:nth-child(3n) { border-right: 0; }
.report-document .summary-grid strong { font-size: .68rem; color: #52707b; }
.report-document .summary-grid span { font-size: .91rem; color: #1d3441; }
.report-document .report-notes { background: #fff; border: 1px solid #d6e2e7; border-left: 5px solid #2b8792; border-radius: 0; color: #263642; }
.report-document .report-clinical-grid p { padding: 8px 0; }
.report-document .timeline-item { border: 0; border-left: 4px solid #2b8792; border-radius: 0; background: #f6f9fa; margin-bottom: 9px; padding: 11px 14px; }
.report-document .signature-block { margin-top: 34px; min-height: 130px; justify-items: start; align-items: end; }
.report-document .report-signature { max-height: 70px; }
@media print {
    .report-document { background: #fff !important; }
    .report-document .print-container { margin: 0 !important; }
    .report-document .print-panel { padding: 0 12mm 12mm !important; }
    .report-document .report-top { margin-left: -12mm !important; margin-right: -12mm !important; padding-left: 12mm !important; padding-right: 12mm !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-document .summary-grid div, .report-document .report-vitals, .report-document .timeline-item { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-document .report-block { break-inside: avoid; }
}

/* Clinical application shell */
body {
    background: #f3f7fa;
}

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

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 28px 18px 20px;
    background: #102d42;
    color: #d9e8f2;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 10px 30px;
}

.sidebar-brand a {
    display: block;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 800;
}

.sidebar-brand small,
.user-mini small {
    display: block;
    color: #91adbe;
    font-size: 0.76rem;
    margin-top: 3px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: #2a9d8f;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.nav-label {
    padding: 0 12px 9px;
    color: #7594a8;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px;
    border-radius: 10px;
    color: #b9cfdb;
    font-weight: 600;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: #1e506c;
    text-decoration: none;
}

.nav-icon {
    display: inline-grid;
    place-items: center;
    width: 22px;
    color: #72d1c6;
    font-size: 1rem;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 18px 10px 0;
    border-top: 1px solid rgba(217, 232, 242, 0.14);
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.user-mini strong {
    display: block;
    max-width: 155px;
    overflow: hidden;
    color: #fff;
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    background: #dff5f1;
    color: #17695f;
    font-weight: 800;
}

.logout-link {
    display: block;
    color: #91adbe;
    font-size: 0.86rem;
}

.logout-link:hover {
    color: #fff;
}

.app-main {
    min-width: 0;
    flex: 1;
}

.app-main .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    min-height: 76px;
    padding: 16px clamp(20px, 4vw, 48px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid #dce7ed;
    box-shadow: 0 5px 20px rgba(16, 45, 66, 0.04);
}

.topbar-title strong,
.topbar-title .eyebrow {
    display: block;
}

.topbar-title strong {
    color: #102d42;
    font-size: 1.08rem;
}

.eyebrow {
    margin-bottom: 3px;
    color: #7290a0;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.app-main > .container {
    width: min(1280px, calc(100% - 48px));
    margin-top: 32px;
}

.focus-mode .sidebar,
.focus-mode .topbar {
    display: none;
}

.focus-mode .app-main > .container {
    width: min(1440px, calc(100% - 32px));
    margin-top: 18px;
}

.focus-mode .grid-two {
    grid-template-columns: 1fr;
}

.focus-mode .panel {
    min-height: calc(100vh - 36px);
}

.panel,
.card,
.auth-card {
    border-color: #dce7ed;
    box-shadow: 0 12px 30px rgba(16, 45, 66, 0.06);
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        padding: 14px 12px;
    }

    .sidebar-brand {
        padding: 0 6px 14px;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        gap: 5px;
    }

    .nav-label,
    .sidebar-bottom {
        display: none;
    }

    .sidebar .nav-link {
        flex: 0 0 auto;
        padding: 9px 12px;
        font-size: 0.88rem;
    }

    .app-main .topbar {
        position: static;
        min-height: 64px;
    }

    .app-main > .container {
        width: calc(100% - 20px);
        margin-top: 18px;
    }
}

@media print {
    .sidebar {
        display: none !important;
    }

    .app-main {
        width: 100%;
    }

    .print-lab-order {
        border: 0;
        box-shadow: none;
    }

    .print-lab-order .lab-order-document {
        max-width: none;
        border: 0;
    }
}
