/* Med Marlo â€” Frappe UI structure, ink + mint palette (Frappe HR colors) */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --mm-ink: #0B313A;
    --mm-ink-soft: #134852;
    --mm-ink-muted: #1a5a66;
    --mm-mint: #A1EEC9;
    --mm-mint-soft: #d8f8e8;
    --mm-mint-deep: #3d9b78;
    --mm-canvas: #e7f0ee;
    --mm-canvas-deep: #d5e4e1;
    --mm-surface: #ffffff;
    --mm-surface-2: #f4faf8;
    --mm-line: #c5d6d2;
    --mm-line-soft: #d9e6e3;
    --mm-text: #0f2c33;
    --mm-text-muted: #4a6b72;
    --mm-blue: #0289F7;
    --mm-blue-soft: #E6F4FF;
    --mm-blue-deep: #0070CC;
    --mm-green: #278F5E;
    --mm-green-soft: #E4FAEB;
    --mm-red: #E03636;
    --mm-amber: #DB7706;
    --mm-radius: 10px;
    --mm-shadow: 0 1px 2px rgba(11, 49, 58, 0.06), 0 4px 16px rgba(11, 49, 58, 0.05);
    --mm-shadow-lg: 0 12px 40px rgba(11, 49, 58, 0.12);

    --fu-gray-50: var(--mm-surface-2);
    --fu-gray-100: var(--mm-canvas);
    --fu-gray-200: var(--mm-line-soft);
    --fu-gray-300: var(--mm-line);
    --fu-gray-400: #9bb0ad;
    --fu-gray-500: #6f8a86;
    --fu-gray-600: var(--mm-text-muted);
    --fu-gray-700: #355960;
    --fu-gray-800: #1e4149;
    --fu-gray-900: var(--mm-text);
    --fu-blue-50: var(--mm-blue-soft);
    --fu-blue-100: #d6ecff;
    --fu-blue-200: #a8d7fc;
    --fu-blue-500: var(--mm-blue);
    --fu-blue-600: #007BE0;
    --fu-blue-700: var(--mm-blue-deep);
    --fu-green-100: var(--mm-green-soft);
    --fu-green-500: #46B37E;
    --fu-green-600: var(--mm-green);
    --fu-red-500: var(--mm-red);
    --fu-amber-500: var(--mm-amber);
    --fu-mint: var(--mm-mint);
    --fu-ink: var(--mm-ink);
    --fu-radius: var(--mm-radius);
    --fu-shadow: var(--mm-shadow);
    --fu-shadow-lg: var(--mm-shadow-lg);

    --docrev-white: var(--mm-surface);
    --docrev-bg: var(--mm-canvas);
    --docrev-blue-50: #e8f6f2;
    --docrev-blue-100: var(--mm-mint-soft);
    --docrev-blue-200: #9fd4c4;
    --docrev-blue-500: var(--mm-mint-deep);
    --docrev-blue-600: var(--mm-ink-soft);
    --docrev-blue-700: var(--mm-ink);
    --docrev-blue-800: var(--mm-ink);
    --docrev-green-50: var(--mm-mint-soft);
    --docrev-green-100: #c8f0dc;
    --docrev-green-200: #8fd4b4;
    --docrev-green-500: var(--mm-mint-deep);
    --docrev-green-600: var(--mm-green);
    --docrev-text: var(--mm-text);
    --docrev-text-muted: var(--mm-text-muted);
    --docrev-border: var(--mm-line);
    --docrev-sidebar-top: var(--mm-ink);
    --docrev-sidebar-bottom: var(--mm-ink-soft);
    --docrev-sidebar-accent: var(--mm-mint);
    --docrev-shadow: var(--mm-shadow);
    --docrev-shadow-lg: var(--mm-shadow-lg);
    --docrev-radius: var(--mm-radius);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(ellipse 80% 50% at 100% 0%, rgba(161, 238, 201, 0.28) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 0% 100%, rgba(11, 49, 58, 0.06) 0%, transparent 50%),
        var(--mm-canvas);
    color: var(--mm-text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.layout { min-height: 100vh; }

.sidebar {
    width: 248px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    background: linear-gradient(180deg, var(--mm-ink) 0%, #0a2a32 55%, var(--mm-ink-soft) 100%);
    border-right: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 8px 0 32px rgba(11, 49, 58, 0.18);
    overflow: hidden;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--mm-mint) 0%, #6ed4a8 50%, transparent 100%);
}

.sidebar h1 {
    padding: 1.25rem 1rem;
    color: #ffffff;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-transform: none;
    font-size: 1rem;
}

.sidebar-brand,
.login-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.sidebar-brand {
    padding: 1.35rem 1.15rem 1.1rem;
    border-bottom: 1px solid rgba(161, 238, 201, 0.14);
}

.login-brand {
    margin-bottom: 1.5rem;
    align-items: center;
    text-align: center;
    width: 100%;
}

.docrev-brand-logo { display: none !important; }

/* Branded lockup: mark + single-line wordmark + product under text */
.mm-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.mm-brand__mark {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: block;
    border-radius: 11px;
}
.mm-brand__text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.15rem;
    min-width: 0;
}
.mm-brand__name {
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--mm-ink);
    white-space: nowrap;
}
.mm-brand__product {
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.2;
    color: var(--mm-text-muted);
    white-space: nowrap;
}
.mm-brand--on-dark .mm-brand__name {
    color: #ffffff;
}
.mm-brand--on-dark .mm-brand__product {
    color: rgba(161, 238, 201, 0.88);
}
.mm-brand--sm .mm-brand__mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
}
.mm-brand--sm .mm-brand__name {
    font-size: 1.05rem;
}
.mm-brand--sm .mm-brand__product {
    font-size: 0.62rem;
}
.mm-brand--lg .mm-brand__mark {
    width: 48px;
    height: 48px;
}
.mm-brand--lg .mm-brand__name {
    font-size: 1.55rem;
}
.mm-brand--lg .mm-brand__product {
    font-size: 0.75rem;
    letter-spacing: 0.1em;
}
.login-brand .mm-brand {
    justify-content: center;
}
.login-brand .mm-brand__text {
    align-items: flex-start;
    text-align: left;
}
.sidebar-brand .mm-brand {
    width: 100%;
}
.mobile-topbar .mm-brand {
    flex: 1;
    min-width: 0;
}
.portal-topbar .mm-brand,
.portal-header .mm-brand {
    align-items: center;
}

