﻿





/* ============ TOKENS ============ */
/* Flat, single-hue color system — no gradients anywhere.
         Each theme below is a calm, analogous primary/accent pair
         chosen for a clinical/health context: enough contrast to
         read clearly, muted enough saturation to stay restful. */
:root {
    font-size: 14px; /* global type scale: all rem sizes derive from this */
    --clr-primary: #2E6F90;
    --clr-primary-light: #DCEAF1;
    --clr-accent: #3F9C86;
    --clr-accent-light: #E1F1EC;
    --font-en: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-en-display: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-fa: "Vazirmatn", Tahoma, sans-serif;
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 78px;
    --topbar-h: 68px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --bg-body: #F3F6F8;
    --clr-text: #1c2b3a;
    --clr-text-muted: #5b7185;
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-bg-strong: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.65);
    --glass-shadow: 0 8px 32px rgba(50, 90, 130, 0.12);
    --sidebar-bg: rgba(255, 255, 255, 0.68);
    --input-bg: rgba(255, 255, 255, 0.92);
    --input-border: rgba(28, 43, 58, 0.22);
    --input-border-hover: rgba(28, 43, 58, 0.34);
    --checkbox-border: rgba(28, 43, 58, 0.4);
    --divider: rgba(28, 43, 58, 0.08);
    /* Fixed semantic colors (status), independent of theme */
    --clr-success: #1f9d55;
    --clr-success-bg: rgba(31, 157, 85, 0.12);
    --clr-warning: #b5860b;
    --clr-warning-bg: rgba(230, 168, 20, 0.14);
    --clr-danger: #d94141;
    --clr-danger-bg: rgba(217, 65, 65, 0.12);
    /* Tells the browser to render native chrome (the <select> popup
           list in particular) with a light palette, so its contents stay
           legible even though we can't fully re-skin it with CSS. */
    color-scheme: light;
}

[data-mode="dark"] {
    --bg-body: #0d1520;
    --clr-text: #e7edf3;
    --clr-text-muted: #93a5b8;
    --glass-bg: rgba(255, 255, 255, 0.055);
    --glass-bg-strong: rgba(255, 255, 255, 0.09);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --sidebar-bg: rgba(15, 20, 28, 0.82);
    --input-bg: rgba(255, 255, 255, 0.09);
    --input-border: rgba(255, 255, 255, 0.28);
    --input-border-hover: rgba(255, 255, 255, 0.42);
    --checkbox-border: rgba(255, 255, 255, 0.45);
    --divider: rgba(255, 255, 255, 0.08);
    /* Same reasoning as above, flipped for dark mode: this is what
           actually fixes the unreadable <option> list in dark mode,
           since the popup is native UI and ignores our custom colors. */
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-en);
    background: var(--bg-body);
    background-attachment: fixed;
    color: var(--clr-text);
    transition: background 0.4s ease, color 0.3s ease;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============ CSS-ONLY i18n ============ */
[lang="fa"] body {
    font-family: var(--font-fa);
}

[lang="en"] .fa-text {
    display: none !important;
}

[lang="fa"] .en-text {
    display: none !important;
}

h1, h2, h3, h4, h5, h6, .display-font {
    font-family: var(--font-en-display);
}

[lang="fa"] h1, [lang="fa"] h2, [lang="fa"] h3, [lang="fa"] h4, [lang="fa"] h5, [lang="fa"] h6, [lang="fa"] .display-font {
    font-family: var(--font-fa);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--clr-primary);
    border-radius: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

a {
    text-decoration: none;
}

/* ============ GLASS ============ */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-lg);
}

.glass-strong {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* ============ TOPBAR ============ */
.topbar {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    inset-inline-start: var(--sidebar-w);
    height: var(--topbar-h);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: inset-inline-start 0.35s ease;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-bottom: 1px solid var(--glass-border);
}

body.sidebar-collapsed .topbar {
    inset-inline-start: var(--sidebar-w-collapsed);
}

@media (max-width: 991.98px) {
    .topbar {
        inset-inline-start: 0 !important;
        padding: 0 14px;
    }
}

.hamburger-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: var(--clr-primary);
    color: #fff;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.3s ease;
}

    .hamburger-btn:hover {
        transform: scale(1.06);
    }

    .hamburger-btn:active {
        transform: scale(0.94);
    }

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--clr-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

    .icon-btn:hover {
        background: var(--clr-primary);
        color: #fff;
        transform: translateY(-2px);
    }

.lang-switch {
    display: flex;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

    .lang-switch button {
        border: none;
        padding: 8px 12px;
        background: var(--glass-bg);
        color: var(--clr-text-muted);
        font-weight: 600;
        font-size: 0.78rem;
        transition: all 0.2s ease;
        cursor: pointer;
    }

        .lang-switch button.active {
            background: var(--clr-primary);
            color: #fff;
        }

/* Profile menu (opens from the avatar in the topbar).
   Uses Bootstrap's dropdown behaviour; only the look is set here.
   Reuses .avatar-sm for the initials circle. */
.avatar-btn {
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .avatar-btn:hover {
        transform: translateY(-2px);
    }

    .avatar-btn:focus-visible,
    .avatar-btn[aria-expanded="true"] {
        outline: 0;
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--clr-primary) 35%, transparent);
    }

.user-menu {
    --bs-dropdown-bg: var(--bg-body);
    --bs-dropdown-color: var(--clr-text);
    --bs-dropdown-border-color: var(--glass-border);
    --bs-dropdown-border-radius: var(--radius-md);
    --bs-dropdown-divider-bg: var(--divider);
    --bs-dropdown-link-color: var(--clr-text);
    --bs-dropdown-link-hover-color: var(--clr-primary);
    --bs-dropdown-link-hover-bg: color-mix(in srgb, var(--clr-primary) 10%, transparent);
    --bs-dropdown-link-active-color: var(--clr-primary);
    --bs-dropdown-link-active-bg: color-mix(in srgb, var(--clr-primary) 14%, transparent);
    --bs-dropdown-padding-x: 8px;
    --bs-dropdown-padding-y: 8px;
    min-width: 240px;
    max-width: calc(100vw - 24px);
    margin-top: 12px !important;
    box-shadow: var(--glass-shadow);
}

.user-menu-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 10px;
}

.user-menu-avatar {
    width: 44px;
    height: 44px;
    font-size: 0.95rem;
}

.user-menu-id {
    min-width: 0;
}

.user-menu-name {
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.user-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

    .user-menu .dropdown-item i {
        width: 1.2rem;
        text-align: center;
        font-size: 1.05rem;
    }

    .user-menu .dropdown-item.user-menu-danger {
        color: var(--clr-danger);
    }

        .user-menu .dropdown-item.user-menu-danger:hover,
        .user-menu .dropdown-item.user-menu-danger:focus-visible {
            color: var(--clr-danger);
            background: var(--clr-danger-bg);
        }

@media (max-width: 575.98px) {
    .user-menu {
        min-width: 220px;
    }
}

/* Doctor profile page (Profile > Index / Edit / Delete).
   Reuses .glass, .kpi-icon, .form-glass-section/.form-glass-title, .selected-drug chips,
   .btn-* and Bootstrap's grid. Hero first, then stat tiles, then two columns of cards
   (they stack below 1200px). */
.avatar-img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-hero {
    overflow: hidden;
    margin-bottom: 24px;
}

.profile-cover {
    position: relative;
    height: 110px;
    overflow: hidden;
    background: var(--clr-primary);
}

    .profile-cover::before,
    .profile-cover::after {
        content: "";
        position: absolute;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
    }

    .profile-cover::before {
        width: 220px;
        height: 220px;
        top: -110px;
        inset-inline-end: 8%;
    }

    .profile-cover::after {
        width: 140px;
        height: 140px;
        bottom: -80px;
        inset-inline-start: 22%;
    }

.profile-hero-body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px 24px;
    padding: 0 24px 24px;
}

.profile-photo {
    position: relative;
    flex: 0 0 auto;
    width: 128px;
    height: 128px;
    margin-top: -64px;
    border: 4px solid var(--bg-body);
    border-radius: 50%;
    background: var(--clr-primary);
    box-shadow: var(--glass-shadow);
    transition: opacity 0.2s ease;
}

    .profile-photo.is-busy {
        opacity: 0.55;
        pointer-events: none;
    }

    /* The upload form has no box of its own, so the camera button positions itself on the photo. */
    .profile-photo > form {
        display: contents;
    }

.profile-photo-img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-photo-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 2.4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
}

.profile-photo-btn {
    position: absolute;
    bottom: 2px;
    inset-inline-end: 2px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--clr-accent);
    border: 3px solid var(--bg-body);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

    .profile-photo-btn:hover {
        transform: scale(1.08);
        background: color-mix(in srgb, var(--clr-accent) 86%, #000);
    }

.profile-photo:focus-within .profile-photo-btn {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--clr-primary) 35%, transparent);
}

.profile-id {
    flex: 1 1 260px;
    min-width: 0;
    padding-top: 14px;
}

.profile-badge-ok {
    color: var(--clr-success);
    background: var(--clr-success-bg);
    border-color: transparent;
}

.profile-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 14px;
    margin-inline-start: auto;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.profile-stat {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    padding: 18px;
}

    .profile-stat > div:last-child {
        min-width: 0;
    }

.profile-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.profile-stat-text {
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.profile-stat-label {
    font-size: 0.8rem;
    color: var(--clr-text-muted);
}

.profile-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 24px;
    margin: 0 0 8px;
}

    .profile-info dt {
        margin-bottom: 2px;
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--clr-text-muted);
    }

    .profile-info dd {
        margin: 0;
        font-weight: 600;
        overflow-wrap: anywhere;
    }

.profile-danger {
    border-color: color-mix(in srgb, var(--clr-danger) 35%, var(--glass-border));
}

    .profile-danger .form-glass-title {
        color: var(--clr-danger);
    }

@media (max-width: 767.98px) {
    .profile-hero-actions {
        flex: 1 1 100%;
        padding-top: 0;
    }

        .profile-hero-actions > .btn,
        .profile-hero-actions > form {
            flex: 1 1 160px;
        }
}

