/* ===== GutCode Practitioner Portal ===== */
/* All classes scoped under .portal-app to prevent conflicts with main site */

:root {
    --p-accent: #22c55e;
    --p-accent-dark: #16a34a;
    --p-accent-light: #dcfce7;
    --p-accent-subtle: #f0fdf4;
    --p-primary: #111827;
    --p-gray-50: #f9fafb;
    --p-gray-100: #f3f4f6;
    --p-gray-200: #e5e7eb;
    --p-gray-300: #d1d5db;
    --p-gray-400: #9ca3af;
    --p-gray-500: #6b7280;
    --p-gray-600: #4b5563;
    --p-gray-700: #374151;
    --p-gray-900: #111827;
    --p-radius: 16px;
    --p-radius-lg: 24px;
    --p-radius-full: 100px;
    --p-sidebar-bg: #1a1a2e;
    --p-sidebar-w: 240px;
    --p-topnav-h: 60px;
}

/* ===== RESET & BASE ===== */
.portal-app {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--p-gray-900);
    margin: 0; padding: 0;
    min-height: 100vh;
    background: var(--p-gray-50);
    -webkit-font-smoothing: antialiased;
}
.portal-app *, .portal-app *::before, .portal-app *::after { box-sizing: border-box; margin: 0; padding: 0; }
.portal-app a { color: inherit; text-decoration: none; }
.portal-app button { cursor: pointer; font-family: inherit; }
.portal-app input, .portal-app select { font-family: inherit; }

/* ===== VIEW MANAGEMENT ===== */
.portal-view { display: none; }
.portal-view.active { display: flex; }
.portal-view-fade { animation: portalFadeIn 0.2s ease; }
@keyframes portalFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== LOGIN VIEW ===== */
.portal-login {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: var(--p-gray-50);
    padding: 24px;
}
.portal-login-card {
    width: 100%; max-width: 480px;
    background: #fff;
    border-radius: var(--p-radius-lg);
    padding: 48px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    border: 1px solid var(--p-gray-100);
}
.portal-login-logo { display: block; height: 32px; margin: 0 auto 20px; }
.portal-login-label {
    text-align: center;
    font-size: 0.8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--p-accent); margin-bottom: 24px;
}
.portal-login-heading {
    text-align: center; font-size: 1.5rem; font-weight: 700;
    color: var(--p-gray-900); margin-bottom: 32px;
}