.brand-logo {
    display: block;
    height: auto;
    max-width: 100%;
}
.brand-logo--light {
    width: 200px;
    max-width: 100%;
}
.brand-logo--sidebar {
    width: 168px;
    max-width: 100%;
}
.brand-logo--header {
    width: 160px;
    max-width: 100%;
    filter: none;
}
.portal-topbar .docrev-brand-product,
.portal-header .docrev-brand-product {
    align-self: center;
}

.docrev-brand-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.login-brand .docrev-brand-text,
.login-brand { align-items: center; }

.docrev-brand-name {
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
    line-height: 1.15;
    color: #ffffff;
}

.sidebar-brand .docrev-brand-name { color: #ffffff; }
.login-brand .docrev-brand-name {
    font-size: 1.65rem;
    color: var(--mm-ink);
}

.docrev-brand-product {
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0;
    color: rgba(161, 238, 201, 0.85);
}

.sidebar-brand .docrev-brand-product { color: rgba(161, 238, 201, 0.85); }
.login-brand .docrev-brand-product {
    color: var(--mm-text-muted);
    letter-spacing: 0.08em;
    margin-top: 0.35rem;
}

.sidebar nav {
    flex: 1;
    min-height: 0;
    padding: 0.65rem 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(161, 238, 201, 0.35) transparent;
}

.sidebar nav::-webkit-scrollbar { width: 5px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(161, 238, 201, 0.28); border-radius: 999px; }
.sidebar nav::-webkit-scrollbar-button { display: none; height: 0; width: 0; }

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 0.65rem 1rem;
    border-top: 1px solid rgba(161, 238, 201, 0.12);
}

.sidebar-footer .logout,
.sidebar-footer .logout:visited,
.sidebar-footer .logout:hover,
.sidebar-footer .logout:focus {
    display: block;
    padding: 0.6rem 0.85rem;
    color: rgba(255, 255, 255, 0.88) !important;
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    border: 1px solid rgba(161, 238, 201, 0.28);
    background: rgba(161, 238, 201, 0.08);
}

.sidebar-footer .logout:hover {
    background: rgba(161, 238, 201, 0.18);
    color: #ffffff !important;
    border-color: rgba(161, 238, 201, 0.45);
}