@media (max-width: 575.98px) {
    .profile-cover {
        height: 90px;
    }

    .profile-hero-body {
        flex-direction: column;
        align-items: center;
        padding: 0 16px 20px;
        text-align: center;
    }

    .profile-photo {
        width: 112px;
        height: 112px;
        margin-top: -56px;
    }

    .profile-id {
        flex: 0 0 auto;
        width: 100%;
        padding-top: 0;
    }

        .profile-id .selected-drugs {
            justify-content: center;
        }

    .profile-hero-actions {
        width: 100%;
        flex-direction: column;
    }

        .profile-hero-actions > .btn,
        .profile-hero-actions > form {
            flex: 0 0 auto;
            width: 100%;
        }

    .profile-info {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    height: 100vh;
    height: 100dvh;
    width: var(--sidebar-w);
    z-index: 1040;
    background: var(--sidebar-bg);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border-inline-end: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: width 0.35s ease, transform 0.35s ease;
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
}

    .sidebar-brand .logo-badge {
        width: 38px;
        height: 38px;
        border-radius: 11px;
        flex-shrink: 0;
        background: var(--clr-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 1.15rem;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    }

    .sidebar-brand .brand-text {
        font-weight: 700;
        font-size: 1.05rem;
        white-space: nowrap;
        font-family: var(--font-en-display);
    }

[lang="fa"] .sidebar-brand .brand-text {
    font-family: var(--font-fa);
}

.sidebar-brand small {
    display: block;
    font-size: 0.65rem;
    color: var(--clr-text-muted);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 10px;
}

.nav-section-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--clr-text-muted);
    padding: 10px 12px 4px;
    font-weight: 700;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--clr-text);
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 3px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    position: relative;
}

    .side-link i.side-icon {
        font-size: 1.05rem;
        width: 22px;
        text-align: center;
        flex-shrink: 0;
        color: var(--clr-primary);
        transition: color 0.2s;
    }

    .side-link:hover {
        background: color-mix(in srgb, var(--clr-primary) 14%, transparent);
    }

    .side-link.active {
        background: var(--clr-primary);
        color: #fff;
        box-shadow: 0 6px 16px rgba(46, 111, 144, 0.32);
    }

        .side-link.active i.side-icon {
            color: #fff;
        }

    .side-link .chev {
        margin-inline-start: auto;
        font-size: 0.7rem;
        transition: transform 0.25s ease;
    }

    .side-link.open .chev {
        transform: rotate(90deg);
    }

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-inline-start: 14px;
}

    .submenu.open {
        max-height: 220px;
    }

    .submenu .side-link {
        font-size: 10px;
        padding: 8px 12px;
    }

        .submenu .side-link i.side-icon {
            font-size: 0.85rem;
        }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--divider);
    flex-shrink: 0;
}

.collapse-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px;
    border-radius: 12px;
    border: none;
    background: var(--glass-bg);
    color: var(--clr-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
}

body.sidebar-collapsed .sidebar-brand .brand-text, body.sidebar-collapsed .sidebar-brand small,
body.sidebar-collapsed .side-link span.label-text, body.sidebar-collapsed .side-link .chev,
body.sidebar-collapsed .nav-section-label, body.sidebar-collapsed .collapse-toggle-btn span {
    display: none;
}

body.sidebar-collapsed .submenu {
    display: none;
}

body.sidebar-collapsed .side-link {
    justify-content: center;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 270px !important;
    }

    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    [dir="rtl"] body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .side-link span.label-text, body.sidebar-collapsed .nav-section-label,
    body.sidebar-collapsed .collapse-toggle-btn span {
        display: inline;
    }

    body.sidebar-collapsed .side-link {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .sidebar-brand {
        justify-content: flex-start;
        padding: 0 18px;
    }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 20, 0.45);
    z-index: 1035;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 992px) {
    .sidebar-backdrop {
        display: none;
    }
}

/* ============ MAIN ============ */
.main-content {
    margin-inline-start: var(--sidebar-w);
    padding: calc(var(--topbar-h) + 22px) 26px 40px;
    transition: margin-inline-start 0.35s ease;
    min-height: 100vh;
}

body.sidebar-collapsed .main-content {
    margin-inline-start: var(--sidebar-w-collapsed);
}

@media (max-width: 991.98px) {
    .main-content {
        margin-inline-start: 0 !important;
        padding: calc(var(--topbar-h) + 18px) 16px 40px;
    }
}

.kpi-card {
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 14px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}
/* Semantic, flat icon backgrounds — theme-independent so KPI meaning stays legible
         (informational/primary, success, attention, critical) across every palette. */
.kpi-icon-primary {
    background: var(--clr-primary);
}

.kpi-icon-success {
    background: var(--clr-success);
}

.kpi-icon-warning {
    background: var(--clr-warning);
}

.kpi-icon-danger {
    background: var(--clr-danger);
}

.kpi-value {
    font-size: 1.9rem;
    font-weight: 700;
    font-family: var(--font-en-display);
    line-height: 1;
}

[lang="fa"] .kpi-value {
    font-family: var(--font-fa);
}

.kpi-label {
    font-size: 0.82rem;
    color: var(--clr-text-muted);
    font-weight: 600;
    margin-top: 4px;
}

.kpi-trend {
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
}

.trend-up {
    color: var(--clr-success);
    background: var(--clr-success-bg);
}

.trend-down {
    color: var(--clr-danger);
    background: var(--clr-danger-bg);
}

.tilt-card {
    transform-style: preserve-3d;
    will-change: transform;
    transition: transform 0.12s ease-out, box-shadow 0.3s ease;
}

    .tilt-card:hover {
        box-shadow: 0 26px 50px rgba(30, 60, 100, 0.22);
    }

.hero-banner {
    padding: 34px;
    position: relative;
    overflow: hidden;
    margin-bottom: 22px;
    background: var(--clr-primary-light);
}

.hero-illustration {
    width: 190px;
    height: 190px;
    border-radius: 50%;
    margin-inline-start: auto;
    background: var(--clr-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4.2rem;
    color: #fff;
    box-shadow: 0 24px 48px rgba(46, 111, 144, 0.28);
    transform-style: preserve-3d;
}

.section-title {
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.section-sub {
    color: var(--clr-text-muted);
    font-size: 0.85rem;
    margin-bottom: 18px;
}

.chart-card {
    padding: 22px;
    height: 100%;
}

.chart-wrap {
    position: relative;
    height: 260px;
}

.table-glass {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
}

    .table-glass thead th {
        text-align: start;
        padding: 10px 12px;
        color: var(--clr-text-muted);
        font-weight: 700;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        border-bottom: 1px solid var(--divider);
    }

    .table-glass tbody td {
        padding: 12px;
        border-bottom: 1px solid var(--divider);
        vertical-align: middle;
    }

    .table-glass tbody tr:last-child td {
        border-bottom: none;
    }

.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.78rem;
    flex-shrink: 0;
}
/* Patient-row avatars: a small, flat, restrained rotation so rows are
         easy to tell apart at a glance without turning into a rainbow. */
.avatar-c1 {
    background: var(--clr-primary);
}

.avatar-c2 {
    background: var(--clr-warning);
}

.avatar-c3 {
    background: var(--clr-success);
}

.avatar-c4 {
    background: var(--clr-danger);
}

.avatar-c5 {
    background: var(--clr-accent);
}

.badge-status {
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-stable {
    background: var(--clr-success-bg);
    color: var(--clr-success);
}

.badge-watch {
    background: var(--clr-warning-bg);
    color: var(--clr-warning);
}

.badge-critical {
    background: var(--clr-danger-bg);
    color: var(--clr-danger);
}

.followup-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    transition: background 0.2s;
}

    .followup-item:hover {
        background: color-mix(in srgb, var(--clr-primary) 10%, transparent);
    }

.followup-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.followup-dot-danger {
    background: var(--clr-danger);
}

.followup-dot-warning {
    background: var(--clr-warning);
}

.followup-dot-primary {
    background: var(--clr-primary);
}

.followup-dot-success {
    background: var(--clr-success);
}

/* ============ FORM STYLING FOR NEW PATIENT ============ */
.form-glass-section {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(16px);
}

.form-glass-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--clr-primary);
    border-bottom: 1px solid var(--divider);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-control, .form-select {
    background: var(--input-bg) !important;
    border: 1.5px solid var(--input-border) !important;
    color: var(--clr-text) !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 14px;
    font-size: 0.88rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
    /* A visible resting state — the field reads as "fillable" before
         the person ever clicks into it, not just once it's active. */
    .form-control:hover, .form-select:hover {
        border-color: var(--input-border-hover) !important;
    }

    .form-control:focus, .form-select:focus {
        border-color: var(--clr-primary) !important;
        box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--clr-primary) 25%, transparent) !important;
    }

    .form-control::placeholder {
        color: var(--clr-text-muted);
        opacity: 0.85;
    }
    /* The <option> list is native browser UI and ignores backdrop-filter
         glass styling entirely, so it needs its own solid, opaque colors
         (this is what actually fixes dark-mode dropdown legibility). */
    .form-select option {
        background: var(--bg-body);
        color: var(--clr-text);
    }

.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--clr-text-muted);
    margin-bottom: 6px;
}

/* Persian date picker popup (built by js/persian-date-picker.js).
   Reuses .form-select and .btn-secondary for its controls. */
.hr-jalali-picker {
    position: fixed;
    z-index: 1080;
    box-sizing: border-box;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    padding: 12px;
    direction: rtl;
    font-family: var(--font-fa);
    color: var(--clr-text);
    background: var(--bg-body);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-md);
    box-shadow: var(--glass-shadow);
}

.hr-jp-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.hr-jp-selectors {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 6px;
}

    .hr-jp-selectors .form-select {
        flex: 1 1 0;
        min-width: 0;
        padding: 6px 8px;
        font-family: inherit;
    }

.hr-jp-nav {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
}

.hr-jp-week,
.hr-jp-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

    .hr-jp-week span {
        padding: 4px 0;
        text-align: center;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--clr-text-muted);
    }

        .hr-jp-week span:last-child {
            color: var(--clr-danger);
        }

    .hr-jp-days button {
        min-height: 36px;
        padding: 0;
        font: inherit;
        font-size: 0.88rem;
        color: inherit;
        background: transparent;
        border: 0;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: background-color 0.15s ease;
    }

        .hr-jp-days button:hover:not(:disabled) {
            background: color-mix(in srgb, var(--clr-primary) 18%, transparent);
        }

        .hr-jp-days button:focus-visible {
            outline: 2px solid var(--clr-primary);
            outline-offset: 1px;
        }

        .hr-jp-days > :nth-child(7n),
        .hr-jp-days button.holiday {
            color: var(--clr-danger);
        }

        .hr-jp-days button.official-holiday {
            font-weight: 700;
        }

        .hr-jp-days button.today {
            box-shadow: inset 0 0 0 1.5px var(--clr-primary);
        }

        .hr-jp-days button.selected {
            color: #fff;
            font-weight: 700;
            background: var(--clr-primary);
        }

        /* Days that cannot be chosen (e.g. after today on the follow-up page). */
        .hr-jp-days button:disabled {
            opacity: 0.35;
            cursor: not-allowed;
        }