/* Form fields */
.portal-field { margin-bottom: 18px; }
.portal-field label {
    display: block; font-size: 0.88rem; font-weight: 600;
    color: var(--p-gray-700); margin-bottom: 6px;
}
.portal-field input {
    width: 100%; padding: 12px 14px;
    border: 1.5px solid var(--p-gray-200); border-radius: 10px;
    font-size: 0.92rem; color: var(--p-gray-900);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.portal-field input:focus {
    outline: none;
    border-color: var(--p-accent);
    box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.portal-field input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

/* Buttons */
.portal-btn-primary {
    width: 100%; padding: 14px 32px;
    background: var(--p-accent); color: #fff;
    border: none; border-radius: var(--p-radius-full);
    font-weight: 600; font-size: 0.95rem;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.portal-btn-primary:hover { background: var(--p-accent-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(34,197,94,0.2); }
.portal-btn-primary:disabled { opacity: 0.6; pointer-events: none; }
.portal-btn-primary .spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: portalSpin 0.6s linear infinite; }

.portal-btn-google {
    width: 100%; padding: 13px 32px;
    background: #fff; color: var(--p-gray-700);
    border: 1.5px solid var(--p-gray-200); border-radius: var(--p-radius-full);
    font-weight: 600; font-size: 0.95rem;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.portal-btn-google:hover { border-color: var(--p-gray-300); background: var(--p-gray-50); }
.portal-btn-google svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Divider */
.portal-divider {
    display: flex; align-items: center; gap: 16px;
    margin: 24px 0; color: var(--p-gray-400); font-size: 0.85rem;
}
.portal-divider::before, .portal-divider::after { content: ''; flex: 1; height: 1px; background: var(--p-gray-200); }

/* Error & links */
.portal-error { color: #dc2626; font-size: 0.85rem; margin-top: 16px; text-align: center; display: none; }
.portal-error.visible { display: block; }
.portal-login-footer {
    margin-top: 32px; text-align: center; font-size: 0.85rem; color: var(--p-gray-500);
}
.portal-login-footer a { color: var(--p-accent-dark); font-weight: 500; }
.portal-login-footer a:hover { text-decoration: underline; }
.portal-login-bottom {
    margin-top: 24px; text-align: center;
    font-size: 0.78rem; color: var(--p-gray-400);
}
.portal-login-bottom a { color: var(--p-gray-400); }
.portal-login-bottom a:hover { color: var(--p-gray-500); }

@keyframes portalSpin { to { transform: rotate(360deg); } }

/* ===== ACCESS PENDING VIEW ===== */
.portal-pending {
    min-height: 100vh; align-items: center; justify-content: center;
    background: var(--p-gray-50); padding: 24px; flex-direction: column; text-align: center;
}
.portal-pending-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--p-accent-light);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 24px;
}
.portal-pending-icon svg { width: 28px; height: 28px; color: var(--p-accent-dark); }
.portal-pending h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 12px; }
.portal-pending p { color: var(--p-gray-500); font-size: 0.95rem; max-width: 400px; line-height: 1.6; margin-bottom: 24px; }
.portal-pending a { color: var(--p-gray-400); font-size: 0.85rem; }
.portal-pending a:hover { color: var(--p-accent); }

/* ===== DASHBOARD LAYOUT ===== */
.portal-dashboard { min-height: 100vh; flex-direction: column; }

/* Top nav */
.portal-topnav {
    height: var(--p-topnav-h); width: 100%;
    background: #fff; border-bottom: 1px solid var(--p-gray-100);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; flex-shrink: 0; z-index: 10;
}
.portal-topnav-left { display: flex; align-items: center; gap: 10px; }
.portal-topnav-logo { height: 24px; }
.portal-topnav-label { font-size: 13px; color: var(--p-gray-400); font-weight: 500; }
.portal-topnav-right { position: relative; display: flex; align-items: center; }
.portal-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--p-accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; cursor: pointer;
    transition: box-shadow 0.2s;
}
.portal-avatar:hover { box-shadow: 0 0 0 3px rgba(34,197,94,0.15); }
.portal-lang-toggle {
    display: flex; align-items: center; gap: 0;
    background: var(--p-gray-100); border-radius: 6px;
    padding: 2px; margin-right: 12px; font-size: 0.75rem; font-weight: 600;
}
.portal-lang-btn {
    padding: 4px 10px; border: none; background: none;
    border-radius: 4px; color: var(--p-gray-400);
    font-family: inherit; font-size: 0.75rem; font-weight: 600;
    transition: all 0.15s; cursor: pointer;
}
.portal-lang-btn.active { background: #fff; color: var(--p-gray-900); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.portal-login-lang { justify-content: center; margin-bottom: 8px; }
.portal-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    min-width: 160px; padding: 6px; display: none; z-index: 20;
}
.portal-dropdown.open { display: block; }
.portal-dropdown button {
    width: 100%; padding: 10px 14px; background: none; border: none;
    text-align: left; font-size: 0.88rem; color: var(--p-gray-700);
    border-radius: 8px; transition: background 0.15s;
}
.portal-dropdown button:hover { background: var(--p-gray-50); }

/* Body: sidebar + content */
.portal-body { display: flex; flex: 1; height: calc(100vh - var(--p-topnav-h)); }

/* Sidebar */
.portal-sidebar {
    width: var(--p-sidebar-w); background: var(--p-sidebar-bg);
    padding: 24px 0; display: flex; flex-direction: column;
    flex-shrink: 0; overflow-y: auto;
}
.portal-sidebar-nav { flex: 1; }
.portal-sidebar-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 24px; color: rgba(255,255,255,0.5);
    font-size: 0.9rem; font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s; cursor: pointer; background: none; border-right: none; border-top: none; border-bottom: none;
    width: 100%; text-align: left;
}
.portal-sidebar-item:hover { color: rgba(255,255,255,0.75); background: rgba(255,255,255,0.03); }
.portal-sidebar-item.active {
    color: #fff; border-left-color: var(--p-accent);
    background: rgba(255,255,255,0.05);
}
.portal-sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.portal-sidebar-badge {
    font-size: 0.65rem; font-weight: 600;
    background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.5);
    padding: 2px 8px; border-radius: 100px; margin-left: auto;
}
.portal-sidebar-footer {
    padding: 16px 24px; font-size: 0.68rem; color: rgba(255,255,255,0.25);
}