.sidebar nav a {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.75rem;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid transparent;
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar nav a.active {
    display: flex;
    align-items: center;
    background: rgba(161, 238, 201, 0.14);
    color: #d8f8e8;
    font-weight: 600;
    box-shadow: none;
    border: 1px solid rgba(161, 238, 201, 0.28);
}

.sidebar nav a.active::before { display: none; }

.sidebar-subnav {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    margin: 0.1rem 0 0.35rem 0.85rem;
    padding: 0.15rem 0 0.15rem 0.55rem;
    border-left: 2px solid rgba(161, 238, 201, 0.22);
    flex-shrink: 0;
}

.sidebar-subnav a {
    display: block;
    padding: 0.32rem 0.55rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.25;
    border: none;
}

.sidebar-subnav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar-subnav a.active {
    background: rgba(161, 238, 201, 0.10);
    color: #c8f0dc;
    font-weight: 600;
    box-shadow: none;
}

.sidebar-subnav a.active::before { display: none; }

.main {
    margin-left: 248px;
    min-height: 100vh;
    padding: 1.65rem 1.85rem;
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
}

/* —— Patient Portal shell —— */
.wrap,
.portal-app {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 70% 40% at 100% 0%, rgba(161, 238, 201, 0.22) 0%, transparent 55%),
        radial-gradient(ellipse 50% 35% at 0% 100%, rgba(11, 49, 58, 0.05) 0%, transparent 50%),
        var(--mm-canvas);
}

.portal-topbar {
    background: linear-gradient(135deg, var(--mm-ink) 0%, var(--mm-ink-soft) 100%);
    border-bottom: 3px solid var(--mm-mint-deep);
    box-shadow: var(--mm-shadow-lg);
}
.portal-topbar__inner {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.9rem clamp(1rem, 3vw, 1.75rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.portal-topbar .mm-brand__name { color: #ffffff; }
.portal-topbar .mm-brand__product { color: rgba(161, 238, 201, 0.9); }
.portal-topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.18);
}
.portal-user {
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 0.84rem;
    font-weight: 650;
    color: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
}
.portal-topbar .btn.logout,
.portal-topbar .logout {
    background: rgba(161, 238, 201, 0.14) !important;
    color: #ffffff !important;
    border: 1px solid rgba(161, 238, 201, 0.55) !important;
    border-radius: 999px !important;
    padding: 0.4rem 0.9rem !important;
    font-weight: 650 !important;
}
.portal-topbar .btn.logout:hover,
.portal-topbar .logout:hover {
    background: rgba(161, 238, 201, 0.28) !important;
    color: #ffffff !important;
    border-color: var(--mm-mint) !important;
}
.portal-topbar .btn.logout i,
.portal-topbar .logout i {
    color: #ffffff !important;
}

.portal-tabs {
    background: var(--mm-surface-2);
    border-bottom: 1px solid var(--mm-line-soft);
    position: sticky;
    top: 0;
    z-index: 50;
}
.portal-tabs__inner {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.65rem clamp(1rem, 3vw, 1.75rem);
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.portal-tab {
    appearance: none;
    border: 1px solid var(--mm-line);
    background: var(--mm-surface);
    color: var(--mm-text-muted);
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 0.86rem;
    font-weight: 650;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    box-shadow: 0 1px 0 rgba(11, 49, 58, 0.04);
    transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.portal-tab i {
    font-size: 0.88rem;
    opacity: 0.9;
    width: 1rem;
    text-align: center;
}
.portal-tab:hover {
    color: var(--mm-ink);
    border-color: #8fd4b4;
    background: #f7fcfa;
}
.portal-tab.is-active {
    color: var(--mm-ink);
    background: var(--mm-mint-soft);
    border-color: var(--mm-mint-deep);
    box-shadow: inset 0 0 0 1px rgba(39, 143, 94, 0.15);
}
.portal-tab.is-active i {
    opacity: 1;
}
.portal-tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--mm-ink);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
}

.portal-main {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.65rem clamp(1rem, 3vw, 1.75rem) 2.75rem;
}

.portal-hero {
    background: var(--mm-surface);
    border: 1px solid var(--mm-line-soft);
    border-radius: 14px;
    padding: 1.5rem 1.6rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--mm-shadow);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.portal-hero__title {
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--mm-ink);
    margin: 0 0 0.4rem;
    line-height: 1.2;
}
.portal-hero__copy {
    margin: 0;
    color: var(--mm-text-muted);
    font-size: 0.95rem;
    max-width: 40rem;
    line-height: 1.5;
}