.hr-jp-foot {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

    .hr-jp-foot .btn {
        flex: 1 1 0;
    }

@media (max-width: 575.98px) {
    .hr-jalali-picker {
        padding: 10px;
    }

    .hr-jp-nav {
        width: 40px;
        height: 40px;
    }

    .hr-jp-selectors .form-select {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .hr-jp-days button {
        min-height: 40px;
    }

    .hr-jp-foot .btn {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* ============ BUTTONS (shared family) ============
   Reusable everywhere: .btn + .btn-primary (solid) | .btn-accent (solid, accent color) |
   .btn-soft (tinted) | .btn-secondary (neutral outline) | .btn-success | .btn-danger,
   optional .btn-sm. Flat, theme-aware. */
.btn {
    --bs-btn-padding-x: 1.1rem;
    --bs-btn-padding-y: 0.55rem;
    --bs-btn-font-family: inherit;
    --bs-btn-font-size: 0.85rem;
    --bs-btn-font-weight: 600;
    --bs-btn-line-height: 1.4;
    --bs-btn-border-width: 1.5px;
    --bs-btn-border-radius: var(--radius-sm);
    min-height: 41px; /* same height as .form-control */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

    .btn:hover {
        transform: translateY(-1px);
    }

    .btn:active {
        transform: translateY(0);
    }

    .btn i {
        font-size: 1em;
        line-height: 1;
    }

/* New Patient actions: use the existing button family without changing
       button styling on any other page. */
#page-new-patient .btn {
    min-height: 42px;
    padding-inline: 1.15rem;
    border-radius: 12px;
    font-weight: 650;
    box-shadow: 0 4px 12px rgba(50, 90, 130, 0.08);
}

    #page-new-patient .btn:hover {
        box-shadow: 0 7px 16px rgba(50, 90, 130, 0.14);
    }

    #page-new-patient .btn:focus-visible {
        box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--clr-primary) 22%, transparent), 0 4px 12px rgba(50, 90, 130, 0.08);
    }

#page-new-patient .btn-soft {
    background: color-mix(in srgb, var(--clr-primary) 9%, var(--glass-bg)) !important;
    border-color: color-mix(in srgb, var(--clr-primary) 28%, var(--glass-border)) !important;
}

    #page-new-patient .btn-soft:hover {
        background: var(--clr-primary) !important;
        border-color: var(--clr-primary) !important;
        color: #fff !important;
    }

#page-new-patient .btn-success {
    min-width: 42px;
    padding-inline: 0.8rem;
}

#page-new-patient .btn-secondary {
    background: transparent;
    border-color: color-mix(in srgb, var(--clr-primary) 35%, transparent);
    color: var(--clr-primary);
}

    #page-new-patient .btn-secondary:hover {
        background: var(--clr-primary);
        border-color: var(--clr-primary);
        color: #fff;
    }

#page-new-patient .btn-primary,
#page-new-patient .btn-accent {
    box-shadow: 0 5px 14px rgba(50, 90, 130, 0.16);
}

#page-new-patient .btn-accent {
    background: var(--clr-primary);
    border-color: var(--clr-primary);
    color: #fff;
}

    #page-new-patient .btn-accent:hover {
        background: color-mix(in srgb, var(--clr-primary) 9%, var(--glass-bg));
        border-color: color-mix(in srgb, var(--clr-primary) 28%, var(--glass-border));
        color: var(--clr-primary);
    }

@media (max-width: 575.98px) {
    #page-new-patient .d-flex.justify-content-end.gap-2.mb-5 {
        display: grid !important;
        grid-template-columns: 1fr;
    }

        #page-new-patient .d-flex.justify-content-end.gap-2.mb-5 .btn {
            width: 100%;
        }

    #page-new-patient .btn-success {
        min-width: 42px;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    #page-new-patient .d-flex.justify-content-end.gap-2.mb-5 .btn {
        flex: 1 1 150px;
    }
}

.btn-sm {
    --bs-btn-padding-x: 0.75rem;
    --bs-btn-padding-y: 0.35rem;
    --bs-btn-font-size: 0.78rem;
    --bs-btn-border-radius: 8px;
    min-height: 0;
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--clr-primary);
    --bs-btn-border-color: var(--clr-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: color-mix(in srgb, var(--clr-primary) 86%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--clr-primary) 86%, #000);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: color-mix(in srgb, var(--clr-primary) 78%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--clr-primary) 78%, #000);
    --bs-btn-focus-shadow-rgb: 128, 128, 128;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--clr-primary);
    --bs-btn-disabled-border-color: var(--clr-primary);
}

.btn-secondary {
    --bs-btn-color: var(--clr-text);
    --bs-btn-bg: var(--input-bg);
    --bs-btn-border-color: var(--input-border);
    --bs-btn-hover-color: var(--clr-primary);
    --bs-btn-hover-bg: var(--clr-primary-light);
    --bs-btn-hover-border-color: var(--clr-primary);
    --bs-btn-active-color: var(--clr-primary);
    --bs-btn-active-bg: var(--clr-primary-light);
    --bs-btn-active-border-color: var(--clr-primary);
    --bs-btn-focus-shadow-rgb: 128, 128, 128;
    --bs-btn-disabled-color: var(--clr-text-muted);
    --bs-btn-disabled-bg: var(--input-bg);
    --bs-btn-disabled-border-color: var(--input-border);
}

.btn-soft {
    --bs-btn-color: var(--clr-primary);
    --bs-btn-bg: color-mix(in srgb, var(--clr-primary) 12%, transparent);
    --bs-btn-border-color: color-mix(in srgb, var(--clr-primary) 35%, transparent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--clr-primary);
    --bs-btn-hover-border-color: var(--clr-primary);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: color-mix(in srgb, var(--clr-primary) 86%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--clr-primary) 86%, #000);
    --bs-btn-focus-shadow-rgb: 128, 128, 128;
    --bs-btn-disabled-color: var(--clr-primary);
    --bs-btn-disabled-bg: color-mix(in srgb, var(--clr-primary) 12%, transparent);
    --bs-btn-disabled-border-color: color-mix(in srgb, var(--clr-primary) 35%, transparent);
}

.btn-accent {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--clr-accent);
    --bs-btn-border-color: var(--clr-accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: color-mix(in srgb, var(--clr-accent) 86%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--clr-accent) 86%, #000);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: color-mix(in srgb, var(--clr-accent) 78%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--clr-accent) 78%, #000);
    --bs-btn-focus-shadow-rgb: 128, 128, 128;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--clr-accent);
    --bs-btn-disabled-border-color: var(--clr-accent);
}

.btn-success {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--clr-success);
    --bs-btn-border-color: var(--clr-success);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: color-mix(in srgb, var(--clr-success) 86%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--clr-success) 86%, #000);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: color-mix(in srgb, var(--clr-success) 78%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--clr-success) 78%, #000);
    --bs-btn-focus-shadow-rgb: 128, 128, 128;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--clr-success);
    --bs-btn-disabled-border-color: var(--clr-success);
}

.btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--clr-danger);
    --bs-btn-border-color: var(--clr-danger);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: color-mix(in srgb, var(--clr-danger) 86%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--clr-danger) 86%, #000);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: color-mix(in srgb, var(--clr-danger) 78%, #000);
    --bs-btn-active-border-color: color-mix(in srgb, var(--clr-danger) 78%, #000);
    --bs-btn-focus-shadow-rgb: 128, 128, 128;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--clr-danger);
    --bs-btn-disabled-border-color: var(--clr-danger);
}

.btn:focus-visible {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--clr-primary) 28%, transparent);
}

/* ============ AUTH PAGES (Login / Register / Registration status) ============
   Same flat, glass look as the dashboard. Reuses .glass, .kpi-icon, .form-control/.form-select,
   .form-label, .form-glass-title, .btn-* and Bootstrap alerts, so only the page frame lives here.
   Below 992px the brand panel is replaced by a compact header above the form. */
.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.auth-main {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 24px 16px;
    overflow: hidden;
}

    /* Soft flat shapes behind the glass card (the blur needs something to show). */
    .auth-main::before,
    .auth-main::after {
        content: "";
        position: absolute;
        border-radius: 50%;
        pointer-events: none;
    }

    .auth-main::before {
        width: 360px;
        height: 360px;
        top: -120px;
        inset-inline-end: -100px;
        background: color-mix(in srgb, var(--clr-primary) 14%, transparent);
    }

    .auth-main::after {
        width: 280px;
        height: 280px;
        bottom: -90px;
        inset-inline-start: -80px;
        background: color-mix(in srgb, var(--clr-accent) 16%, transparent);
    }

    .auth-main > * {
        position: relative;
        z-index: 1;
    }

.auth-mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--clr-text);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 28px 20px;
}

.auth-card-wide {
    max-width: 680px;
}

.auth-footnote {
    margin: 0;
    font-size: 0.78rem;
    color: var(--clr-text-muted);
}

/* ---- Brand panel (large screens) ---- */
.auth-brand {
    display: none;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
    padding: 48px;
    overflow: hidden;
    color: #fff;
    background: var(--clr-primary);
}

    .auth-brand::before,
    .auth-brand::after {
        content: "";
        position: absolute;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.08);
        pointer-events: none;
    }

    .auth-brand::before {
        width: 420px;
        height: 420px;
        bottom: -160px;
        inset-inline-start: -140px;
    }

    .auth-brand::after {
        width: 220px;
        height: 220px;
        top: -70px;
        inset-inline-end: -60px;
    }

    .auth-brand > * {
        position: relative;
        z-index: 1;
    }

    .auth-brand .kpi-icon {
        background: rgba(255, 255, 255, 0.18);
        box-shadow: none;
    }

.auth-brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: #fff;
}

    .auth-brand-logo:hover {
        color: #fff;
    }

.auth-brand-muted {
    color: rgba(255, 255, 255, 0.82);
}

.auth-brand-title {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.5;
    margin-bottom: 14px;
}

.auth-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 14px;
}

    .auth-features li {
        display: flex;
        align-items: center;
        gap: 12px;
        font-weight: 500;
    }

    .auth-features i {
        flex: 0 0 auto;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.16);
    }

/* ---- Fields: icon inside the input ---- */
.auth-field {
    position: relative;
}

    .auth-field .form-control,
    .auth-field .form-select {
        padding-inline-start: 2.7rem;
    }

    .auth-field .form-select {
        appearance: none;
        -webkit-appearance: none;
        padding-inline-end: 2.4rem;
    }

    .auth-field.has-action .form-control {
        padding-inline-end: 2.8rem;
    }

.auth-field-icon,
.auth-field-end {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--clr-text-muted);
    pointer-events: none;
    transition: color 0.15s ease;
}