/* Main content */
.portal-content {
    flex: 1; padding: 40px; overflow-y: auto; background: var(--p-gray-50);
}
.portal-content-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
}
.portal-content-title { font-size: 1.25rem; font-weight: 700; }
.portal-count-badge {
    background: var(--p-accent-light); color: var(--p-accent-dark);
    font-size: 0.78rem; font-weight: 600;
    padding: 4px 12px; border-radius: var(--p-radius-full);
}

/* ===== PATIENT LIST ===== */
.portal-patient-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 20px 24px;
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 12px; transition: box-shadow 0.2s;
}
.portal-patient-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.04); }
.portal-patient-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--p-gray-100); color: var(--p-gray-500);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.78rem; font-weight: 700; flex-shrink: 0;
    text-transform: uppercase;
}
.portal-patient-info { flex: 1; min-width: 0; }
.portal-patient-name { font-size: 0.92rem; font-weight: 600; margin-bottom: 2px; }
.portal-patient-meta { font-size: 0.8rem; color: var(--p-gray-500); display: flex; gap: 12px; flex-wrap: wrap; }
.portal-patient-meta span { display: flex; align-items: center; gap: 4px; }

/* Score badge */
.portal-score-badge {
    padding: 4px 10px; border-radius: var(--p-radius-full);
    font-size: 0.78rem; font-weight: 700; flex-shrink: 0;
}
.portal-score-green { background: #f0fdf4; color: #15803d; }
.portal-score-orange { background: #fff7ed; color: #ea580c; }
.portal-score-red { background: #fef2f2; color: #dc2626; }
.portal-score-gray { background: var(--p-gray-100); color: var(--p-gray-500); }

.portal-btn-view {
    padding: 8px 18px; border: 1.5px solid var(--p-accent);
    border-radius: var(--p-radius-full); background: none;
    color: var(--p-accent-dark); font-size: 0.82rem; font-weight: 600;
    transition: all 0.2s; flex-shrink: 0;
}
.portal-btn-view:hover { background: var(--p-accent-subtle); }

/* ===== EMPTY STATE ===== */
.portal-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center;
    min-height: 60vh; padding: 40px 20px;
}
.portal-empty-icon { margin-bottom: 24px; color: var(--p-accent); }
.portal-empty-icon svg { width: 120px; height: 120px; }
.portal-empty h3 { font-size: 1.25rem; font-weight: 600; color: var(--p-sidebar-bg); margin-bottom: 8px; }
.portal-empty p { color: var(--p-gray-500); font-size: 0.95rem; max-width: 400px; line-height: 1.6; margin-bottom: 32px; }

/* Code card */
.portal-code-card {
    background: #fff; border: 2px solid rgba(34,197,94,0.2);
    border-radius: var(--p-radius-lg); padding: 32px 40px;
    margin-bottom: 40px; text-align: center;
}
.portal-code-label {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--p-gray-400); margin-bottom: 12px;
}
.portal-code-display {
    display: flex; align-items: center; justify-content: center; gap: 12px;
}
.portal-code-value {
    font-size: 2.2rem; font-family: 'SF Mono', 'Fira Code', monospace;
    letter-spacing: 0.25em; color: var(--p-sidebar-bg); font-weight: 700;
}
.portal-code-copy {
    background: none; border: none; color: var(--p-gray-400);
    padding: 8px; border-radius: 8px; transition: all 0.2s;
    position: relative;
}
.portal-code-copy:hover { color: var(--p-gray-600); background: var(--p-gray-50); }
.portal-code-copy svg { width: 20px; height: 20px; }
.portal-code-copy .tooltip {
    position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%); background: var(--p-gray-900);
    color: #fff; font-size: 0.72rem; padding: 4px 10px;
    border-radius: 6px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.portal-code-copy .tooltip.show { opacity: 1; }
.portal-code-hint { font-size: 0.82rem; color: var(--p-gray-400); margin-top: 12px; }

/* How it works cards */
.portal-how-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
    max-width: 720px;
}
.portal-how-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 24px; text-align: center;
}
.portal-how-card svg { width: 32px; height: 32px; color: var(--p-accent); margin-bottom: 12px; }
.portal-how-card h4 { font-size: 0.92rem; font-weight: 600; margin-bottom: 6px; }
.portal-how-card p { font-size: 0.82rem; color: var(--p-gray-500); line-height: 1.5; }