.portal-quick {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 0.25rem;
}
.portal-quick-card {
    appearance: none;
    text-align: left;
    cursor: pointer;
    background: var(--mm-surface);
    border: 1px solid var(--mm-line-soft);
    border-radius: 14px;
    padding: 1.2rem 1.25rem;
    box-shadow: var(--mm-shadow);
    transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
    min-width: 0;
}
.portal-quick-card:hover {
    border-color: #8fd4b4;
    box-shadow: var(--mm-shadow-lg);
    transform: translateY(-1px);
}
.portal-quick-card__icon {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--mm-mint-soft);
    color: var(--mm-ink);
    margin-bottom: 0.85rem;
}
.portal-quick-card__num {
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--mm-ink);
    line-height: 1;
}
.portal-quick-card__label {
    margin-top: 0.35rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--mm-text-muted);
}

.portal-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.portal-page-head h2 {
    margin: 0;
    font-family: Manrope, Inter, system-ui, sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--mm-ink);
}
.portal-page-head p {
    margin: 0.3rem 0 0;
    color: var(--mm-text-muted);
    font-size: 0.9rem;
}

.portal-card {
    background: var(--mm-surface);
    border: 1px solid var(--mm-line-soft);
    border-radius: 14px;
    padding: 1.35rem;
    box-shadow: var(--mm-shadow);
    margin-bottom: 1.25rem;
    min-width: 0;
}
.portal-card > h2:first-child,
.portal-card .portal-page-head {
    margin-bottom: 1rem;
}
.portal-card .table-wrap {
    margin-top: 0.25rem;
}
.portal-empty {
    color: var(--mm-text-muted);
    font-size: 0.92rem;
    padding: 1.25rem 0.25rem;
    margin: 0;
}

.portal-compose {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--mm-surface-2);
    border: 1px solid var(--mm-line-soft);
    border-radius: 10px;
}
.portal-thread-list {
    border: 1px solid var(--mm-line-soft);
    border-radius: 10px;
    overflow: auto;
    max-height: 480px;
    background: var(--mm-surface);
}
.portal-thread-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-bottom: 1px solid var(--mm-line-soft);
    border-radius: 0;
    background: transparent;
    padding: 0.85rem 1rem;
    cursor: pointer;
    font-family: inherit;
}
.portal-thread-item:hover { background: var(--mm-surface-2); }
.portal-thread-item.is-active {
    background: var(--mm-mint-soft);
    border-left: 3px solid var(--mm-mint-deep);
}
.portal-thread-item strong {
    display: block;
    color: var(--mm-ink);
    font-size: 0.9rem;
}
.portal-thread-item__meta {
    font-size: 0.75rem;
    color: var(--mm-text-muted);
    margin-top: 0.2rem;
}
.portal-thread-pane {
    border: 1px solid var(--mm-line-soft);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 320px;
    background: var(--mm-surface);
}
.portal-thread-empty {
    border: 1px dashed var(--mm-line);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mm-text-muted);
    min-height: 200px;
    background: var(--mm-surface-2);
}

/* Legacy aliases used by older portal markup */
.portal-header { /* kept for safety */ }
.portal-body { width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.65rem clamp(1rem, 3vw, 1.75rem) 2.75rem; }
.portal-nav { display: none; }

/* Cards & panels */
.card {
    background: var(--mm-surface);
    border-radius: var(--mm-radius);
    padding: 1.35rem;
    box-shadow: var(--mm-shadow);
    border: 1px solid var(--mm-line-soft);
    margin-bottom: 1.35rem;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.panel {
    background: var(--fu-gray-50);
    border: 1px solid var(--fu-gray-300);
    border-radius: var(--fu-radius);
    padding: 1rem;
    margin: 1rem 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.card > .panel,
.layout-grid > .panel,
.layout-grid > .card {
    margin: 0;
}

/* Consistent multi-column layouts (prevents overlapping tables) */
.layout-grid {
    display: grid;
    gap: 1.25rem;
    align-items: start;
    width: 100%;
    min-width: 0;
}
.layout-grid > * {
    min-width: 0;
    max-width: 100%;
}
.layout-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.layout-grid--aside {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
}
.layout-grid--main-aside {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}
.layout-grid--mailbox {
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
}
.layout-grid--auto {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 0.75rem;
    border-radius: var(--mm-radius);
}
.table-wrap > table {
    margin-top: 0;
    min-width: 520px;
}
.table-wrap--sm > table { min-width: 420px; }
.table-wrap--lg > table { min-width: 720px; }

td code,
th code {
    white-space: nowrap;
    font-size: 0.8em;
}
td.nowrap,
th.nowrap {
    white-space: nowrap;
}

h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--fu-gray-900);
    font-weight: 600;
    letter-spacing: -0.01em;
}
h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--fu-gray-800);
    font-weight: 600;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 0.75rem;
    background: var(--mm-surface);
    border: 1px solid var(--mm-line-soft);
    border-radius: var(--mm-radius);
    overflow: hidden;
    box-shadow: var(--mm-shadow);
}