.auth-field-icon {
    inset-inline-start: 14px;
    font-size: 1.05rem;
}

.auth-field-end {
    inset-inline-end: 14px;
    font-size: 0.85rem;
}

.auth-field:focus-within .auth-field-icon {
    color: var(--clr-primary);
}

.auth-field-action {
    position: absolute;
    top: 50%;
    inset-inline-end: 6px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--clr-text-muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

    .auth-field-action:hover {
        color: var(--clr-primary);
        background: color-mix(in srgb, var(--clr-primary) 12%, transparent);
    }

    .auth-field-action:focus-visible {
        outline: 2px solid var(--clr-primary);
        outline-offset: 1px;
    }

/* ---- "or" divider, registration steps, status summary ---- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 14px;
    font-size: 0.8rem;
    color: var(--clr-text-muted);
}

    .auth-divider::before,
    .auth-divider::after {
        content: "";
        flex: 1 1 0;
        height: 1px;
        background: var(--divider);
    }

.auth-steps {
    list-style: none;
    margin: 0 0 22px;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

    .auth-steps li {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        text-align: center;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--clr-text-muted);
    }

    .auth-steps span {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.8rem;
        border-radius: 50%;
        border: 1.5px solid var(--input-border);
        background: var(--input-bg);
    }

    .auth-steps li.is-active {
        color: var(--clr-primary);
    }

        .auth-steps li.is-active span {
            color: #fff;
            border-color: var(--clr-primary);
            background: var(--clr-primary);
        }

.auth-summary {
    margin: 0 0 20px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    background: var(--glass-bg);
}

    .auth-summary > div {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 4px 16px;
        padding: 12px 16px;
    }

        .auth-summary > div + div {
            border-top: 1px solid var(--divider);
        }

    .auth-summary dt {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0;
        font-size: 0.82rem;
        font-weight: 600;
        color: var(--clr-text-muted);
    }

    .auth-summary dd {
        margin: 0;
        font-weight: 600;
        overflow-wrap: anywhere;
    }

@media (min-width: 576px) {
    .auth-main {
        padding: 32px 24px;
    }

    .auth-card {
        padding: 36px;
    }
}

@media (min-width: 992px) {
    .auth-shell {
        grid-template-columns: minmax(380px, 5fr) 7fr;
    }

    .auth-brand {
        display: flex;
    }

    .auth-mobile-brand {
        display: none;
    }
}

@media (max-width: 575.98px) {
    /* 16px stops iOS from zooming into the field. */
    .auth-field .form-control,
    .auth-field .form-select {
        font-size: 16px;
    }
}

/* ============ PATIENT FOLLOW-UP (Patient > Follow ups before surgery) ============
   Form on the left, visit-history tree on the right (sticky on desktop).
   Reuses .glass, .form-glass-section/.form-glass-title, .btn-* and .selected-drug.
   Below 1200px the tree moves above the form and opens with a toggle button. */
.followup-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 24px;
    align-items: start;
}

.followup-main {
    min-width: 0;
}

.followup-aside {
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
    max-height: calc(100vh - var(--topbar-h) - 32px);
    overflow-y: auto;
}

.followup-aside-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    text-align: start;
}

.followup-aside-body {
    padding: 18px;
}

.followup-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

.followup-node {
    position: relative;
    padding-inline-start: 26px;
    padding-bottom: 6px;
}

    /* The vertical line that joins the dates. */
    .followup-node::before {
        content: "";
        position: absolute;
        inset-inline-start: 7px;
        top: 0;
        bottom: 0;
        width: 2px;
        background: var(--divider);
    }

    .followup-node:first-child::before {
        top: 22px;
    }

    .followup-node:last-child::before {
        bottom: auto;
        height: 22px;
    }

    .followup-node:only-child::before {
        display: none;
    }

.followup-dot {
    position: absolute;
    inset-inline-start: 0;
    top: 14px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-body);
    border: 3px solid var(--clr-primary);
    z-index: 1;
}

.followup-node.is-done .followup-dot {
    background: var(--clr-success);
    border-color: var(--clr-success);
}

.followup-node.is-active .followup-dot {
    background: var(--clr-primary);
    border-color: var(--clr-primary);
}

.followup-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--clr-text);
    transition: background 0.15s ease, border-color 0.15s ease;
}

a.followup-link:hover {
    color: var(--clr-text);
    background: color-mix(in srgb, var(--clr-primary) 10%, transparent);
}

.followup-node.is-active > .followup-link {
    background: color-mix(in srgb, var(--clr-primary) 12%, transparent);
    border-color: color-mix(in srgb, var(--clr-primary) 35%, transparent);
}

.followup-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.followup-date {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.followup-edit {
    flex: 0 0 auto;
    font-size: 0.8rem;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

a.followup-link:hover .followup-edit {
    opacity: 1;
}

/* "Add Extra" box under the tree of Follow ups after surgery. */
.followup-extra {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--divider);
}

@media (max-width: 1199.98px) {
    .followup-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .followup-aside {
        position: static;
        max-height: none;
        overflow: visible;
        order: -1;
    }

    .followup-aside-toggle {
        display: flex;
    }

    .followup-aside-body {
        display: none;
        margin-top: 8px;
        max-height: 50vh;
        overflow-y: auto;
    }

        .followup-aside-body.is-open {
            display: block;
        }
}

@media (max-width: 575.98px) {
    .followup-aside-body {
        padding: 14px;
    }
}

/* ============ PATIENT LAB CHARTS (Patient > Examinations > Lab Charts) ============
   Reuses .glass, .kpi-card, .chart-card, .form-glass-section, .table-glass and .selected-drug.
   Only what those classes do not cover is defined here: chart height, trend cards with
   sparklines, and the report table (sticky first column, horizontal scroll on small screens). */
.lab-chart-wrap {
    position: relative;
    height: 320px;
}

    .lab-chart-wrap canvas {
        max-width: 100%;
    }

/* Trend card = a <button>, so the browser look is reset and the glass look is kept. */
.lab-trend-card {
    display: block;
    font: inherit;
    color: var(--clr-text);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

    .lab-trend-card:hover {
        border-color: color-mix(in srgb, var(--clr-primary) 45%, transparent);
        background: color-mix(in srgb, var(--clr-primary) 7%, var(--glass-bg));
    }

    .lab-trend-card.is-active {
        border-color: var(--clr-primary);
        box-shadow: 0 0 0 2px color-mix(in srgb, var(--clr-primary) 25%, transparent);
    }

    .lab-trend-card:focus-visible {
        outline: none;
        box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--clr-primary) 28%, transparent);
    }

/* Sparkline: the svg is stretched to the card width, so strokes do not scale. */
.lab-spark {
    display: block;
    width: 100%;
    height: 44px;
    margin: 10px 0 6px;
}

.lab-spark-line {
    fill: none;
    stroke: var(--clr-primary);
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.lab-spark-dot {
    fill: none;
    stroke: var(--clr-primary);
    stroke-width: 6;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.lab-spark-dot-last {
    stroke: var(--clr-accent);
    stroke-width: 10;
}

/* Report table */
.lab-table-wrap {
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
}

.lab-table {
    width: 100%;
    min-width: max-content;
}

    .lab-table thead th:first-child,
    .lab-table tbody th[scope="row"] {
        position: sticky;
        inset-inline-start: 0;
        z-index: 1;
        min-width: 150px;
        max-width: 220px;
        padding: 12px;
        background: var(--bg-body);
        border-bottom: 1px solid var(--divider);
        border-inline-end: 1px solid var(--divider);
        text-align: start;
    }

    .lab-table tbody td {
        text-align: center;
    }

    .lab-table thead th:not(:first-child) {
        text-align: center;
    }

    .lab-table tbody tr:hover td,
    .lab-table tbody tr:hover th[scope="row"] {
        background: color-mix(in srgb, var(--clr-primary) 7%, var(--bg-body));
    }

.lab-table-group th {
    padding: 8px 12px;
    text-align: start;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--clr-primary);
    background: color-mix(in srgb, var(--clr-primary) 10%, var(--bg-body));
    border-bottom: 1px solid var(--divider);
}

/* Tablet and desktop: taller chart */
@media (min-width: 768px) {
    .lab-chart-wrap {
        height: 380px;
    }
}

@media (min-width: 1200px) {
    .lab-chart-wrap {
        height: 440px;
    }
}

/* Phone: shorter chart, narrower first column */
@media (max-width: 575.98px) {
    .lab-chart-wrap {
        height: 280px;
    }

    .lab-table thead th:first-child,
    .lab-table tbody th[scope="row"] {
        min-width: 110px;
        max-width: 140px;
        padding: 10px 8px;
    }
}

/* Print: only the report is printed (no menu, no shadows). */
@media print {
    .sidebar,
    .topbar,
    .sidebar-backdrop {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
    }

    .glass,
    .form-glass-section {
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .lab-table-wrap {
        overflow: visible !important;
    }

    .lab-table {
        min-width: 0;
    }

        .lab-table thead th:first-child,
        .lab-table tbody th[scope="row"] {
            position: static;
        }
}

/* ============ PATIENT MEGA MENU (Patient > Details) ============
   Trigger = .btn.btn-soft (button family above); panel is a rectangular,
   multi-column sheet anchored to the page header, so it always follows
   the page width. Group titles reuse .form-glass-title. Flat, theme-aware. */
.patient-page-header {
    position: relative;
    z-index: 20; /* keep the open panel above the glass cards below */
}

.patient-mega-toggle[aria-expanded="true"] {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--clr-primary);
    --bs-btn-border-color: var(--clr-primary);
}

.patient-mega-chev {
    font-size: 0.75em;
    transition: transform 0.25s ease;
}

.patient-mega-toggle[aria-expanded="true"] .patient-mega-chev {
    transform: rotate(180deg);
}

.patient-mega-panel {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline: 0;
    padding: 18px;
    background: var(--bg-body);
    border: 1px solid color-mix(in srgb, var(--clr-primary) 25%, transparent);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow), 0 18px 48px rgba(28, 43, 58, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

    .patient-mega-panel.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
    }

.patient-mega-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--divider);
}

    .patient-mega-head i {
        color: var(--clr-primary);
    }

.patient-mega-close {
    flex: 0 0 auto;
}

.patient-mega-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.patient-mega-group {
    min-width: 0;
    padding: 14px;
    background: var(--glass-bg);
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
}

    .patient-mega-group .form-glass-title {
        margin-bottom: 8px;
        font-size: 0.92rem;
    }