/* ===== PATIENT DETAIL ===== */
.portal-back {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.88rem; color: var(--p-gray-500); font-weight: 500;
    margin-bottom: 20px; cursor: pointer; background: none; border: none;
    transition: color 0.2s;
}
.portal-back:hover { color: var(--p-accent); }
.portal-back svg { width: 16px; height: 16px; }

.portal-detail-header { margin-bottom: 32px; }
.portal-detail-header h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; }
.portal-detail-header p { font-size: 0.85rem; color: var(--p-gray-500); }

.portal-section { margin-bottom: 32px; }
.portal-section-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; color: var(--p-gray-900); }

/* Chart container */
.portal-chart-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 24px;
}
.portal-chart-card canvas { width: 100% !important; max-height: 280px; }

/* Trigger pills */
.portal-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: var(--p-radius-full);
    font-size: 0.82rem; font-weight: 600; margin: 0 6px 8px 0;
    border: 1px solid;
}
.portal-pill-confirmed { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.portal-pill-likely { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.portal-pill-emerging { background: #fefce8; color: #854d0e; border-color: #fef08a; }
.portal-pill-safe { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

.portal-no-data { color: var(--p-gray-400); font-size: 0.88rem; font-style: italic; }

/* Clinical profile card */
.portal-profile-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.portal-profile-item label {
    display: block; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--p-gray-400); margin-bottom: 4px;
}
.portal-profile-item span { font-size: 0.92rem; font-weight: 500; }

/* ===== SKELETON LOADING ===== */
.portal-skeleton {
    background: linear-gradient(90deg, var(--p-gray-100) 25%, var(--p-gray-50) 50%, var(--p-gray-100) 75%);
    background-size: 200% 100%;
    animation: portalShimmer 1.5s infinite;
    border-radius: 10px;
}
.portal-skeleton-card {
    height: 80px; margin-bottom: 12px; border-radius: var(--p-radius);
}
@keyframes portalShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== RECOMMENDATIONS ===== */
.portal-rec-desc {
    font-size: 0.85rem; color: var(--p-gray-500);
    margin-bottom: 16px; line-height: 1.5;
}
.portal-rec-compose {
    background: #fff; border: 1px solid var(--p-gray-200);
    border-radius: var(--p-radius); margin-bottom: 20px;
    overflow: hidden;
}
.portal-rec-textarea {
    width: 100%; min-height: 100px; max-height: 200px;
    padding: 16px; border: none; resize: vertical;
    font-family: inherit; font-size: 0.92rem;
    color: var(--p-gray-900); line-height: 1.5;
    box-sizing: border-box;
}
.portal-rec-textarea:focus { outline: none; }
.portal-rec-textarea::placeholder { color: var(--p-gray-400); }
.portal-rec-compose-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-top: 1px solid var(--p-gray-100);
    background: var(--p-gray-50);
}
.portal-rec-charcount {
    font-size: 0.78rem; color: var(--p-gray-400);
    font-variant-numeric: tabular-nums;
}
.portal-btn-send {
    padding: 8px 20px; background: var(--p-accent); color: #fff;
    border: none; border-radius: var(--p-radius-full); cursor: pointer;
    font-weight: 600; font-size: 0.85rem; transition: all 0.2s;
}
.portal-btn-send:hover { background: var(--p-accent-dark); }
.portal-btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.portal-rec-list { display: flex; flex-direction: column; gap: 12px; }
.portal-rec-item {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 16px 20px;
    position: relative;
}
.portal-rec-text {
    font-size: 0.92rem; line-height: 1.6;
    color: var(--p-gray-900); white-space: pre-wrap;
    word-break: break-word;
}
.portal-rec-meta {
    display: flex; align-items: center; gap: 12px;
    margin-top: 10px; font-size: 0.78rem; color: var(--p-gray-400);
}
.portal-rec-status {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: var(--p-radius-full);
    font-size: 0.72rem; font-weight: 600;
}
.portal-rec-status-read { background: #f0fdf4; color: #15803d; }
.portal-rec-status-sent { background: var(--p-gray-100); color: var(--p-gray-500); }
.portal-rec-delete {
    position: absolute; top: 12px; right: 12px;
    background: none; border: none; color: var(--p-gray-300);
    cursor: pointer; padding: 4px; border-radius: 6px; transition: all 0.15s;
}
.portal-rec-delete:hover { color: #dc2626; background: #fef2f2; }
.portal-rec-delete svg { width: 16px; height: 16px; }

/* ===== TOAST ===== */
.portal-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--p-gray-900); color: #fff;
    padding: 12px 24px; border-radius: var(--p-radius-full);
    font-size: 0.88rem; font-weight: 500;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 100;
}
.portal-toast.visible {
    opacity: 1; pointer-events: auto;
    transform: translateX(-50%) translateY(-8px);
}

/* ===== MODAL ===== */
.portal-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    display: none; align-items: center; justify-content: center;
    z-index: 90;
}
.portal-modal-overlay.visible { display: flex; }
.portal-modal-card {
    background: #fff; border-radius: var(--p-radius-lg);
    padding: 32px; max-width: 400px; width: 90%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}
.portal-modal-card h3 {
    font-size: 1rem; font-weight: 700; margin-bottom: 8px;
}
.portal-modal-card p {
    font-size: 0.88rem; color: var(--p-gray-500); line-height: 1.5;
    margin-bottom: 24px; min-height: 1px;
}
.portal-modal-actions { display: flex; gap: 12px; justify-content: flex-end; }
.portal-modal-cancel {
    padding: 10px 20px; background: var(--p-gray-100); color: var(--p-gray-700);
    border: none; border-radius: var(--p-radius-full);
    font-weight: 600; font-size: 0.88rem; transition: background 0.15s;
}
.portal-modal-cancel:hover { background: var(--p-gray-200); }
.portal-modal-confirm {
    padding: 10px 20px; background: #dc2626; color: #fff;
    border: none; border-radius: var(--p-radius-full);
    font-weight: 600; font-size: 0.88rem; transition: background 0.15s;
}
.portal-modal-confirm:hover { background: #b91c1c; }

/* ===== SEARCH BAR ===== */
.portal-search-bar {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--p-gray-200);
    border-radius: var(--p-radius); padding: 10px 16px;
    margin-bottom: 20px; transition: border-color 0.2s;
}
.portal-search-bar:focus-within { border-color: var(--p-accent); }
.portal-search-bar svg { width: 18px; height: 18px; color: var(--p-gray-400); flex-shrink: 0; }
.portal-search-bar input {
    border: none; outline: none; flex: 1;
    font-size: 0.92rem; color: var(--p-gray-900);
    background: transparent; font-family: inherit;
}
.portal-search-bar input::placeholder { color: var(--p-gray-400); }

/* ===== SCORE TREND ===== */
.portal-score-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.portal-score-trend {
    font-size: 0.85rem; font-weight: 700; line-height: 1;
}
.portal-score-trend-up { color: #15803d; }
.portal-score-trend-down { color: #dc2626; }
.portal-score-trend-stable { color: var(--p-gray-400); }

/* ===== SETTINGS ===== */
.portal-settings-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius-lg); padding: 32px;
    margin-bottom: 24px;
}
.portal-settings-section-title {
    font-size: 1rem; font-weight: 700; margin-bottom: 24px;
    color: var(--p-gray-900);
}
.portal-settings-field { margin-bottom: 20px; }
.portal-settings-field label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--p-gray-600); margin-bottom: 6px;
}
.portal-settings-field input,
.portal-settings-field select {
    width: 100%; max-width: 400px; padding: 12px 14px;
    border: 1.5px solid var(--p-gray-200); border-radius: 10px;
    font-size: 0.92rem; color: var(--p-gray-900); background: #fff;
    transition: border-color 0.2s;
}
.portal-settings-field input:focus,
.portal-settings-field select:focus {
    outline: none; border-color: var(--p-accent);
    box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.portal-settings-save { max-width: 200px; margin-top: 8px; }
.portal-btn-secondary {
    padding: 10px 20px; background: var(--p-gray-100); color: var(--p-gray-700);
    border: none; border-radius: var(--p-radius-full);
    font-weight: 600; font-size: 0.85rem; transition: all 0.2s; cursor: pointer;
}
.portal-btn-secondary:hover { background: var(--p-gray-200); }

/* ===== WELCOME OVERLAY ===== */
.portal-welcome-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 95;
}
.portal-welcome-overlay.visible { display: flex; }
.portal-welcome-card {
    background: #fff; border-radius: var(--p-radius-lg);
    padding: 40px; max-width: 480px; width: 90%;
    text-align: center; box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}