th, td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--fu-gray-200);
    border-right: none;
    font-size: 0.875rem;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--mm-mint-soft); }

th {
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: normal;
    color: var(--mm-text-muted);
    background: linear-gradient(180deg, #f7fcfa 0%, var(--mm-surface-2) 100%);
    font-weight: 600;
    border-bottom: 1px solid var(--mm-line);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--fu-gray-100);
    color: var(--fu-gray-700);
}
.badge-green { background: var(--fu-green-100); color: var(--fu-green-600); }
.badge-yellow { background: #FFF7D3; color: #B35309; }
.badge-blue { background: var(--fu-blue-100); color: var(--fu-blue-700); }

/* Buttons Ã¢â‚¬â€ frappe-ui solid/outline */
.btn {
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--mm-surface);
    color: var(--mm-ink);
    border: 1px solid var(--mm-line);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover {
    background: var(--mm-mint-soft);
    border-color: #8fd4b4;
}
.btn-sm { padding: 0.28rem 0.55rem; font-size: 0.78rem; }
.btn-icon {
    min-width: 2rem;
    padding: 0.28rem 0.45rem;
    line-height: 1;
}
.btn-icon .fas { font-size: 0.85rem; pointer-events: none; }
.btn-primary {
    background: var(--mm-ink);
    color: #ffffff;
    border-color: var(--mm-ink);
}
.btn-primary:hover {
    background: var(--mm-ink-soft);
    border-color: var(--mm-ink-soft);
}
.btn-success {
    background: var(--fu-green-500);
    color: #ffffff;
    border-color: var(--fu-green-500);
}
.btn-success:hover {
    background: var(--fu-green-600);
    border-color: var(--fu-green-600);
}

/* Login */
.login-wrap,
.portal-login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(161, 238, 201, 0.45) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 80%, rgba(11, 49, 58, 0.12) 0%, transparent 50%),
        var(--mm-canvas);
}
.login-card {
    background: var(--mm-surface);
    padding: 2.15rem;
    border-radius: 14px;
    width: 390px;
    max-width: calc(100vw - 2rem);
    box-shadow: var(--mm-shadow-lg);
    border: 1px solid var(--mm-line-soft);
    border-top: 4px solid var(--mm-mint-deep);
}
.login-card h2 {
    margin-bottom: 1.25rem;
    text-align: center;
    color: var(--mm-ink);
}

.login-card .login-brand + .form-group { margin-top: 0; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
    color: var(--fu-gray-700);
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--fu-gray-300);
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--fu-gray-900);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.2rem;
    min-height: 2.35rem;
    line-height: 1.35;
    cursor: pointer;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C7C7C' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 0.9rem;
}
.form-group select:hover { border-color: var(--fu-gray-400); }
.form-group select:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background-color: var(--fu-gray-50);
}
.form-group select[multiple],
.form-group select[size]:not([size="1"]) {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    background-image: none;
    padding: 0.45rem 0.65rem;
    min-height: 7.5rem;
    line-height: 1.45;
    cursor: default;
}
.form-group select option {
    color: var(--fu-gray-900);
    background: #ffffff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--mm-mint-deep);
    box-shadow: 0 0 0 3px rgba(161, 238, 201, 0.45);
}
.form-group input[type="checkbox"] {
    width: auto;
    min-height: auto;
    accent-color: var(--fu-blue-500);
    cursor: pointer;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

/* Inline filter toolbars */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-bar .form-group {
    margin-bottom: 0;
    flex: 0 1 auto;
}
.filter-bar .form-group select,
.filter-bar .form-group input:not([type="checkbox"]) {
    width: auto;
    min-width: 9rem;
    max-width: 100%;
}
.filter-bar .form-group--wide select { min-width: 11.5rem; }
.filter-bar .form-group--state select { min-width: 13.5rem; }
.filter-bar .form-group--search input { min-width: 14rem; }
.filter-bar .form-group--multi select { min-width: 17.5rem; width: 100%; }
.filter-bar .checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--fu-gray-800);
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0.35rem;
    cursor: pointer;
    user-select: none;
}
.filter-bar .checkbox-inline input { margin: 0; }