.patient-mega-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.patient-mega-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--clr-text);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
    transition: background 0.2s ease, color 0.2s ease;
}

    .patient-mega-link i {
        flex: 0 0 auto;
        width: 20px;
        text-align: center;
        color: var(--clr-accent);
        transition: color 0.2s ease;
    }

    .patient-mega-link:hover,
    .patient-mega-link:focus-visible {
        background: color-mix(in srgb, var(--clr-primary) 14%, transparent);
        color: var(--clr-primary);
    }

    .patient-mega-link:focus-visible {
        outline: none;
        box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--clr-primary) 28%, transparent);
    }

/* Tablet: 2 columns */
@media (min-width: 576px) {
    .patient-mega-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Small desktop / large tablet: 3 columns */
@media (min-width: 992px) {
    .patient-mega-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Wide desktop: 4 columns */
@media (min-width: 1400px) {
    .patient-mega-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Mobile: full-width sheet, bigger touch targets */
@media (max-width: 575.98px) {
    .patient-mega-panel {
        padding: 12px;
        border-radius: var(--radius-md);
    }

    .patient-mega-group {
        padding: 10px;
    }

    .patient-mega-link {
        padding: 11px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .patient-mega-panel,
    .patient-mega-panel.show,
    .patient-mega-chev {
        transition: none;
    }
}

/* ---- Checkbox groups ---- */
/* Only the checkbox square itself gets a visible resting border —
         wrapping the whole label in a bordered "chip" made it look like
         a text field and merged visually with the inputs above it. */
.form-check {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 10px;
    padding: 0;
    margin-left: 20px;
}

.form-check-input {
    width: 17px;
    height: 17px;
    margin-top: 0;
    flex-shrink: 0;
    cursor: pointer;
    background-color: var(--input-bg);
    border: 2px solid var(--checkbox-border);
}

    .form-check-input:hover {
        border-color: var(--clr-primary);
    }

    .form-check-input:checked {
        background-color: var(--clr-primary);
        border-color: var(--clr-primary);
    }

    .form-check-input:focus {
        border-color: var(--clr-primary);
        box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--clr-primary) 25%, transparent);
    }

.form-check-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--clr-text);
    cursor: pointer;
}

.placeholder-page {
    padding: 60px 30px;
    text-align: center;
    display: none;
}

    .placeholder-page i {
        font-size: 3.4rem;
        color: var(--clr-primary);
        margin-bottom: 18px;
        display: block;
    }

.page-view {
    display: none;
}

    .page-view.active {
        display: block;
    }

/* ============ OFFCANVAS SETTINGS ============ */
/* Theme swatches: one solid, flat primary color per theme (never a
         gradient) with a single small accent dot in the corner — enough to
         preview the pairing without turning the picker into visual noise. */
.theme-swatch {
    width: 100%;
    aspect-ratio: 1.3/1;
    border-radius: 14px;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
}

    .theme-swatch:hover {
        transform: translateY(-3px);
    }

    .theme-swatch.active {
        border-color: var(--clr-text);
    }

        .theme-swatch.active::after {
            content: "\F26E";
            font-family: "bootstrap-icons";
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 1.1rem;
            text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
        }

.swatch-accent-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    bottom: 6px;
    inset-inline-end: 6px;
    border: 2px solid rgba(255, 255, 255, 0.85);
}

.swatch-label {
    font-size: 0.68rem;
    text-align: center;
    margin-top: 6px;
    color: var(--clr-text-muted);
    font-weight: 600;
}

.mode-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    border-radius: 14px;
    background: var(--glass-bg);
    margin-bottom: 22px;
}

.form-switch .form-check-input {
    width: 2.6em;
    height: 1.4em;
    cursor: pointer;
}

.offcanvas {
    --bs-offcanvas-width: 340px;
    background: var(--glass-bg-strong) !important;
    backdrop-filter: blur(24px);
    color: var(--clr-text);
    border: none !important;
}

[dir="rtl"] .offcanvas-end {
    inset-inline-start: 0;
    inset-inline-end: auto;
}

.fade-in {
    animation: fadeIn 0.45s ease both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 575.98px) {
    .kpi-value {
        font-size: 1.5rem;
    }

    .hero-illustration {
        display: none;
    }

    .hero-banner {
        padding: 24px;
    }
}


.dynamic-panel {
    padding: 12px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(255,255,255,.04)
}

.dynamic-panel-title {
    font-weight: 700;
    margin-bottom: 8px
}

.drug-history-box {
    border: 1px solid var(--glass-border);
    padding: 14px;
    border-radius: 10px;
    min-width: 0;
}

.selected-drugs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.selected-drug {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    background: rgba(255,255,255,.06);
    overflow-wrap: anywhere;
}

    .selected-drug button {
        flex: 0 0 auto;
        border: 0;
        padding: 0 2px;
        color: inherit;
        background: transparent;
        font-size: 1.25rem;
        line-height: 1;
        cursor: pointer;
    }

@media (max-width: 575.98px) {
    .drug-history-box {
        padding: 10px;
    }

    .selected-drug {
        max-width: 100%;
    }
}
/* Hierarchical Back Office comorbidity options */
.patient-comorbidity-grid {
    align-items: stretch;
}

    .patient-comorbidity-grid > [class*="col-"] {
        min-width: 0;
        display: flex;
    }

.patient-comorbidity-card {
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    overflow-wrap: anywhere;
}

/* Only diseases that have sub-options receive an outer dashed frame. */
.patient-comorbidity-card-has-options {
    padding: 12px;
    border: 1px dashed rgba(150, 150, 150, 0.65);
    background: rgba(255, 255, 255, 0.025);
}

.patient-comorbidity-card > .form-check {
    margin: 0;
    /* Keep the checkbox and disease name fully inside the parent dashed frame. */
    padding: 3px 5px 3px 1.75em;
    min-width: 0;
    overflow-wrap: anywhere;
}

    .patient-comorbidity-card > .form-check .form-check-input {
        margin-left: -1.5em;
        position: relative;
    }

    .patient-comorbidity-card > .form-check .form-check-label {
        white-space: normal;
        overflow-wrap: anywhere;
    }

.patient-comorbidity-options {
    min-width: 0;
    margin-top: 8px;
    padding: 0;
    border: 0;
    border-radius: 0;
}

.patient-option-node {
    min-width: 0;
    box-sizing: border-box;
}

/* A dashed frame belongs only to a node that has children. */
.patient-option-has-children {
    margin-top: 8px;
    padding: 10px;
    border: 1px dashed rgba(150, 150, 150, 0.6);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.025);
}

.patient-option-node > .patient-option-check {
    margin: 0;
    min-width: 0;
    /* The checkbox's Bootstrap negative margin is compensated by left padding. */
    padding: 3px 5px 3px 1.9em;
    overflow-wrap: anywhere;
}

.patient-option-check .form-check-input {
    margin-left: -1.5em;
}

.patient-option-check .form-check-label {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.patient-option-children {
    min-width: 0;
    margin: 9px 0 0 8px;
    padding: 9px 0 0 10px;
    border-left: 1px dashed rgba(150, 150, 150, 0.5);
}

    .patient-option-children > .patient-option-node + .patient-option-node {
        margin-top: 8px;
    }

.patient-option-other {
    min-width: 0;
    max-width: 100%;
    padding: 0 5px 4px;
}

    .patient-option-other .form-control {
        width: 100%;
        min-width: 0;
    }

@media (max-width: 767.98px) {
    .patient-comorbidity-card-has-options {
        padding: 9px;
    }

    .patient-comorbidity-card > .form-check {
        padding-left: 1.75em;
    }

    .patient-option-has-children {
        padding: 8px;
    }

    .patient-option-children {
        margin-left: 3px;
        padding-left: 7px;
    }

    .patient-option-node > .patient-option-check {
        padding-right: 2px;
        padding-left: 1.9em;
    }
}

/* Dashed border for Dyslipidemia Type and its options */
/* ================================
       Dyslipidemia - Dashed Design
       ================================ */

/* فقط یک کادر نقطه چین دور کل Dyslipidemia */
.comorbidity-grid > #DyslipidemiaOptions {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px dashed rgba(150, 150, 150, 0.65) !important;
    border-radius: 10px !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    background: transparent !important;
}

    .comorbidity-grid > #DyslipidemiaOptions .form-check {
        border: none !important;
        background: transparent !important;
        padding: 6px 12px !important;
        margin: 0 !important;
    }

    .comorbidity-grid > #DyslipidemiaOptions .dynamic-panel-title {
        border: none !important;
        margin-bottom: 8px;
        padding: 0;
    }

#DyslipidemiaOptions .row.g-2 {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
}

    #DyslipidemiaOptions .row.g-2 > div {
        flex: 0 0 auto;
        width: auto !important;
    }

#DyslipidemiaOptions .form-check {
    padding: 4px 8px !important;
    margin: 0 !important;
}

/* فقط یک کادر نقطه چین دور کل Thyroid Disease */
.comorbidity-grid > #ThyroidOptions {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px dashed rgba(150, 150, 150, 0.65) !important;
    border-radius: 10px !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    background: transparent !important;
}

    /* گزینه‌های داخل کادر بدون کادر */
    .comorbidity-grid > #ThyroidOptions .form-check {
        border: none !important;
        background: transparent !important;
        padding: 6px 12px !important;
        margin: 0 !important;
    }

    /* عنوان Thyroid Disease Type */
    .comorbidity-grid > #ThyroidOptions .dynamic-panel-title {
        border: none !important;
        margin-bottom: 8px;
        padding: 0;
    }

/* نزدیک کردن Hypothyroidism و Hyperthyroidism */
#ThyroidOptions .row.g-2 {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
}

    /* جلوگیری از نصف شدن عرض ستون‌ها */
    #ThyroidOptions .row.g-2 > div {
        flex: 0 0 auto;
        width: auto !important;
    }

/* فاصله داخلی گزینه‌ها */
#ThyroidOptions .form-check {
    padding: 4px 8px !important;
}

/* =========================================
       Liver Disease - Dashed Design
       ========================================= */

/* کادر نقطه چین دور کل Liver Disease Details */
.comorbidity-grid > #LiverDiseaseOptions {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px dashed rgba(150, 150, 150, 0.65) !important;
    border-radius: 10px !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    background: transparent !important;
}

    /* عنوان Liver Disease Details */
    .comorbidity-grid > #LiverDiseaseOptions .dynamic-panel-title {
        border: none !important;
        margin-bottom: 8px;
        padding: 0;
    }

    /* تمام فرم‌چک‌های داخل Liver بدون کادر */
    .comorbidity-grid > #LiverDiseaseOptions .form-check {
        border: none !important;
        background: transparent !important;
        padding: 4px 8px !important;
        margin: 0 !important;
    }

/* Other و Liver Disease Type در بخش اصلی */
#LiverDiseaseOptions > .row.g-3 > .col-12.col-md-6 {
    padding-left: 8px;
    padding-right: 8px;
}