.portal-welcome-card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 12px; }
.portal-welcome-card p { font-size: 0.92rem; color: var(--p-gray-500); line-height: 1.6; margin-bottom: 24px; }

/* ===== ALERTS BANNER ===== */
.portal-alerts-banner { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.portal-alert {
    flex: 1; min-width: 180px;
    padding: 12px 16px; border-radius: var(--p-radius);
    font-size: 0.85rem; font-weight: 500;
}
.portal-alert strong { font-weight: 700; }
.portal-alert-red { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.portal-alert-orange { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.portal-alert-green { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ===== PATIENT SUMMARY CARD ===== */
.portal-summary-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 16px 20px;
    margin-bottom: 20px; display: flex; gap: 24px; flex-wrap: wrap;
}
.portal-summary-item { font-size: 0.88rem; font-weight: 500; }
.portal-summary-good { color: #15803d; }
.portal-summary-bad { color: #dc2626; }
.portal-summary-neutral { color: var(--p-gray-500); }

/* ===== KEY METRICS ROW ===== */
.portal-metrics-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    margin-bottom: 24px;
}
.portal-metric-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 16px; text-align: center;
}
.portal-metric-value {
    font-size: 1.5rem; font-weight: 800; margin-bottom: 4px;
    color: var(--p-gray-900);
}
.portal-metric-sub { font-size: 0.85rem; font-weight: 500; color: var(--p-gray-400); }
.portal-metric-label { font-size: 0.75rem; font-weight: 600; color: var(--p-gray-400); text-transform: uppercase; letter-spacing: 0.04em; }

/* ===== DATE RANGE TOGGLE ===== */
.portal-range-toggle {
    display: inline-flex; gap: 0; background: var(--p-gray-100);
    border-radius: 6px; padding: 2px; margin-left: 12px;
    vertical-align: middle;
}
.portal-range-btn {
    padding: 4px 10px; border: none; background: none;
    border-radius: 4px; color: var(--p-gray-400);
    font-family: inherit; font-size: 0.75rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.portal-range-btn.active { background: #fff; color: var(--p-gray-900); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* ===== STATUS TAGS ===== */
.portal-status-tag {
    display: inline-block; padding: 2px 8px; border-radius: var(--p-radius-full);
    font-size: 0.68rem; font-weight: 700; margin-left: 8px;
    vertical-align: middle;
}
.portal-status-red { background: #fef2f2; color: #dc2626; }
.portal-status-orange { background: #fff7ed; color: #c2410c; }
.portal-status-yellow { background: #fefce8; color: #854d0e; }
.portal-status-green { background: #f0fdf4; color: #15803d; }
.portal-status-blue { background: #eff6ff; color: #2563eb; }

/* ===== LIST TOOLBAR (search + sort) ===== */
.portal-list-toolbar {
    display: flex; gap: 12px; align-items: center; margin-bottom: 20px;
}
.portal-sort-select {
    padding: 10px 14px; border: 1px solid var(--p-gray-200);
    border-radius: var(--p-radius); background: #fff;
    font-size: 0.88rem; color: var(--p-gray-700);
    font-family: inherit; cursor: pointer; min-width: 160px;
}

/* ===== TEMPLATES ===== */
.portal-templates {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    margin-bottom: 12px;
}
.portal-templates-label {
    font-size: 0.78rem; color: var(--p-gray-400); font-weight: 600;
}
.portal-template-btn {
    padding: 4px 10px; background: var(--p-gray-50);
    border: 1px solid var(--p-gray-200); border-radius: var(--p-radius-full);
    font-size: 0.72rem; color: var(--p-gray-600);
    font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.portal-template-btn:hover { background: var(--p-accent-subtle); border-color: var(--p-accent); color: var(--p-accent-dark); }

/* ===== DETAIL HEADER ACTIONS ===== */
.portal-detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 32px; }
.portal-detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===== TRIGGER BAR (reports) ===== */
.portal-trigger-bar {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.portal-trigger-name { font-size: 0.88rem; font-weight: 500; min-width: 120px; }
.portal-trigger-bar-track {
    flex: 1; height: 8px; background: var(--p-gray-100);
    border-radius: 4px; overflow: hidden;
}
.portal-trigger-bar-fill { height: 100%; background: var(--p-accent); border-radius: 4px; transition: width 0.3s; }
.portal-trigger-count { font-size: 0.78rem; color: var(--p-gray-400); min-width: 80px; text-align: right; }

/* ===== HEALTH DATA GRID ===== */
.portal-health-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
    margin-bottom: 32px;
}
.portal-health-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 20px;
    margin-bottom: 0;
}
.portal-progress-display { text-align: center; margin-bottom: 16px; }
.portal-progress-big {
    font-size: 2rem; font-weight: 800; color: var(--p-gray-900);
}
.portal-progress-sub { font-size: 0.85rem; font-weight: 500; color: var(--p-gray-400); }
.portal-progress-bar {
    height: 8px; background: var(--p-gray-100);
    border-radius: 4px; overflow: hidden; margin-top: 8px;
}
.portal-progress-fill {
    height: 100%; background: var(--p-accent); border-radius: 4px;
    transition: width 0.5s ease;
}
.portal-progress-blue { background: #3b82f6; }
.portal-progress-orange { background: #f59e0b; }
.portal-progress-red { background: #ef4444; }
.portal-plant-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.portal-health-hint {
    font-size: 0.78rem; font-style: italic; margin-top: 6px;
}
.portal-hint-red { color: #dc2626; }
.portal-hint-orange { color: #c2410c; }
.portal-hint-green { color: #15803d; }

/* Bristol Scale Legend */
.portal-bristol-legend {
    display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.portal-bristol-item {
    font-size: 0.78rem; font-weight: 500; padding: 4px 12px;
    border-radius: var(--p-radius-full);
}
.portal-bristol-item span { font-weight: 700; }
.portal-bristol-bad { background: #fff7ed; color: #c2410c; }
.portal-bristol-good { background: #f0fdf4; color: #15803d; }
.portal-bristol-bad2 { background: #fef2f2; color: #dc2626; }
.portal-health-stat { }
.portal-health-stat label {
    display: block; font-size: 0.82rem; font-weight: 600;
    color: var(--p-gray-500); margin-bottom: 6px;
}
.portal-health-stat span {
    display: block; font-size: 0.82rem; color: var(--p-gray-500); margin-top: 4px;
}

/* ===== FODMAP ANALYSIS ===== */
.portal-fodmap-card {
    background: #fff; border: 1px solid var(--p-gray-100);
    border-radius: var(--p-radius); padding: 16px 20px;
    margin-bottom: 12px;
}
.portal-fodmap-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.portal-fodmap-icon { font-size: 1.2rem; }
.portal-fodmap-header strong { font-size: 0.95rem; }
.portal-fodmap-count {
    font-size: 0.78rem; color: var(--p-gray-400); margin-left: auto;
}
.portal-fodmap-foods { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.portal-fodmap-hint {
    font-size: 0.8rem; color: var(--p-accent-dark); font-style: italic;
}

/* ===== RISK BADGE ===== */
.portal-risk-badge {
    padding: 2px 8px; border-radius: var(--p-radius-full);
    font-size: 0.68rem; font-weight: 700;
}
.portal-risk-low { background: #f0fdf4; color: #15803d; }
.portal-risk-medium { background: #fff7ed; color: #c2410c; }
.portal-risk-high { background: #fef2f2; color: #dc2626; }

/* ===== PATIENT COMPARISON ===== */
.portal-comparison { margin-top: 20px; }
.portal-compare-table {
    width: 100%; border-collapse: collapse; margin-bottom: 20px;
    background: #fff; border-radius: var(--p-radius); overflow: hidden;
    border: 1px solid var(--p-gray-100);
}
.portal-compare-table th, .portal-compare-table td {
    padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--p-gray-100);
    font-size: 0.88rem;
}
.portal-compare-table th {
    background: var(--p-gray-50); font-weight: 700; font-size: 0.82rem;
    color: var(--p-gray-600); text-transform: uppercase; letter-spacing: 0.04em;
}
.portal-compare-table td:first-child {
    font-weight: 600; color: var(--p-gray-500); font-size: 0.82rem;
}
.portal-compare-table tr:last-child td { border-bottom: none; }
.portal-compare-section { margin-bottom: 16px; }
.portal-compare-section strong { font-size: 0.85rem; display: block; margin-bottom: 8px; }
.portal-compare-pills { display: flex; flex-wrap: wrap; gap: 6px; }

/* ===== PRINT STYLES ===== */
@media print {
    .portal-sidebar, .portal-topnav, .portal-toast, .portal-modal-overlay,
    .portal-welcome-overlay, .portal-back, .portal-rec-compose,
    .portal-rec-delete, .portal-templates, .portal-detail-actions,
    .portal-range-toggle, .portal-btn-send { display: none !important; }
    .portal-content { padding: 0 !important; }
    .portal-body { display: block !important; }
    .portal-chart-card canvas { max-height: none !important; }
    .portal-dashboard { min-height: auto !important; }
    .portal-section { page-break-inside: avoid; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .portal-how-grid { grid-template-columns: 1fr; }
    .portal-profile-grid { grid-template-columns: 1fr; }
    .portal-metrics-row { grid-template-columns: repeat(2, 1fr); }
    .portal-health-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .portal-sidebar { display: none; }
    .portal-content { padding: 24px 16px; }
    .portal-login-card { padding: 32px 24px; }
    .portal-patient-card { flex-wrap: wrap; }
    .portal-patient-meta { flex-direction: column; gap: 4px; }
    .portal-code-value { font-size: 1.6rem; }
    .portal-code-card { padding: 24px 20px; }
    .portal-rec-compose-footer { flex-direction: column; gap: 8px; align-items: stretch; }
    .portal-btn-send { width: 100%; text-align: center; }
    .portal-rec-textarea { font-size: 16px; }
    .portal-metrics-row { grid-template-columns: repeat(2, 1fr); }
    .portal-list-toolbar { flex-direction: column; }
    .portal-sort-select { width: 100%; }
    .portal-alerts-banner { flex-direction: column; }
    .portal-detail-header { flex-direction: column; gap: 12px; }
    .portal-detail-actions { width: 100%; }
    .portal-detail-actions button { flex: 1; }
    .portal-templates { gap: 6px; }
}