.error { color: var(--fu-red-500); font-size: 0.875rem; margin-top: 0.5rem; }

.toast {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--fu-green-100);
    color: var(--fu-green-600);
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border: 1px solid #C3F9D3;
    border-left: 3px solid var(--fu-green-500);
}
.toast__text { flex: 1; min-width: 0; line-height: 1.45; }
.toast__close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 0.1rem;
}
.toast__close:hover,
.toast__close:focus { opacity: 1; outline: none; }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}
.stat {
    background: var(--mm-surface);
    padding: 1.15rem 1.2rem;
    border-radius: var(--mm-radius);
    box-shadow: var(--mm-shadow);
    border: 1px solid var(--mm-line-soft);
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--mm-mint-deep);
}
.stat .num {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--mm-ink);
    line-height: 1.2;
    letter-spacing: -0.02em;
}
.stat .label {
    font-size: 0.78rem;
    color: var(--fu-gray-600);
    margin-top: 0.2rem;
    font-weight: 500;
}

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.edi-box {
    background: var(--fu-gray-50);
    color: var(--fu-gray-800);
    padding: 1rem;
    border-radius: 6px;
    overflow: auto;
    max-height: 300px;
    font-size: 0.75rem;
    white-space: pre-wrap;
    border: 1px solid var(--fu-gray-300);
    font-family: ui-monospace, Consolas, 'Courier New', monospace;
}

.btn.logout {
    background: transparent !important;
    color: var(--fu-gray-700) !important;
    border: 1px solid var(--fu-gray-300) !important;
}
.btn.logout:hover {
    background: var(--fu-gray-50) !important;
}


.patient-subnav {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin: 1rem 0 1.15rem;
    padding: 0.55rem 0.6rem;
    background: #ffffff;
    border: 1px solid var(--fu-gray-300);
    border-radius: var(--fu-radius);
    box-shadow: none;
}

.patient-subnav__btn { white-space: nowrap; }

.patient-subtitle {
    margin-top: 0.3rem;
    color: var(--fu-gray-600);
    font-size: 0.875rem;
}

.patient-empty-state {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--fu-gray-600);
    background: var(--fu-gray-50);
    border: 1px dashed var(--fu-gray-300);
    border-radius: var(--fu-radius);
    margin-bottom: 1rem;
}

.patient-empty-state p { margin: 0; }

/* Clinical mailbox */
.mailbox-card { padding: 0; overflow: hidden; }
.mailbox-card > .mailbox-header,
.mailbox-card > .mailbox-layout { padding-left: 1.5rem; padding-right: 1.5rem; }
.mailbox-card > .mailbox-header { padding-top: 1.5rem; padding-bottom: 1rem; }
.mailbox-card > .mailbox-layout { padding-bottom: 1.5rem; }

