
    /* ═══════════════════════════════════════════════════════
       NUTRIAPP — Design System v3
       Modern SaaS · Inter · Stripe/Linear-inspired
    ═══════════════════════════════════════════════════════ */

    @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700&display=swap');

    :root {
        /* ── Brand ── */
        --primary:          #0D9488;
        --primary-hover:    #0F766E;
        --primary-ring:     rgba(13, 148, 136, 0.15);
        --primary-subtle:   #F0FDFA;

        /* ── Surfaces ── */
        --bg:               #F9FAFB;
        --surface:          #FFFFFF;
        --surface-hover:    #F9FAFB;
        --surface-raised:   #FFFFFF;

        /* ── Sidebar ── */
        --sidebar-bg:       #FFFFFF;
        --sidebar-border:   #E5E7EB;
        --sidebar-item:     #6B7280;
        --sidebar-hover-bg: #F3F4F6;
        --sidebar-active-bg:#F0FDFA;
        --sidebar-active:   #0D9488;

        /* ── Text ── */
        --text:             #111827;
        --text-secondary:   #6B7280;
        --text-tertiary:    #9CA3AF;
        --text-disabled:    #D1D5DB;

        /* ── Borders ── */
        --border:           #E5E7EB;
        --border-strong:    #D1D5DB;

        /* ── Feedback ── */
        --error:            #E53E3E;
        --error-bg:         #FFF5F5;
        --error-border:     #FED7D7;
        --success:          #0D9488;
        --success-bg:       #F0FDFA;
        --success-border:   #99F6E4;
        --warning:          #B45309;
        --warning-bg:       #FEFCE8;
        --warning-border:   #FDE68A;
        --info-bg:          #F0F9FF;
        --info-border:      #BAE6FD;
        --info-text:        #0369A1;

        /* ── Shadows ── */
        --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
        --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
        --shadow-lg: 0 10px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
        --shadow-xl: 0 20px 40px rgba(0,0,0,0.10), 0 8px 16px rgba(0,0,0,0.06);

        /* ── Radius ── */
        --r-sm:  6px;
        --r-md:  8px;
        --r-lg:  12px;
        --r-xl:  16px;
        --r-2xl: 20px;

        /* ── Motion ── */
        --ease: cubic-bezier(0.4, 0, 0.2, 1);
        --t:    150ms;
    }

    /* ══ DARK MODE ══════════════════════════════════════ */
    [data-theme="dark"] {
        --primary:          #14B8A6;
        --primary-hover:    #0D9488;
        --primary-ring:     rgba(20, 184, 166, 0.20);
        --primary-subtle:   #134E4A;

        --bg:               #0F172A;
        --surface:          #1E293B;
        --surface-hover:    #263448;
        --surface-raised:   #1E293B;

        --sidebar-bg:       #1E293B;
        --sidebar-border:   #334155;
        --sidebar-item:     #94A3B8;
        --sidebar-hover-bg: #263448;
        --sidebar-active-bg:#134E4A;
        --sidebar-active:   #14B8A6;

        --text:             #F1F5F9;
        --text-secondary:   #94A3B8;
        --text-tertiary:    #64748B;
        --text-disabled:    #475569;

        --border:           #334155;
        --border-strong:    #475569;

        --error:            #FC8181;
        --error-bg:         #2D1515;
        --error-border:     #7F1D1D;
        --success:          #14B8A6;
        --success-bg:       #134E4A;
        --success-border:   #0F766E;
        --warning:          #FBD38D;
        --warning-bg:       #2D1E00;
        --warning-border:   #92400E;
        --info-bg:          #1E3A5F;
        --info-border:      #1D4ED8;
        --info-text:        #93C5FD;

        --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
        --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.25);
        --shadow-lg: 0 10px 24px rgba(0,0,0,0.4), 0 4px 8px rgba(0,0,0,0.3);
        --shadow-xl: 0 20px 40px rgba(0,0,0,0.5), 0 8px 16px rgba(0,0,0,0.4);
    }

    /* Dark mode: general overrides for hardcoded colors in dynamic HTML */
    [data-theme="dark"] input,
    [data-theme="dark"] select,
    [data-theme="dark"] textarea {
        background: var(--surface) !important;
        color: var(--text) !important;
        border-color: var(--border) !important;
    }

    /* ── Autofill do browser no tema escuro ──────────────────────
       O Chrome/Edge aplica fundo branco no :-webkit-autofill que
       não pode ser sobrescrito via background. O truque é usar
       box-shadow inset para cobrir o fundo e transition longa
       para atrasar a cor de texto do browser. */
    [data-theme="dark"] input:-webkit-autofill,
    [data-theme="dark"] input:-webkit-autofill:hover,
    [data-theme="dark"] input:-webkit-autofill:focus,
    [data-theme="dark"] input:-webkit-autofill:active,
    [data-theme="dark"] select:-webkit-autofill,
    [data-theme="dark"] textarea:-webkit-autofill {
        -webkit-box-shadow: 0 0 0px 1000px #1E293B inset !important;
        box-shadow: 0 0 0px 1000px #1E293B inset !important;
        -webkit-text-fill-color: #F1F5F9 !important;
        caret-color: #F1F5F9 !important;
        border-color: var(--border) !important;
        transition: background-color 5000s ease-in-out 0s;
    }

    /* Autofill no tema claro — garante consistência */
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    input:-webkit-autofill:active,
    select:-webkit-autofill,
    textarea:-webkit-autofill {
        -webkit-box-shadow: 0 0 0px 1000px #FFFFFF inset !important;
        box-shadow: 0 0 0px 1000px #FFFFFF inset !important;
        -webkit-text-fill-color: #111827 !important;
        caret-color: #111827 !important;
        transition: background-color 5000s ease-in-out 0s;
    }

    /* Labels with white pill background (checkbox filters) */
    [data-theme="dark"] label[style*="background:white"],
    [data-theme="dark"] label[style*="background: white"],
    [data-theme="dark"] label[style*="background:#fff"],
    [data-theme="dark"] select[style*="background:white"],
    [data-theme="dark"] select[style*="background: white"] {
        background: var(--surface-hover) !important;
        border-color: var(--border) !important;
        color: var(--text) !important;
    }

    /* Modals and overlays with white background */
    [data-theme="dark"] [style*="background:white"],
    [data-theme="dark"] [style*="background: white"],
    [data-theme="dark"] [style*="background:#fff"],
    [data-theme="dark"] [style*="background: #fff"],
    [data-theme="dark"] [style*="background:#FFFFFF"],
    [data-theme="dark"] [style*="background: #FFFFFF"] {
        background: var(--surface) !important;
    }

    /* Light gray backgrounds used as secondary surface */
    [data-theme="dark"] [style*="background:#F9FAFB"],
    [data-theme="dark"] [style*="background: #F9FAFB"],
    [data-theme="dark"] [style*="background:#f9fafb"],
    [data-theme="dark"] [style*="background:#f3f4f6"],
    [data-theme="dark"] [style*="background: #f3f4f6"],
    [data-theme="dark"] [style*="background:#F3F4F6"],
    [data-theme="dark"] [style*="background:#F0FDFA"],
    [data-theme="dark"] [style*="background:#EFF6FF"],
    [data-theme="dark"] [style*="background:#FFF5F5"],
    [data-theme="dark"] [style*="background:#FFFAF0"],
    [data-theme="dark"] [style*="background:#EBF8FF"],
    [data-theme="dark"] [style*="background:#fafafa"],
    [data-theme="dark"] [style*="background:#FAFAFA"],
    [data-theme="dark"] [style*="background:#F0FDF4"],
    [data-theme="dark"] [style*="background:#fefce8"],
    [data-theme="dark"] [style*="background:#FFFBEB"],
    [data-theme="dark"] [style*="background:#FEF3C7"],
    [data-theme="dark"] [style*="background:#D1FAE5"],
    [data-theme="dark"] [style*="background:#DBEAFE"],
    [data-theme="dark"] [style*="background:#FEE2E2"] {
        background: var(--surface-hover) !important;
    }

    /* Text that's dark on light background */
    [data-theme="dark"] [style*="color:#111827"],
    [data-theme="dark"] [style*="color: #111827"],
    [data-theme="dark"] [style*="color:#1F2937"],
    [data-theme="dark"] [style*="color:#374151"] {
        color: var(--text) !important;
    }

    [data-theme="dark"] [style*="color:#6B7280"],
    [data-theme="dark"] [style*="color:#6b7280"],
    [data-theme="dark"] [style*="color:#9CA3AF"],
    [data-theme="dark"] [style*="color:#9ca3af"] {
        color: var(--text-secondary) !important;
    }

    /* Borders */
    [data-theme="dark"] [style*="border:1px solid #E5E7EB"],
    [data-theme="dark"] [style*="border: 1px solid #E5E7EB"],
    [data-theme="dark"] [style*="border-bottom:1px solid #E5E7EB"],
    [data-theme="dark"] [style*="border-color:#E5E7EB"] {
        border-color: var(--border) !important;
    }

    /* Modal dialog backgrounds specifically */
    [data-theme="dark"] #legalModal > div {
        background: var(--surface) !important;
    }
    [data-theme="dark"] #legalModal [style*="background:white"] {
        background: var(--surface-hover) !important;
    }

    /* Chart.js canvas - keep as-is, charts handle their own colors */
    [data-theme="dark"] canvas { filter: brightness(0.92); }

    /* Dark mode toggle button */
    #darkModeToggle {
        background: none;
        border: 1px solid var(--border);
        border-radius: 6px;
        cursor: pointer;
        width: calc(100% - 20px);
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        color: var(--sidebar-item);
        font-size: 12.5px;
        font-weight: 500;
        font-family: inherit;
        margin: 0 10px 6px;
        padding: 0 10px;
        overflow: hidden;
        transition: background var(--t), color var(--t), border-color var(--t);
        white-space: nowrap;
        position: relative;
        flex-shrink: 0;
    }
    #darkModeToggle:hover { background: var(--sidebar-hover-bg); color: var(--text); border-color: var(--border-strong); }
    #dmIcon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
    #dmIcon svg { width: 15px; height: 15px; stroke: currentColor; }
    .btn-logout .nav-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
    .btn-logout .nav-icon svg { width: 15px; height: 15px; stroke: currentColor; }
    .sidebar.collapsed #darkModeToggle { justify-content: center; gap: 0; padding: 0; width: calc(100% - 20px); }
    .sidebar.collapsed #darkModeToggle .dm-label { opacity: 0; width: 0; overflow: hidden; }
    .sidebar.collapsed #darkModeToggle:hover::after {
        content: attr(data-tip);
        position: absolute;
        left: 56px;
        background: #1F2937;
        color: white;
        font-size: 12px;
        padding: 4px 10px;
        border-radius: 6px;
        white-space: nowrap;
        z-index: 200;
        pointer-events: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }

    /* ── Reset ─────────────────────────────────────────── */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    body {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        background: var(--bg);
        color: var(--text);
        line-height: 1.5;
        font-size: 14px;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* ── Scrollbar ─────────────────────────────────────── */
    ::-webkit-scrollbar { width: 5px; height: 5px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

    /* ═══════════════════════════════════════════════════
       LOGIN
    ═══════════════════════════════════════════════════ */
    .login-container {
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
        background: var(--bg);
    }

    .login-box {
        background: var(--surface);
        padding: 40px;
        border-radius: var(--r-xl);
        box-shadow: var(--shadow-lg);
        max-width: 400px;
        width: 100%;
        border: 1px solid var(--border);
        animation: fadeUp 0.3s var(--ease) both;
    }

    @keyframes fadeUp {
        from { opacity: 0; transform: translateY(16px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(8px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .logo { text-align: center; margin-bottom: 32px; }

    .logo h1 {
        font-size: 22px;
        font-weight: 700;
        color: var(--text);
        letter-spacing: -0.4px;
        margin-bottom: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .logo p {
        font-size: 14px;
        color: var(--text-secondary);
    }

    /* ═══════════════════════════════════════════════════
       FORMS
    ═══════════════════════════════════════════════════ */
    .form-group { margin-bottom: 16px; }

    .form-group label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        color: var(--text);
        margin-bottom: 6px;
        letter-spacing: 0.01em;
    }

    /* Base input styles — applies broadly */
    .form-group input,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="month"] {
        width: 100%;
        height: 40px;
        padding: 0 12px;
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        font-size: 14px;
        font-family: inherit;
        color: var(--text);
        background: var(--surface);
        outline: none;
        transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
    }

    .form-group input:hover,
    input[type="text"]:hover,
    input[type="email"]:hover,
    input[type="number"]:hover,
    input[type="date"]:hover,
    input[type="time"]:hover {
        border-color: var(--border-strong);
    }

    .form-group input:focus,
    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="password"]:focus,
    input[type="tel"]:focus,
    input[type="number"]:focus,
    input[type="date"]:focus,
    input[type="time"]:focus,
    input[type="month"]:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-ring);
    }

    .form-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        margin-bottom: 16px;
    }

    select {
        width: 100%;
        height: 40px;
        padding: 0 12px;
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        font-size: 14px;
        font-family: inherit;
        color: var(--text);
        background: var(--surface);
        cursor: pointer;
        outline: none;
        transition: border-color var(--t), box-shadow var(--t);
    }

    select:hover { border-color: var(--border-strong); }
    select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-ring);
    }

    textarea {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        font-size: 14px;
        font-family: inherit;
        color: var(--text);
        background: var(--surface);
        resize: vertical;
        min-height: 88px;
        outline: none;
        line-height: 1.6;
        transition: border-color var(--t), box-shadow var(--t);
    }

    textarea:hover { border-color: var(--border-strong); }
    textarea:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-ring);
    }

    /* ═══════════════════════════════════════════════════
       BUTTONS
    ═══════════════════════════════════════════════════ */
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: 40px;
        padding: 0 16px;
        background: var(--primary);
        color: #FFFFFF;
        border: none;
        border-radius: var(--r-md);
        font-size: 14px;
        font-weight: 500;
        font-family: inherit;
        cursor: pointer;
        white-space: nowrap;
        letter-spacing: -0.01em;
        outline: none;
        transition:
            background var(--t) var(--ease),
            box-shadow var(--t) var(--ease),
            transform var(--t) var(--ease);
    }

    .btn:hover {
        background: var(--primary-hover);
        box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    }

    .btn:active { transform: scale(0.98); }

    .btn:focus-visible { box-shadow: 0 0 0 3px var(--primary-ring); }

    .btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
    }

    /* Secondary */
    .btn-secondary {
        background: var(--surface);
        color: var(--text);
        border: 1px solid var(--border);
    }

    .btn-secondary:hover {
        background: var(--surface-hover);
        border-color: var(--border-strong);
        box-shadow: var(--shadow-xs);
    }

    /* Danger */
    .btn-danger { background: #C53030; }
    .btn-danger:hover { background: #9B2C2C; }

    /* Block */
    .btn-block { width: 100%; }

    /* Logout (inside light sidebar) */
    .btn-logout {
        background: transparent;
        color: var(--sidebar-item);
        border: 1px solid var(--border);
        height: 36px;
        font-size: 13px;
        margin: 8px 10px;
        width: calc(100% - 20px);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        overflow: hidden;
        flex-shrink: 0;
        transition: background var(--t), color var(--t), width 0.22s cubic-bezier(0.4,0,0.2,1);
    }

    .btn-logout:hover {
        background: var(--sidebar-hover-bg);
        color: var(--text);
        border-color: var(--border-strong);
        box-shadow: none;
    }

    .sidebar.collapsed .btn-logout .nav-label { opacity: 0; width: 0; overflow: hidden; }
    .sidebar.collapsed .btn-logout { gap: 0; }

    .link-btn {
        background: none;
        border: none;
        color: var(--primary);
        cursor: pointer;
        font-size: 14px;
        font-family: inherit;
        text-decoration: underline;
        text-underline-offset: 2px;
        padding: 0;
        transition: color var(--t);
    }

    .link-btn:hover { color: var(--primary-hover); }

    /* ═══════════════════════════════════════════════════
       DASHBOARD SHELL
    ═══════════════════════════════════════════════════ */
    .dashboard { display: none; min-height: 100vh; }
    .dashboard.active { display: flex; }

    /* ── Sidebar ───────────────────────────────────────── */
    .sidebar {
        width: 240px;
        min-width: 240px;
        background: var(--sidebar-bg);
        border-right: 1px solid var(--sidebar-border);
        position: fixed;
        height: 100vh;
        overflow-x: hidden;
        overflow-y: hidden;
        display: flex;
        flex-direction: column;
        z-index: 100;
        flex-shrink: 0;
        transition: width 0.22s cubic-bezier(0.4,0,0.2,1), min-width 0.22s cubic-bezier(0.4,0,0.2,1);
        box-shadow: 1px 0 0 var(--sidebar-border);
    }

    .sidebar.collapsed {
        width: 60px;
        min-width: 60px;
        overflow: hidden;
    }

    .sidebar-logo {
        padding: 18px 14px 14px;
        border-bottom: 1px solid var(--sidebar-border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        overflow: visible;
        min-height: 62px;
        flex-shrink: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .sidebar-logo h2 {
        font-size: 17px;
        font-weight: 700;
        color: var(--text);
        letter-spacing: -0.3px;
        display: flex;
        align-items: center;
        gap: 8px;
        white-space: nowrap;
        transition: opacity 0.15s;
        overflow: hidden;
        flex: 1;
        min-width: 0;
    }

    .sidebar-logo h2 span { color: var(--primary); }

    /* Quando colapsada: centraliza apenas o botão toggle */
    .sidebar.collapsed .sidebar-logo {
        justify-content: center;
        padding: 18px 0 14px;
    }

    /* Esconde a logo quando colapsada */
    .sidebar.collapsed .sidebar-logo h2 {
        display: none;
    }

    /* Botão toggle SEMPRE visível */
    .sidebar-toggle {
        background: none;
        border: 1px solid var(--border);
        border-radius: 6px;
        cursor: pointer;
        width: 28px;
        height: 28px;
        min-width: 28px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        color: var(--sidebar-item);
        flex-shrink: 0;
        transition: background var(--t), color var(--t);
        position: relative;
        z-index: 10;
    }
    .sidebar-toggle:hover { background: var(--sidebar-hover-bg); color: var(--text); }

    /* Rodapé da sidebar — agrupa botões de tema e sair */
    .sidebar-footer {
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
    }

    #tacoStatus {
        font-size: 11px;
        color: var(--text-tertiary);
        margin-top: 5px;
        padding-left: 2px;
        white-space: nowrap;
        overflow: hidden;
        flex-shrink: 0;
        transition: opacity 0.15s;
    }
    .sidebar.collapsed #tacoStatus { opacity: 0; }

    .sidebar-user {
        margin: 12px 10px 4px;
        padding: 10px 10px;
        background: var(--surface-hover);
        border-radius: var(--r-md);
        border: 1px solid var(--border);
        overflow: hidden;
        flex-shrink: 0;
        transition: opacity 0.15s, margin 0.22s;
        white-space: nowrap;
    }
    .sidebar.collapsed .sidebar-user { opacity: 0; pointer-events: none; margin: 4px 10px; padding: 4px; min-height: 0; }

    .sidebar-user p {
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--text-tertiary);
        margin-bottom: 2px;
    }

    .sidebar-user strong {
        font-size: 12.5px;
        font-weight: 600;
        color: var(--text);
    }

    .nav-menu {
        list-style: none;
        padding: 8px 8px 0;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        min-height: 0;
    }

    .nav-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 10px;
        border-radius: var(--r-md);
        cursor: pointer;
        font-size: 12.5px;
        font-weight: 500;
        letter-spacing: 0.01em;
        color: var(--sidebar-item);
        transition: background var(--t), color var(--t);
        margin-bottom: 1px;
        user-select: none;
        white-space: nowrap;
        overflow: hidden;
        position: relative;
    }

    .nav-item span { font-size: 15px; line-height: 1; flex-shrink: 0; }
    .nav-item .nav-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 16px; height: 16px; }
    .nav-item .nav-icon svg { width: 16px; height: 16px; stroke: currentColor; }
    .nav-item .nav-label { transition: opacity 0.15s; }
    .sidebar.collapsed .nav-item .nav-label { opacity: 0; width: 0; overflow: hidden; }
    .sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; overflow: visible; }
    .sidebar.collapsed .nav-item .nav-icon { width: 18px; height: 18px; }
    .sidebar.collapsed .nav-item .nav-icon svg { width: 18px; height: 18px; }
    .sidebar.collapsed .nav-item span:first-child { font-size: 18px; }

    /* Tooltip on collapsed */
    .sidebar.collapsed .nav-item[data-tip]:hover::after {
        content: attr(data-tip);
        position: absolute;
        left: 56px;
        background: #1F2937;
        color: white;
        font-size: 12px;
        padding: 4px 10px;
        border-radius: 6px;
        white-space: nowrap;
        z-index: 200;
        pointer-events: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }

    .nav-item:hover {
        background: var(--sidebar-hover-bg);
        color: var(--text);
    }

    .nav-item.active {
        background: var(--sidebar-active-bg);
        color: var(--sidebar-active);
        font-weight: 600;
    }

    #subBadge {
        margin: 0 10px 8px !important;
        padding: 8px 12px !important;
        border-radius: var(--r-md) !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        transition: opacity 0.15s;
        white-space: nowrap;
        overflow: hidden;
        flex-shrink: 0;
    }
    .sidebar.collapsed #subBadge { opacity: 0; pointer-events: none; }

    /* ── Main content ───────────────────────────────────── */
    .main-content {
        margin-left: 240px;
        transition: margin-left 0.22s cubic-bezier(0.4,0,0.2,1);
        padding: 32px 40px;
        min-height: 100vh;
        background: var(--bg);
        flex: 1;
        min-width: 0;
    }
    .main-content.sidebar-collapsed { margin-left: 60px; }

    .page { display: none; }

    .page.active {
        display: block;
        animation: fadeIn 0.2s var(--ease) both;
    }

    /* ── Patient Profile Tabs ── */
    .pp-tab {
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        padding: 10px 16px;
        font-size: 13px;
        font-weight: 500;
        color: var(--text-secondary);
        cursor: pointer;
        white-space: nowrap;
        margin-bottom: -2px;
        transition: color 0.15s, border-color 0.15s;
        font-family: inherit;
    }
    .pp-tab:hover { color: var(--text); }
    .pp-tab.active {
        color: var(--primary);
        border-bottom-color: var(--primary);
        font-weight: 600;
    }

    .page-header { margin-bottom: 32px; }

    .page-header h1 {
        font-size: 28px;
        font-weight: 600;
        color: var(--text);
        letter-spacing: -0.6px;
        line-height: 1.2;
        margin-bottom: 4px;
    }

    .page-header p {
        font-size: 14px;
        color: var(--text-secondary);
    }

    /* ═══════════════════════════════════════════════════
       CARDS
    ═══════════════════════════════════════════════════ */
    .card {
        background: var(--surface);
        border-radius: var(--r-lg);
        padding: 24px;
        margin-bottom: 20px;
        border: 1px solid var(--border);
        box-shadow: var(--shadow-xs);
    }

    .card-title {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--text-tertiary);
        margin-bottom: 16px;
    }

    /* ═══════════════════════════════════════════════════
       GRID
    ═══════════════════════════════════════════════════ */
    .grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }

    /* ═══════════════════════════════════════════════════
       STAT CARDS
    ═══════════════════════════════════════════════════ */
    .stat-card {
        background: var(--surface);
        padding: 24px;
        border-radius: var(--r-lg);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-xs);
        transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
    }

    .stat-card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

    .stat-card h3 {
        font-size: 30px;
        font-weight: 600;
        color: var(--text);
        letter-spacing: -1px;
        line-height: 1;
        margin-bottom: 6px;
    }

    .stat-card p {
        font-size: 13px;
        font-weight: 500;
        color: var(--text-secondary);
    }

    /* ═══════════════════════════════════════════════════
       METRIC CARDS
    ═══════════════════════════════════════════════════ */
    .metric-card {
        text-align: center;
        padding: 24px 16px;
        background: var(--surface);
        border-radius: var(--r-lg);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-xs);
        transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
    }

    .metric-card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

    .metric-value {
        font-size: 28px;
        font-weight: 600;
        color: var(--primary);
        letter-spacing: -0.5px;
        line-height: 1;
        margin-bottom: 6px;
    }

    .metric-label {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--text-secondary);
    }

    .metric-subtitle {
        font-size: 12px;
        color: var(--text-tertiary);
        margin-top: 4px;
    }

    /* ═══════════════════════════════════════════════════
       TABLES
    ═══════════════════════════════════════════════════ */
    table { width: 100%; border-collapse: collapse; }

    thead { background: var(--bg); }

    th {
        padding: 10px 14px;
        text-align: left;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--text-secondary);
        border-bottom: 1px solid var(--border);
    }

    td {
        padding: 13px 14px;
        font-size: 14px;
        color: var(--text);
        border-bottom: 1px solid var(--border);
    }

    tr:last-child td { border-bottom: none; }
    tr:hover td { background: var(--surface-hover); }

    /* ═══════════════════════════════════════════════════
       ALERTS
    ═══════════════════════════════════════════════════ */
    .alert {
        padding: 12px 16px;
        border-radius: var(--r-md);
        margin-bottom: 16px;
        font-size: 14px;
        line-height: 1.5;
        display: flex;
        align-items: flex-start;
        gap: 10px;
        border: 1px solid transparent;
    }

    .alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
    .alert-error   { background: var(--error-bg);   color: var(--error);   border-color: var(--error-border); }
    .alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
    .alert-info    { background: var(--info-bg);    color: var(--info-text); border-color: var(--info-border); }

    /* ── Patient identification card ── */
    .patient-card {
        padding: 10px 16px;
        border-radius: var(--r-md);
        margin-bottom: 16px;
        font-size: 14px;
        line-height: 1.5;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        background: var(--surface);
        border: 1px solid var(--border);
        color: var(--text);
    }
    .patient-card strong { color: var(--primary); }
    .patient-card-badge {
        background: var(--primary);
        color: white;
        padding: 2px 10px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
    }

    /* ═══════════════════════════════════════════════════
       BADGES
    ═══════════════════════════════════════════════════ */
    .badge {
        display: inline-flex;
        align-items: center;
        padding: 2px 8px;
        border-radius: 99px;
        font-size: 11px;
        font-weight: 500;
        letter-spacing: 0.01em;
    }

    .badge-success { background: var(--success-bg); color: #166534; }
    .badge-warning { background: var(--warning-bg); color: #92400E; }
    .badge-error   { background: var(--error-bg);   color: #991B1B; }

    /* ═══════════════════════════════════════════════════
       AGENDA
    ═══════════════════════════════════════════════════ */
    .view-btn {
        height: 36px;
        padding: 0 14px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        cursor: pointer;
        font-size: 13px;
        font-family: inherit;
        font-weight: 500;
        color: var(--text-secondary);
        outline: none;
        transition: all var(--t);
    }

    .view-btn:hover { border-color: var(--border-strong); color: var(--text); }
    .view-btn.active { background: var(--primary); color: #FFFFFF; border-color: var(--primary); }

    .week-grid { display: grid; grid-template-columns: 60px repeat(7, 1fr); }

    .week-day-header {
        padding: 10px 8px;
        text-align: center;
        border-bottom: 1px solid var(--border);
        border-right: 1px solid var(--border);
        font-size: 12px;
        font-weight: 500;
        color: var(--text-secondary);
    }

    .week-day-header.today { background: var(--surface-hover); color: var(--primary); font-weight: 600; }

    .week-time-label {
        padding: 4px 8px 0;
        text-align: right;
        font-size: 10px;
        color: var(--text-tertiary);
        height: 48px;
        display: flex;
        align-items: flex-start;
        justify-content: flex-end;
        border-right: 1px solid var(--border);
    }

    .week-cell {
        height: 48px;
        border-bottom: 1px solid var(--border);
        border-right: 1px solid var(--border);
        position: relative;
        cursor: pointer;
        transition: background var(--t);
    }

    .week-cell:hover { background: var(--surface-hover); }
    .week-cell.today-col { background: var(--surface); border-right: 2px solid var(--primary); }

    .appt-chip {
        position: absolute;
        left: 2px; right: 2px;
        border-radius: var(--r-sm);
        padding: 2px 6px;
        font-size: 11px;
        font-weight: 500;
        cursor: pointer;
        z-index: 1;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .chip-consulta    { background: #DBEAFE; color: #1E40AF; border-left: 2px solid #3B82F6; }
    .chip-retorno     { background: #D1FAE5; color: #065F46; border-left: 2px solid #059669; }
    .chip-reavaliacao { background: #FEF3C7; color: #92400E; border-left: 2px solid #F59E0B; }
    .chip-cancelado   { background: #FEE2E2; color: #991B1B; border-left: 2px solid #EF4444; text-decoration: line-through; }
    .chip-realizado   { background: #F3F4F6; color: #6B7280; border-left: 2px solid #9CA3AF; }

    [data-theme="dark"] .chip-consulta    { background: #1e3a5f; color: #93C5FD; border-left-color: #3B82F6; }
    [data-theme="dark"] .chip-retorno     { background: #064e3b; color: #6EE7B7; border-left-color: #059669; }
    [data-theme="dark"] .chip-reavaliacao { background: #3d2100; color: #FCD34D; border-left-color: #F59E0B; }
    [data-theme="dark"] .chip-cancelado   { background: #4b1c1c; color: #FCA5A5; border-left-color: #EF4444; }
    [data-theme="dark"] .chip-realizado   { background: #1e293b; color: #94A3B8; border-left-color: #475569; }

    .appt-list-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 16px;
        border-radius: var(--r-lg);
        border: 1px solid var(--border);
        margin-bottom: 8px;
        cursor: pointer;
        background: var(--surface);
        transition: border-color var(--t), box-shadow var(--t), transform var(--t);
    }

    .appt-list-item:hover {
        border-color: var(--border-strong);
        box-shadow: var(--shadow-sm);
        transform: translateX(2px);
    }

    .appt-date-badge {
        text-align: center;
        min-width: 48px;
        background: var(--primary);
        color: #FFFFFF;
        border-radius: var(--r-md);
        padding: 8px 6px;
        flex-shrink: 0;
    }

    .appt-date-badge .day   { font-size: 20px; font-weight: 700; line-height: 1; }
    .appt-date-badge .month { font-size: 10px; text-transform: uppercase; opacity: 0.85; letter-spacing: 0.05em; }

    .status-badge {
        display: inline-flex;
        align-items: center;
        padding: 2px 8px;
        border-radius: 99px;
        font-size: 11px;
        font-weight: 500;
    }

    .status-agendado   { background: #DBEAFE; color: #1E40AF; }
    .status-confirmado { background: #D1FAE5; color: #065F46; }
    .status-realizado  { background: #F3F4F6; color: #374151; }
    .status-cancelado  { background: #FEE2E2; color: #991B1B; }

    /* ═══════════════════════════════════════════════════
       LOADING
    ═══════════════════════════════════════════════════ */
    #loadingOverlay {
        position: fixed;
        inset: 0;
        background: rgba(249,250,251,0.88);
        backdrop-filter: blur(4px);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
        flex-direction: column;
        gap: 14px;
    }

    #loadingOverlay.hidden { display: none; }

    .spinner {
        width: 28px;
        height: 28px;
        border: 2.5px solid var(--border);
        border-top-color: var(--primary);
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
    }

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

    /* ── Toast alert ───────────────────────────────────── */
    #mainAlert {
        position: fixed;
        top: 20px;
        right: 24px;
        z-index: 8888;
        min-width: 280px;
        max-width: 400px;
        border-radius: var(--r-lg);
        box-shadow: var(--shadow-xl);
        animation: toastIn 0.25s var(--ease) both;
    }

    @keyframes toastIn {
        from { opacity: 0; transform: translateY(-10px) scale(0.98); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }

    /* ═══════════════════════════════════════════════════
       RESPONSIVE
    ═══════════════════════════════════════════════════ */
    /* ═══════════════════════════════════════════════════
       RESPONSIVIDADE — Tablet (≤ 1024px)
    ═══════════════════════════════════════════════════ */
    @media (max-width: 1024px) {
        .main-content {
            padding: 24px 28px;
        }

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

        .page-header h1 { font-size: 22px; }
    }

    /* ═══════════════════════════════════════════════════
       RESPONSIVIDADE — Mobile (≤ 768px)
    ═══════════════════════════════════════════════════ */
    @media (max-width: 768px) {

        /* ── Dashboard Shell ── */
        .dashboard.active { flex-direction: column; }

        /* ── Sidebar: esconde fixa e vira drawer ── */
        .sidebar {
            position: fixed;
            top: 0;
            left: -100%;
            width: 260px !important;
            min-width: 260px !important;
            height: 100%;
            height: 100dvh;
            z-index: 300;
            transition: left 0.25s cubic-bezier(0.4,0,0.2,1);
            box-shadow: var(--shadow-xl);
            overflow: hidden !important;
            display: flex !important;
            flex-direction: column !important;
        }
        /* Área rolável — só o menu de itens rola */
        .sidebar .nav-menu {
            flex: 1 1 auto !important;
            overflow-y: auto !important;
            min-height: 0 !important;
        }
        /* Rodapé fixo na parte inferior — nunca some */
        .sidebar .sidebar-footer {
            flex-shrink: 0 !important;
            border-top: 1px solid var(--sidebar-border);
            padding-top: 4px;
            background: var(--sidebar-bg);
        }
        .sidebar.mobile-open {
            left: 0;
        }
        /* Garante que collapsed não sobreponha no mobile */
        .sidebar.collapsed {
            left: -100%;
            width: 260px !important;
            min-width: 260px !important;
        }
        .sidebar.collapsed.mobile-open {
            left: 0;
        }
        /* Overlay escuro atrás do drawer */
        .sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(17,24,39,0.45);
            z-index: 299;
        }
        .sidebar-overlay.active { display: block; }

        /* ── Topbar mobile ── */
        .mobile-topbar {
            display: flex !important;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            position: sticky;
            top: 0;
            z-index: 200;
            box-shadow: var(--shadow-xs);
        }
        .mobile-topbar h2 {
            font-size: 16px;
            font-weight: 700;
            color: var(--text);
            letter-spacing: -0.3px;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .mobile-topbar h2 span { color: var(--primary); }
        .mobile-menu-btn {
            background: none;
            border: 1px solid var(--border);
            border-radius: var(--r-md);
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 18px;
            color: var(--text);
        }

        /* ── Main content ── */
        .main-content {
            margin-left: 0 !important;
            padding: 16px;
            min-height: calc(100vh - 57px);
        }

        /* ── Grids ── */
        .grid,
        .grid-2,
        .grid-3,
        .grid-4,
        .form-row {
            grid-template-columns: 1fr !important;
        }

        /* ── Dashboard grids específicos ── */
        #dashMainGrid,
        #dashBottomGrid { grid-template-columns: 1fr !important; }

        /* ── Page header ── */
        .page-header { margin-bottom: 20px; }
        .page-header h1 { font-size: 20px; }
        .page-header p { font-size: 13px; }

        /* Cabeçalho com botões (flex) ── */
        .page-header > div[style*="display:flex"],
        .page-header > div[style*="display: flex"] {
            flex-wrap: wrap;
            gap: 8px !important;
        }

        /* ── Cards ── */
        .card { padding: 16px; }

        /* ── Stat cards ── */
        .stat-card { padding: 16px; }
        .stat-card h3 { font-size: 24px; }

        /* ── Login ── */
        .login-box {
            padding: 28px 20px;
            border-radius: var(--r-lg);
        }

        /* ── Tabelas: scroll horizontal ── */
        .card > table,
        .card > div > table,
        [style*="overflow"] > table {
            min-width: 500px;
        }
        /* Wrapper de scroll para tabelas */
        .table-wrapper {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

        /* ── Agenda semanal ── */
        .week-grid {
            grid-template-columns: 48px repeat(3, 1fr) !important;
            font-size: 11px;
        }

        /* ── Botões em linha: quebra para coluna ── */
        .btn-group-row {
            flex-direction: column !important;
        }

        /* ── Modais: tela cheia no mobile ── */
        [style*="max-width:680px"],
        [style*="max-width: 680px"],
        [style*="max-width:900px"],
        [style*="max-width: 900px"],
        [style*="max-width:1100px"],
        [style*="max-width: 1100px"] {
            max-width: 100% !important;
            width: 100% !important;
            margin: 0 !important;
            border-radius: 16px 16px 0 0 !important;
            max-height: 92vh !important;
        }
        [style*="position:fixed"][style*="align-items:center"],
        [style*="position: fixed"][style*="align-items: center"] {
            align-items: flex-end !important;
            padding: 0 !important;
        }

        /* ── Tabs do perfil do paciente ── */
        .pp-tab {
            padding: 8px 10px;
            font-size: 12px;
        }

        /* ── Formulários com linhas duplas ── */
        .form-row { gap: 12px; }

        /* ── Buttons full width em contextos menores ── */
        .card .btn,
        .login-box .btn {
            width: 100%;
            margin-bottom: 8px;
        }

        /* ── Legal modal tabs ── */
        #legalTabTerms, #legalTabPrivacy {
            font-size: 12px !important;
            padding: 5px 12px !important;
        }

        /* ── Ocultar labels longas na agenda ── */
        .week-day-header small { display: none; }

        /* ── Sidebar toggle no desktop não aparece no mobile ── */
        .sidebar-toggle { display: none; }
    }

    /* ═══════════════════════════════════════════════════
       RESPONSIVIDADE — Mobile pequeno (≤ 400px)
    ═══════════════════════════════════════════════════ */
    @media (max-width: 400px) {
        .main-content { padding: 12px; }
        .page-header h1 { font-size: 18px; }
        .stat-card h3 { font-size: 20px; }
        .metric-value { font-size: 22px; }
        .card { padding: 12px; }
        .btn { font-size: 13px; height: 38px; }
        .login-box { padding: 20px 14px; }
    }

    /* ── A topbar mobile fica escondida no desktop ── */
    .mobile-topbar { display: none; }
    .sidebar-overlay { display: none; }


    /* ── Onboarding dots ──────────────────────────── */
    .onb-dot.active { background: var(--primary) !important; transform: scale(1.3); }

    .hidden { display: none !important; }

    #patientFormCard {
        transition: opacity 0.25s ease, transform 0.25s ease;
    }
    #patientFormCard.form-open {
        opacity: 1;
        transform: translateY(0);
    }