/* نزدیک کردن NAFL و NASH */
#LiverDiseaseOptions .row.g-2 {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
}

    #LiverDiseaseOptions .row.g-2 > div {
        flex: 0 0 auto;
        width: auto !important;
    }

/* NAFL Grade */
#LiverDiseaseOptions #NAFLGradeOptions {
    margin-top: 10px !important;
}

    /* نزدیک کردن Grade ها */
    #LiverDiseaseOptions #NAFLGradeOptions .row.g-2 {
        display: flex;
        flex-wrap: nowrap;
        gap: 12px;
    }

        #LiverDiseaseOptions #NAFLGradeOptions .row.g-2 > div {
            flex: 0 0 auto;
            width: auto !important;
        }

/* =========================================
       Hernia - Dashed Design
       ========================================= */

/* کادر نقطه چین دور کل Hernia Type */
.comorbidity-grid > #HerniaOptions {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px dashed rgba(150, 150, 150, 0.65) !important;
    border-radius: 10px !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    background: transparent !important;
}

    /* عنوان Hernia Type */
    .comorbidity-grid > #HerniaOptions .dynamic-panel-title {
        border: none !important;
        margin-bottom: 8px;
        padding: 0;
    }

    /* گزینه‌های Hernia بدون کادر */
    .comorbidity-grid > #HerniaOptions .form-check {
        border: none !important;
        background: transparent !important;
        padding: 4px 8px !important;
        margin: 0 !important;
    }

/* نزدیک کردن گزینه‌های Hernia */
#HerniaOptions .row.g-2 {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
}

    #HerniaOptions .row.g-2 > div {
        flex: 0 0 auto;
        width: auto !important;
    }

/* بخش Other Hernia Description */
#HerniaOptions #HerniaOtherText {
    margin-top: 10px !important;
}

    #HerniaOptions #HerniaOtherText .form-control {
        margin-top: 4px;
    }

/* =========================================
       Collagen Vascular Disease - Dashed Design
       ========================================= */

/* کادر نقطه چین دور کل Collagen Vascular Disease Type */
.comorbidity-grid > #CollagenVascularOptions {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px dashed rgba(150, 150, 150, 0.65) !important;
    border-radius: 10px !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    background: transparent !important;
}

    /* عنوان Collagen Vascular Disease Type */
    .comorbidity-grid > #CollagenVascularOptions .dynamic-panel-title {
        border: none !important;
        margin-bottom: 8px;
        padding: 0;
    }

    /* گزینه‌های RA / SLE / VASCULITIS / Others بدون کادر */
    .comorbidity-grid > #CollagenVascularOptions .form-check {
        border: none !important;
        background: transparent !important;
        padding: 4px 8px !important;
        margin: 0 !important;
    }

/* نزدیک کردن گزینه‌ها */
#CollagenVascularOptions .row.g-2 {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
}

    #CollagenVascularOptions .row.g-2 > div {
        flex: 0 0 auto;
        width: auto !important;
    }

/* بخش Other Collagen Vascular Disease */
#CollagenVascularOptions #CollagenOthersText {
    margin-top: 10px !important;
}

    #CollagenVascularOptions #CollagenOthersText .form-control {
        margin-top: 4px;
    }

/* =========================================
       Responsive Dynamic Panels
       ========================================= */

/* Tablet */
@media (max-width: 991.98px) {
    /* همه پنل‌های نقطه‌چین */
    .comorbidity-grid > #DyslipidemiaOptions, .comorbidity-grid > #ThyroidOptions, .comorbidity-grid > #LiverDiseaseOptions, .comorbidity-grid > #HerniaOptions, .comorbidity-grid > #CollagenVascularOptions {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden;
    }
    /* اجازه رفتن گزینه‌ها به خط بعد */
    #DyslipidemiaOptions .row.g-2,
    #ThyroidOptions .row.g-2,
    #LiverDiseaseOptions .row.g-2,
    #HerniaOptions .row.g-2,
    #CollagenVascularOptions .row.g-2 {
        display: flex;
        flex-wrap: wrap !important;
        gap: 4px 12px !important;
        width: 100%;
        margin: 0 !important;
    }
        /* ستون‌ها دیگر نصف عرض اجباری نداشته باشند */
        #DyslipidemiaOptions .row.g-2 > div,
        #ThyroidOptions .row.g-2 > div,
        #LiverDiseaseOptions .row.g-2 > div,
        #HerniaOptions .row.g-2 > div,
        #CollagenVascularOptions .row.g-2 > div {
            flex: 0 1 auto !important;
            width: auto !important;
            max-width: 100% !important;
        }
    /* متن گزینه‌ها اجازه شکستن داشته باشد */
    #DyslipidemiaOptions .form-check-label,
    #ThyroidOptions .form-check-label,
    #LiverDiseaseOptions .form-check-label,
    #HerniaOptions .form-check-label,
    #CollagenVascularOptions .form-check-label {
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }
}


/* Mobile */
@media (max-width: 575.98px) {
    /* کادر نقطه چین */
    .comorbidity-grid > #DyslipidemiaOptions, .comorbidity-grid > #ThyroidOptions, .comorbidity-grid > #LiverDiseaseOptions, .comorbidity-grid > #HerniaOptions, .comorbidity-grid > #CollagenVascularOptions {
        padding: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }
    /* گزینه‌ها در موبایل */
    #DyslipidemiaOptions .row.g-2,
    #ThyroidOptions .row.g-2,
    #LiverDiseaseOptions .row.g-2,
    #HerniaOptions .row.g-2,
    #CollagenVascularOptions .row.g-2 {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap !important;
        gap: 2px !important;
    }

        #DyslipidemiaOptions .row.g-2 > div,
        #ThyroidOptions .row.g-2 > div,
        #LiverDiseaseOptions .row.g-2 > div,
        #HerniaOptions .row.g-2 > div,
        #CollagenVascularOptions .row.g-2 > div {
            width: 100% !important;
            max-width: 100% !important;
            flex: 0 0 auto !important;
        }
    /* گزینه‌ها تمام عرض باشند */
    #DyslipidemiaOptions .form-check,
    #ThyroidOptions .form-check,
    #LiverDiseaseOptions .form-check,
    #HerniaOptions .form-check,
    #CollagenVascularOptions .form-check {
        width: 100%;
        box-sizing: border-box;
        padding: 4px 6px !important;
    }
    /* متن‌ها از کادر بیرون نزنند */
    #DyslipidemiaOptions .form-check-label,
    #ThyroidOptions .form-check-label,
    #LiverDiseaseOptions .form-check-label,
    #HerniaOptions .form-check-label,
    #CollagenVascularOptions .form-check-label {
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    /* فیلد Other در موبایل */
    #LiverDiseaseOptions #NAFLGradeOptions,
    #HerniaOptions #HerniaOtherText,
    #CollagenVascularOptions #CollagenOthersText {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    #LiverDiseaseOptions .form-control,
    #HerniaOptions .form-control,
    #CollagenVascularOptions .form-control {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Dynamic surgery form builder */

.surgery-form-page, .patient-surgery-forms {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
    color: #243247
}

.surgery-form-header, .patient-surgery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px
}

    .surgery-form-header h1, .surgery-form-header h2, .patient-surgery-header h1, .patient-surgery-card h2 {
        margin: 0 0 8px
    }

    .surgery-form-header p, .patient-surgery-header p, .surgery-form-help {
        color: #64748b;
        margin: 0
    }

.surgery-form-card, .patient-surgery-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 18px
}

.surgery-form-meta {
    display: grid;
    grid-template-columns: 160px minmax(180px,1fr);
    gap: 12px;
    align-items: center
}

    .surgery-form-meta .surgery-form-check {
        grid-column: 2
    }

.surgery-form-section {
    border: 1px solid #dbe4ee;
    border-radius: 10px;
    padding: 16px;
    margin: 14px 0
}

.surgery-form-question {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    padding: 12px 0;
    border-bottom: 1px solid #edf2f7
}

    .surgery-form-question label {
        display: block;
        font-size: .85rem;
        margin-bottom: 5px
    }

    .surgery-form-question input, .surgery-form-question select, .surgery-form-section > input {
        width: 100%;
        min-width: 0;
        padding: 8px;
        border: 1px solid #cbd5e1;
        border-radius: 7px
    }

.surgery-form-json {
    font-family: Consolas,monospace;
    direction: ltr;
    text-align: left;
    margin: 10px 0
}

.surgery-form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

    .surgery-form-actions form, .patient-surgery-inline {
        display: inline-flex;
        margin: 0
    }

.surgery-form-table-wrap, .patient-surgery-table-wrap {
    overflow-x: auto
}

.surgery-form-help {
    font-size: .88rem
}

.patient-surgery-select {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap
}

    .patient-surgery-select select {
        min-width: 240px;
        max-width: 100%;
        padding: 10px;
        border: 1px solid #cbd5e1;
        border-radius: 8px
    }

.patient-surgery-field {
    display: grid;
    grid-template-columns: minmax(150px,220px) minmax(0,1fr);
    gap: 12px;
    align-items: start;
    margin: 14px 0;
    padding-bottom: 14px;
    border-bottom: 1px solid #edf2f7
}

    .patient-surgery-field > label {
        font-weight: 600
    }

    .patient-surgery-field input:not([type=checkbox]):not([type=radio]):not([type=file]), .patient-surgery-field select, .patient-surgery-field textarea {
        width: 100%;
        min-width: 0;
        padding: 10px;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        background: #fff
    }

.patient-surgery-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap
}

.patient-surgery-option {
    display: inline-flex;
    gap: 7px;
    align-items: center
}

.patient-surgery-answer {
    display: grid;
    grid-template-columns: minmax(160px,260px) 1fr;
    gap: 12px;
    border-bottom: 1px solid #edf2f7;
    padding: 12px 0
}

    .patient-surgery-answer p {
        margin: 0;
        white-space: pre-wrap;
        overflow-wrap: anywhere
    }

.patient-surgery-answer__files {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0
}

.patient-surgery-answer__file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    color: #276a8a;
    text-decoration: none;
    overflow-wrap: anywhere
}

    .patient-surgery-answer__file:hover {
        background: #f3f8fb
    }

    .patient-surgery-answer__file small {
        color: #718096;
        white-space: nowrap
    }

.patient-surgery-field[hidden] {
    display: none !important
}

@media(max-width:760px) {
    .surgery-form-meta {
        grid-template-columns: 1fr
    }

        .surgery-form-meta .surgery-form-check {
            grid-column: 1
        }

    .surgery-form-question {
        grid-template-columns: 1fr 1fr
    }

    .surgery-form-card, .patient-surgery-card {
        padding: 14px
    }

    .surgery-form-header, .patient-surgery-header {
        align-items: flex-start
    }

    .patient-surgery-field, .patient-surgery-answer {
        grid-template-columns: 1fr;
        gap: 6px
    }

    .patient-surgery-select select {
        min-width: 0;
        width: 100%
    }
}