.mailbox-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    border-bottom: 1px solid var(--docrev-border);
    margin-bottom: 0;
}
.mailbox-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    color: var(--docrev-text-muted);
}
.mailbox-layout {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 0;
    min-height: 520px;
    border: 1px solid var(--docrev-border);
    border-radius: var(--docrev-radius);
    overflow: hidden;
    background: var(--docrev-white);
    width: 100%;
    min-width: 0;
}
.mailbox-inbox {
    border-right: 1px solid var(--docrev-border);
    background: var(--docrev-blue-50);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.mailbox-inbox-toolbar {
    padding: 0.75rem;
    border-bottom: 1px solid var(--docrev-border);
    background: var(--docrev-white);
}
.mailbox-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--docrev-border);
    border-radius: 8px;
    font-size: 0.875rem;
}
.mailbox-search:focus {
    outline: none;
    border-color: var(--docrev-blue-500);
    box-shadow: 0 0 0 3px rgba(2, 137, 247, 0.15);
}
.mailbox-thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.mailbox-thread-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 10px;
    padding: 0.7rem;
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.mailbox-thread-item:hover {
    background: rgba(255, 255, 255, 0.75);
    border-color: var(--docrev-border);
}
.mailbox-thread-item.active {
    background: var(--docrev-white);
    border-color: var(--docrev-blue-200);
    box-shadow: var(--docrev-shadow);
}
.mailbox-thread-item.unread .mailbox-thread-subject {
    font-weight: 700;
}
.mailbox-thread-avatar {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--docrev-blue-600);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mailbox-thread-avatar--lg {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 0.85rem;
}
.mailbox-thread-meta { flex: 1; min-width: 0; }
.mailbox-thread-top {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: baseline;
}
.mailbox-thread-top strong {
    font-size: 0.9rem;
    color: var(--docrev-text);
}
.mailbox-thread-time {
    font-size: 0.72rem;
    color: var(--docrev-text-muted);
    white-space: nowrap;
}
.mailbox-thread-subject {
    font-size: 0.82rem;
    color: var(--docrev-blue-700);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mailbox-thread-preview {
    font-size: 0.78rem;
    color: var(--docrev-text-muted);
    margin-top: 0.2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mailbox-unread-dot {
    position: absolute;
    top: 0.85rem;
    right: 0.65rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--docrev-blue-500);
}
.mailbox-empty {
    padding: 1.5rem 0.75rem;
    text-align: center;
    color: var(--docrev-text-muted);
    font-size: 0.875rem;
}
.mailbox-thread-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--fu-gray-50);
}
.mailbox-thread-panel--empty {
    align-items: center;
    justify-content: center;
    color: var(--docrev-text-muted);
}
.mailbox-thread-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    background: var(--docrev-white);
    border-bottom: 1px solid var(--docrev-border);
}
.mailbox-thread-title {
    margin: 0;
    font-size: 1.05rem;
    color: var(--docrev-blue-700);
}
.mailbox-thread-participant {
    margin: 0.2rem 0 0;
    font-size: 0.82rem;
    color: var(--docrev-text-muted);
}
.mailbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.mailbox-message {
    display: flex;
    max-width: 85%;
}
.mailbox-message--in { align-self: flex-start; }
.mailbox-message--out { align-self: flex-end; }
.mailbox-bubble {
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    box-shadow: var(--docrev-shadow);
}
.mailbox-message--in .mailbox-bubble {
    background: var(--docrev-white);
    border: 1px solid var(--docrev-border);
    border-bottom-left-radius: 4px;
}
.mailbox-message--out .mailbox-bubble {
    background: var(--fu-blue-500);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.mailbox-bubble-head {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
}
.mailbox-message--in .mailbox-bubble-head strong { color: var(--docrev-blue-700); }
.mailbox-message--in .mailbox-bubble-head span { color: var(--docrev-text-muted); }
.mailbox-message--out .mailbox-bubble-head strong,
.mailbox-message--out .mailbox-bubble-head span { color: rgba(255, 255, 255, 0.9); }
.mailbox-bubble-body {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
}
.mailbox-message--in .mailbox-bubble-body { color: var(--docrev-text); }
.mailbox-bubble-time {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.72rem;
    opacity: 0.8;
}
.mailbox-compose {
    padding: 1rem 1.25rem;
    background: var(--docrev-white);
    border-top: 1px solid var(--docrev-border);
}
.mailbox-compose textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--docrev-border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 4.5rem;
}
.mailbox-compose textarea:focus {
    outline: none;
    border-color: var(--docrev-blue-500);
    box-shadow: 0 0 0 3px rgba(2, 137, 247, 0.12);
}
.mailbox-compose-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.65rem;
    gap: 0.75rem;
}
.mailbox-compose-hint {
    font-size: 0.75rem;
    color: var(--docrev-text-muted);
}

@media (max-width: 900px) {
    .mailbox-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .mailbox-inbox {
        max-height: 240px;
        border-right: none;
        border-bottom: 1px solid var(--docrev-border);
    }
    .mailbox-messages { min-height: 280px; }
}

/* Consistent page utilities (prefer classes over random hex) */
.text-muted { color: var(--mm-text-muted) !important; }
.text-ink { color: var(--mm-text) !important; }
.icon-accent { color: var(--mm-mint-deep) !important; }
.surface-soft { background: var(--mm-surface-2) !important; border-color: var(--mm-line) !important; }
.panel-section {
    background: var(--mm-surface) !important;
    border: 1px solid var(--mm-line) !important;
    border-radius: var(--mm-radius);
    padding: 1.35rem;
}
.panel-section > h3 {
    color: var(--mm-text) !important;
    border-bottom: 1px solid var(--mm-line-soft) !important;
    padding-bottom: 0.5rem;
}
.btn-danger {
    background: var(--mm-red) !important;
    color: #fff !important;
    border-color: var(--mm-red) !important;
}
.row-selected {
    background: var(--mm-mint-soft) !important;
    border-left: 4px solid var(--mm-mint-deep) !important;
}
.badge-success { background: var(--mm-green-soft) !important; color: var(--mm-green) !important; }
.badge-info { background: #e8f6f2 !important; color: var(--mm-ink) !important; }
.badge-warn { background: #FFF7D3 !important; color: #B35309 !important; }

h2 .fas, h2 .far, h3 .fas, h3 .far {
    color: var(--mm-mint-deep);
}

/* —— Responsive shell —— */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 90;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.25rem;
    padding: 0.65rem 0.9rem;
    background: linear-gradient(135deg, var(--mm-ink) 0%, var(--mm-ink-soft) 100%);
    color: #fff;
    border-bottom: 3px solid var(--mm-mint-deep);
    box-shadow: var(--mm-shadow);
}
.mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid rgba(161, 238, 201, 0.35);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-menu-btn:hover,
.mobile-menu-btn:focus-visible {
    background: rgba(161, 238, 201, 0.18);
    outline: none;
}
.brand-logo--topbar {
    width: 132px;
    max-width: calc(100% - 6rem);
}
.mobile-topbar .docrev-brand-product {
    margin-left: auto;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(161, 238, 201, 0.9);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(11, 49, 58, 0.45);
    border: none;
    padding: 0;
    cursor: pointer;
}
body.nav-drawer-open { overflow: hidden; }

.telehealth-grid {
    display: flex;
    gap: 1rem;
    height: 320px;
    margin-bottom: 1rem;
}
.telehealth-chat {
    width: 280px;
    flex-shrink: 0;
}
.telehealth-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    border-top: 1px solid #4a6b72;
    padding-top: 1rem;
}
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1200px) {
    .layout-grid--2,
    .layout-grid--aside,
    .layout-grid--main-aside {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 1100px) {
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    .main {
        padding: 1.25rem 1.15rem;
    }
    .layout-grid--mailbox {
        grid-template-columns: minmax(0, 1fr);
        min-height: auto;
    }
}

@media (max-width: 900px) {
    .mobile-topbar { display: flex; }

    .sidebar {
        width: min(288px, 86vw);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: none;
    }
    .sidebar.sidebar--open {
        transform: translateX(0);
        box-shadow: 16px 0 40px rgba(11, 49, 58, 0.35);
    }
    .layout.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .main {
        margin-left: 0;
        padding: 1rem 0.85rem 1.5rem;
        width: 100%;
        max-width: 100vw;
    }

    .wrap {
        max-width: 100%;
        padding: 0;
    }

    .portal-topbar__inner,
    .portal-tabs__inner,
    .portal-main {
        padding-left: 0.9rem;
        padding-right: 0.9rem;
    }
    .portal-user { display: none; }
    .portal-quick {
        grid-template-columns: 1fr;
    }
    .portal-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    .portal-hero {
        padding: 1.2rem 1.15rem;
    }
    .portal-hero__title { font-size: 1.3rem; }

    .card, .panel, .panel-section, .portal-card {
        padding: 1rem;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }
    .stat { padding: 0.9rem 0.85rem; }
    .stat .num { font-size: 1.35rem; }

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

    .filter-bar .form-group {
        flex: 1 1 100%;
    }
    .filter-bar .form-group select,
    .filter-bar .form-group input:not([type="checkbox"]) {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .row-between {
        align-items: flex-start;
    }

    .login-card {
        padding: 1.5rem 1.2rem;
        width: 100%;
    }
    .brand-logo--light { width: 170px; }

    .telehealth-grid {
        flex-direction: column !important;
        height: auto !important;
    }
    .telehealth-grid > div {
        width: 100% !important;
        min-height: 200px;
    }
    .telehealth-chat {
        width: 100% !important;
        height: 240px;
        min-height: 240px;
    }
    .telehealth-controls {
        gap: 0.5rem;
    }
    .telehealth-controls .btn {
        flex: 1 1 auto;
    }

    .panel > div[style*="justify-content:space-between"] {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .toast {
        position: sticky;
        top: 3.4rem;
        z-index: 80;
    }
}

@media (max-width: 560px) {
    .stats {
        grid-template-columns: 1fr;
    }
    .portal-quick {
        grid-template-columns: 1fr;
    }
    .actions .btn,
    .row-between .btn {
        width: 100%;
        justify-content: center;
    }
    .mobile-topbar .docrev-brand-product {
        display: none;
    }
    th, td {
        padding: 0.5rem 0.55rem;
        font-size: 0.8125rem;
    }
    h2 { font-size: 1.05rem; }
}