/* OfficeMedyx — Surgery Forms index page only */
.office-surgery-index {
    --office-surgery-primary: var(--clr-primary, #2e6f90);
    --office-surgery-primary-light: var(--clr-primary-light, #dceaf1);
    --office-surgery-accent: var(--clr-accent, #3f9c86);
    --office-surgery-text: var(--clr-text, #25364a);
    --office-surgery-muted: var(--clr-text-muted, #778597);
    --office-surgery-border: var(--divider, #e4eaf0);
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 8px 0 28px;
    color: var(--office-surgery-text);
    direction: ltr;
    text-align: left;
}

    .office-surgery-index,
    .office-surgery-index * {
        box-sizing: border-box;
    }

.office-surgery-index__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.office-surgery-index__heading {
    min-width: 0;
}

.office-surgery-index__eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--office-surgery-accent);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
}

.office-surgery-index__heading h1 {
    margin: 0 0 8px;
    color: var(--office-surgery-text);
    font-size: clamp(1.55rem, 2.2vw, 2rem);
    font-weight: 750;
    line-height: 1.25;
}

.office-surgery-index__heading p,
.office-surgery-index__panel-heading p {
    margin: 0;
    color: var(--office-surgery-muted);
    font-size: .93rem;
    line-height: 1.65;
}

.office-surgery-index__patient-badge {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
    padding: 11px 15px;
    border: 1px solid var(--office-surgery-border);
    border-radius: 13px;
    background: var(--card-bg, #fff);
    color: var(--office-surgery-muted);
    font-size: .85rem;
}

    .office-surgery-index__patient-badge > i {
        color: var(--office-surgery-primary);
        font-size: 1.2rem;
    }

    .office-surgery-index__patient-badge strong {
        color: var(--office-surgery-text);
    }

.office-surgery-index__panel {
    margin-bottom: 22px;
    padding: clamp(18px, 2.2vw, 26px);
    border: 1px solid var(--office-surgery-border);
    border-radius: 18px;
    background: var(--card-bg, #fff);
    box-shadow: 0 7px 24px rgba(28, 54, 75, .045);
}

.office-surgery-index__panel-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 22px;
}

.office-surgery-index__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 13px;
    background: var(--office-surgery-primary-light);
    color: var(--office-surgery-primary);
    font-size: 1.2rem;
}

.office-surgery-index__panel-heading h2 {
    margin: 0 0 5px;
    color: var(--office-surgery-text);
    font-size: 1.12rem;
    font-weight: 750;
}

.office-surgery-index__select-form {
    display: flex;
    align-items: end;
    gap: 14px;
}

.office-surgery-index__form-field {
    flex: 1 1 auto;
    min-width: 0;
}

    .office-surgery-index__form-field label {
        display: block;
        margin-bottom: 8px;
        color: var(--office-surgery-text);
        font-size: .87rem;
        font-weight: 650;
    }

    .office-surgery-index__form-field select {
        display: block;
        width: 100%;
        min-height: 46px;
        padding: 10px 13px;
        border: 1px solid var(--office-surgery-border);
        border-radius: 10px;
        outline: none;
        background: var(--input-bg, #fff);
        color: var(--office-surgery-text);
        font: inherit;
        transition: border-color .18s ease, box-shadow .18s ease;
    }

        .office-surgery-index__form-field select:focus {
            border-color: var(--office-surgery-primary);
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--office-surgery-primary) 15%, transparent);
        }

.office-surgery-index__primary-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    padding: 10px 19px;
    border: 1px solid var(--office-surgery-primary);
    border-radius: 10px;
    background: var(--office-surgery-primary);
    color: #fff;
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .18s ease, filter .18s ease;
}

    .office-surgery-index__primary-button:hover {
        filter: brightness(.96);
        color: #fff;
        transform: translateY(-1px);
    }

.office-surgery-index__panel-heading--table {
    margin-bottom: 20px;
}

.office-surgery-index__count {
    margin-left: auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--office-surgery-primary-light);
    color: var(--office-surgery-primary);
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}

.office-surgery-index__empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 35px 16px 28px;
    border: 1px dashed var(--office-surgery-border);
    border-radius: 14px;
    text-align: center;
}

    .office-surgery-index__empty-state > span {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 54px;
        height: 54px;
        margin-bottom: 13px;
        border-radius: 16px;
        background: var(--office-surgery-primary-light);
        color: var(--office-surgery-primary);
        font-size: 1.45rem;
    }

    .office-surgery-index__empty-state h3 {
        margin: 0 0 7px;
        font-size: 1rem;
        font-weight: 750;
    }

    .office-surgery-index__empty-state p {
        margin: 0;
        color: var(--office-surgery-muted);
        font-size: .88rem;
    }

.office-surgery-index__table-wrap {
    width: 100%;
    overflow-x: auto;
}

.office-surgery-index__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .9rem;
}

    .office-surgery-index__table thead th {
        padding: 13px 15px;
        border-top: 1px solid var(--office-surgery-border);
        border-bottom: 1px solid var(--office-surgery-border);
        background: var(--table-head-bg, #f6f9fb);
        color: var(--office-surgery-muted);
        font-size: .76rem;
        font-weight: 750;
        letter-spacing: .025em;
        text-align: left;
        white-space: nowrap;
    }

        .office-surgery-index__table thead th:first-child {
            border-top-left-radius: 9px;
        }

        .office-surgery-index__table thead th:last-child {
            border-top-right-radius: 9px;
        }

    .office-surgery-index__table tbody td {
        padding: 15px;
        border-bottom: 1px solid var(--office-surgery-border);
        color: var(--office-surgery-text);
        vertical-align: middle;
    }

    .office-surgery-index__table tbody tr:last-child td {
        border-bottom: 0;
    }

    .office-surgery-index__table tbody tr:hover {
        background: color-mix(in srgb, var(--office-surgery-primary-light) 24%, transparent);
    }

.office-surgery-index__form-name {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
}

    .office-surgery-index__form-name i {
        color: var(--office-surgery-primary);
        font-size: 1.05rem;
    }

.office-surgery-index__version {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 7px;
    background: var(--office-surgery-primary-light);
    color: var(--office-surgery-primary);
    font-size: .78rem;
    font-weight: 750;
}

.office-surgery-index__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.office-surgery-index__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 33px;
    padding: 6px 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: .79rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.office-surgery-index__action--view {
    border-color: color-mix(in srgb, var(--office-surgery-primary) 25%, transparent);
    color: var(--office-surgery-primary);
}

.office-surgery-index__action--edit {
    border-color: color-mix(in srgb, var(--office-surgery-accent) 28%, transparent);
    color: var(--office-surgery-accent);
}

.office-surgery-index__action--delete {
    border-color: #f1d3d3;
    color: #b54747;
}

.office-surgery-index__action:hover {
    filter: brightness(.9);
}

.office-surgery-index__delete-form {
    display: inline-flex;
    margin: 0;
}

@media (max-width: 900px) {
    .office-surgery-index__table {
        min-width: 720px;
    }
}

@media (max-width: 640px) {
    .office-surgery-index {
        padding-top: 2px;
    }

    .office-surgery-index__header {
        align-items: flex-start;
        flex-direction: column;
        margin-bottom: 18px;
    }

    .office-surgery-index__patient-badge {
        align-self: stretch;
    }

    .office-surgery-index__panel {
        padding: 17px 14px;
        border-radius: 14px;
    }

    .office-surgery-index__select-form {
        align-items: stretch;
        flex-direction: column;
    }

    .office-surgery-index__primary-button {
        width: 100%;
    }

    .office-surgery-index__panel-heading {
        align-items: flex-start;
    }

    .office-surgery-index__panel-heading--table {
        flex-wrap: wrap;
    }

    .office-surgery-index__count {
        margin-left: 57px;
    }

    .office-surgery-index__empty-state {
        padding: 28px 12px;
    }
}



/* Surgery form entry page — isolated styles; appended to preserve existing UI. */
.office-surgery-create {
    --office-surgery-create-primary: var(--primary-color, var(--primary, #276a8a));
    --office-surgery-create-accent: var(--accent-color, #3f83a1);
    --office-surgery-create-text: var(--text-color, #263746);
    --office-surgery-create-muted: var(--muted-color, #718096);
    --office-surgery-create-border: var(--border-color, #e1e8ee);
    --office-surgery-create-surface: var(--card-bg, #ffffff);
    --office-surgery-create-soft: #f3f8fb;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 8px 0 28px;
    color: var(--office-surgery-create-text);
    direction: ltr;
    text-align: left;
}

    .office-surgery-create *,
    .office-surgery-create *::before,
    .office-surgery-create *::after {
        box-sizing: border-box;
    }

.office-surgery-create__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 24px;
    padding: 25px 28px;
    border: 1px solid var(--office-surgery-create-border);
    border-radius: 18px;
    background: var(--office-surgery-create-surface);
    box-shadow: 0 8px 28px rgba(34, 67, 88, .055);
}

.office-surgery-create__heading {
    min-width: 0;
}

.office-surgery-create__eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--office-surgery-create-primary);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
}

.office-surgery-create__heading h1 {
    margin: 0 0 9px;
    color: var(--office-surgery-create-text);
    font-size: clamp(1.25rem, 2.4vw, 1.8rem);
    font-weight: 750;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.office-surgery-create__heading p {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0;
    color: var(--office-surgery-create-muted);
    font-size: .88rem;
    line-height: 1.7;
}

.office-surgery-create__separator {
    margin: 0 5px;
    color: #a6b2bc;
}

.office-surgery-create__back,
.office-surgery-create__cancel,
.office-surgery-create__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 15px;
    border-radius: 10px;
    font: inherit;
    font-size: .86rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.office-surgery-create__back {
    flex: 0 0 auto;
    border: 1px solid var(--office-surgery-create-border);
    background: var(--office-surgery-create-surface);
    color: var(--office-surgery-create-primary);
}

    .office-surgery-create__back:hover, .office-surgery-create__cancel:hover {
        border-color: var(--office-surgery-create-primary);
        background: var(--office-surgery-create-soft);
        color: var(--office-surgery-create-primary);
    }

.office-surgery-create__form {
    display: block;
}

.office-surgery-create__validation {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 10px;
    background: #fff5f5;
}

    .office-surgery-create__validation:empty {
        display: none;
    }

.office-surgery-create__fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.office-surgery-create .patient-surgery-card {
    min-width: 0;
    margin: 0;
    padding: 24px;
    border: 1px solid var(--office-surgery-create-border);
    border-radius: 16px;
    background: var(--office-surgery-create-surface);
    box-shadow: 0 7px 22px rgba(34, 67, 88, .045);
}

    .office-surgery-create .patient-surgery-card > h2 {
        margin: 0 0 20px;
        padding-bottom: 13px;
        border-bottom: 1px solid var(--office-surgery-create-border);
        color: var(--office-surgery-create-text);
        font-size: 1.08rem;
        font-weight: 750;
        line-height: 1.5;
    }

    .office-surgery-create .patient-surgery-card > h3 {
        margin: 16px 0 10px;
        color: var(--office-surgery-create-primary);
        font-size: .98rem;
        font-weight: 750;
    }

.office-surgery-create .patient-surgery-field {
    min-width: 0;
    margin: 0 0 20px;
}

    .office-surgery-create .patient-surgery-field:last-child {
        margin-bottom: 0;
    }

    .office-surgery-create .patient-surgery-field > label {
        display: block;
        margin: 0 0 8px;
        color: var(--office-surgery-create-text);
        font-size: .88rem;
        font-weight: 700;
        line-height: 1.6;
    }

    .office-surgery-create .patient-surgery-field input:not([type=checkbox]):not([type=radio]):not([type=file]),
    .office-surgery-create .patient-surgery-field select,
    .office-surgery-create .patient-surgery-field textarea {
        display: block;
        width: 100%;
        min-height: 44px;
        padding: 10px 13px;
        border: 1px solid #d7e1e8;
        border-radius: 9px;
        outline: none;
        background: var(--office-surgery-create-surface);
        color: var(--office-surgery-create-text);
        font: inherit;
        font-size: .9rem;
        line-height: 1.5;
        box-shadow: none;
        transition: border-color .18s ease, box-shadow .18s ease;
    }

    .office-surgery-create .patient-surgery-field textarea {
        min-height: 110px;
        resize: vertical;
    }

        .office-surgery-create .patient-surgery-field input:focus,
        .office-surgery-create .patient-surgery-field select:focus,
        .office-surgery-create .patient-surgery-field textarea:focus {
            border-color: var(--office-surgery-create-accent);
            box-shadow: 0 0 0 3px rgba(63, 131, 161, .13);
        }

    /* The native file input is hidden; the "Choose file" button (label) of the document field opens it. */
    .office-surgery-create .patient-surgery-field input[type=file] {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        border: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        opacity: 0;
    }

/* Document field of a "file" question: saved document, chosen document and the picker button. */
.office-surgery-create .patient-surgery-file {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

    .office-surgery-create .patient-surgery-file [hidden] {
        display: none !important;
    }

.office-surgery-create .patient-surgery-file__current,
.office-surgery-create .patient-surgery-file__pending {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--office-surgery-create-border);
    border-radius: 10px;
    background: var(--office-surgery-create-soft);
}

.office-surgery-create .patient-surgery-file__pending {
    border-style: dashed;
    border-color: var(--office-surgery-create-accent);
    background: #eaf4f8;
}

.office-surgery-create .patient-surgery-file__icon {
    display: inline-flex;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #e3eef4;
    color: var(--office-surgery-create-primary);
    font-size: 1.1rem;
}

.office-surgery-create .patient-surgery-file__info {
    display: flex;
    flex: 1 1 180px;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.office-surgery-create .patient-surgery-file__name {
    color: var(--office-surgery-create-text);
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.5;
    text-decoration: none;
    overflow-wrap: anywhere;
}

    .office-surgery-create .patient-surgery-file__name:is(a):hover {
        color: var(--office-surgery-create-primary);
        text-decoration: underline;
    }

.office-surgery-create .patient-surgery-file__meta {
    color: var(--office-surgery-create-muted);
    font-size: .78rem;
    line-height: 1.5;
}

.office-surgery-create .patient-surgery-file__actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 8px;
    margin-inline-start: auto;
}

.office-surgery-create .patient-surgery-file__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--office-surgery-create-border);
    border-radius: 8px;
    background: var(--office-surgery-create-surface);
    color: var(--office-surgery-create-text);
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

    .office-surgery-create .patient-surgery-file__button:hover {
        background: var(--office-surgery-create-soft);
    }

    .office-surgery-create .patient-surgery-file__button:disabled {
        opacity: .6;
        cursor: not-allowed;
    }

.office-surgery-create .patient-surgery-file__button--view {
    border-color: color-mix(in srgb, var(--office-surgery-create-primary) 30%, transparent);
    color: var(--office-surgery-create-primary);
}

.office-surgery-create .patient-surgery-file__button--delete {
    border-color: #f1d3d3;
    color: #b54747;
}

.office-surgery-create .patient-surgery-file__picker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px dashed #cbd8e1;
    border-radius: 9px;
    background: var(--office-surgery-create-soft);
    color: var(--office-surgery-create-primary);
    font-size: .87rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease;
}

    .office-surgery-create .patient-surgery-file__picker:hover {
        border-color: var(--office-surgery-create-accent);
        background: #eaf4f8;
    }

    .office-surgery-create .patient-surgery-file__picker:focus-within {
        outline: 3px solid rgba(63, 131, 161, .3);
        outline-offset: 2px;
    }

.office-surgery-create .patient-surgery-file__error {
    color: #b54747;
    font-size: .8rem;
    line-height: 1.6;
}

.office-surgery-create .patient-surgery-field input[type=checkbox],
.office-surgery-create .patient-surgery-field input[type=radio] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--office-surgery-create-primary);
}

.office-surgery-create .patient-surgery-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 5px;
}

.office-surgery-create .patient-surgery-option {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 9px 13px;
    border: 1px solid var(--office-surgery-create-border);
    border-radius: 9px;
    background: var(--office-surgery-create-soft);
    color: var(--office-surgery-create-text);
    font-size: .87rem;
    cursor: pointer;
}

    .office-surgery-create .patient-surgery-option:has(input:checked) {
        border-color: var(--office-surgery-create-accent);
        background: #eaf4f8;
    }

.office-surgery-create .patient-surgery-field small {
    display: block;
    margin-top: 7px;
    color: var(--office-surgery-create-muted);
    font-size: .8rem;
    line-height: 1.6;
}

.office-surgery-create .patient-surgery-field[hidden] {
    display: none !important;
}

.office-surgery-create__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
    padding: 18px 22px;
    border: 1px solid var(--office-surgery-create-border);
    border-radius: 14px;
    background: var(--office-surgery-create-surface);
}

.office-surgery-create__cancel {
    border: 1px solid var(--office-surgery-create-border);
    background: var(--office-surgery-create-surface);
    color: var(--office-surgery-create-muted);
}

.office-surgery-create__submit {
    border: 1px solid var(--office-surgery-create-primary);
    background: var(--office-surgery-create-primary);
    color: #fff;
}

    .office-surgery-create__submit:hover {
        filter: brightness(.94);
        transform: translateY(-1px);
    }

    .office-surgery-create__submit:focus-visible, .office-surgery-create__back:focus-visible, .office-surgery-create__cancel:focus-visible {
        outline: 3px solid rgba(63, 131, 161, .3);
        outline-offset: 2px;
    }

@media (max-width: 760px) {
    .office-surgery-create__header {
        align-items: stretch;
        flex-direction: column;
        padding: 21px 19px;
    }

    .office-surgery-create__back {
        align-self: flex-start;
    }

    .office-surgery-create .patient-surgery-card {
        padding: 19px 16px;
    }

    .office-surgery-create__footer {
        justify-content: stretch;
        padding: 14px;
    }

        .office-surgery-create__footer > * {
            flex: 1 1 0;
        }
}

@media (max-width: 460px) {
    .office-surgery-create {
        padding-top: 0;
    }

    .office-surgery-create__header {
        border-radius: 13px;
    }

    .office-surgery-create__heading p {
        display: block;
    }

    .office-surgery-create__separator {
        margin: 0 3px;
    }

    .office-surgery-create .patient-surgery-options {
        flex-direction: column;
        align-items: stretch;
    }

    .office-surgery-create .patient-surgery-option {
        width: 100%;
    }

    .office-surgery-create .patient-surgery-file,
    .office-surgery-create .patient-surgery-file__picker {
        width: 100%;
    }

    .office-surgery-create .patient-surgery-file__actions {
        width: 100%;
        margin-inline-start: 0;
    }

    .office-surgery-create .patient-surgery-file__button {
        flex: 1 1 0;
    }

    .office-surgery-create__footer {
        flex-direction: column-reverse;
    }

        .office-surgery-create__footer > * {
            width: 100%;
        }
}


/* Surgery form input alignment fixes — scoped to the dynamic surgery editor only. */
.office-surgery-create .patient-surgery-field {
    display: block;
    width: 100%;
}

.office-surgery-create .patient-surgery-field--boolean {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-height: 38px;
}

    .office-surgery-create .patient-surgery-field--boolean > input[type="checkbox"] {
        flex: 0 0 16px;
        order: 0;
    }

    .office-surgery-create .patient-surgery-field--boolean > label {
        order: 1;
        margin: 0;
        cursor: pointer;
    }

.office-surgery-create .patient-surgery-options {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.office-surgery-create .patient-surgery-option {
    width: auto;
    flex: 0 0 auto;
}


/* Surgery form details page: same look as the other surgery form pages. */
.office-surgery-details__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

    .office-surgery-details__actions .office-surgery-create__submit:hover {
        color: #fff;
    }

.office-surgery-details .patient-surgery-answer {
    display: grid;
    grid-template-columns: minmax(160px, 260px) minmax(0, 1fr);
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--office-surgery-create-border);
}

    .office-surgery-details .patient-surgery-answer:last-child {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .office-surgery-details .patient-surgery-answer > strong {
        color: var(--office-surgery-create-text);
        font-size: .88rem;
        font-weight: 700;
        line-height: 1.6;
        overflow-wrap: anywhere;
    }

    .office-surgery-details .patient-surgery-answer p,
    .office-surgery-details .patient-surgery-answer__files {
        min-width: 0;
        color: var(--office-surgery-create-text);
        font-size: .9rem;
        line-height: 1.7;
    }

.office-surgery-details .patient-surgery-answer__file {
    border-color: var(--office-surgery-create-border);
    background: var(--office-surgery-create-soft);
    color: var(--office-surgery-create-primary);
    font-weight: 700;
}

@media (max-width: 760px) {
    .office-surgery-details .patient-surgery-answer {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }

    .office-surgery-details__actions {
        width: 100%;
    }
}

@media (max-width: 460px) {
    .office-surgery-details__actions > * {
        flex: 1 1 100%;
    }
}
