        :root {
            --primary-color: #0044FF;
            --primary-rgb: 0, 68, 255; /* componentes RGB da cor principal (para sombreados com transparência) */
            --hover-color: #0033CC;
            --bg-color: #F0F4F8;
            --card-bg: #FFFFFF;
            --text-main: #0B192C;
            --text-muted: #475569;
            --border-color: #CBD5E1;
            --input-bg: #F8FAFC;
            
            --success-color: #00FF66; 
            --success-hover: #00E65C;
            --success-text: #00220E; 
            --success-rgb: 0, 255, 102; /* componentes RGB da cor de destaque (modo escuro/OLED) */
            
            --danger-color: #FF1744;
            --danger-hover: #D50000;
            --danger-text: #FFFFFF;

            --warning-color: #F59E0B;
            
            --modal-backdrop: rgba(11, 25, 44, 0.85);
            --preview-bg: #E2E8F0;
            
            --radius-main: 6px;
            --radius-sm: 4px;
            
            --sidebar-width: 260px;
            --sidebar-width-collapsed: 80px;
        }

        body.dark-mode {
            --bg-color: #050A15;
            --card-bg: #0D1629;
            --text-main: #F8FAFC;
            --text-muted: #94A3B8;
            --border-color: #1E293B;
            --input-bg: #050A15;
            --preview-bg: #050A15;
        }

        body.oled-mode {
            --bg-color: #000000;
            --card-bg: #000000;
            --text-main: #F8FAFC;
            --text-muted: #A0ABC0;
            --border-color: #1A1A1A;
            --input-bg: #050505;
            --preview-bg: #000000;
        }

        * { box-sizing: border-box; margin: 0; padding: 0; }

        html, body {
            height: 100%; width: 100%; overflow: hidden;
            background-color: var(--bg-color); transition: background-color 0.3s ease;
        }

        body { font-family: 'Funnel Sans', system-ui, -apple-system, sans-serif; color: var(--text-main); line-height: 1.5; transition: color 0.3s ease; }

        /* Títulos e subtítulos usam Funnel Display (o resto do texto herda Funnel Sans do body) */
        h1, h2, h3, h4, h5, h6,
        .subtitle, .section-subtitle, .faq-category-title, .turma-title, .notif-title,
        .info-widget-title, .dia-titulo, .bloco-evento-titulo {
            font-family: 'Funnel Display', 'Funnel Sans', system-ui, -apple-system, sans-serif;
        }
        /* A pré-visualização A4 simula o documento impresso e mantém a sua própria fonte */
        .a4-preview h1, .a4-preview h2, .a4-preview h3, .a4-preview h4, .a4-preview h5, .a4-preview h6 { font-family: inherit; }

        .fade-out-anim { animation: containerFadeOut 0.3s ease-in forwards !important; }
        .fade-in-anim { animation: containerFadeIn 0.3s ease-out forwards !important; }
        @keyframes containerFadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes containerFadeOut { from { opacity: 1; } to { opacity: 0; } }
        @keyframes popIn { from { opacity: 0; transform: scale(0.98) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
        @keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
        .shake-anim { animation: shake 0.3s ease-in-out; }
        @keyframes spin { 100% { transform: rotate(360deg); } }

        .logo-theme-light { display: block; }
        .logo-theme-dark { display: none; }
        body.dark-mode .logo-theme-light, body.oled-mode .logo-theme-light { display: none; }
        body.dark-mode .logo-theme-dark, body.oled-mode .logo-theme-dark { display: block; }

        /* TELA DE LOGIN (LANDING)
           Mobile: faixa de marca no topo, cartão do formulário sobreposto e rodapé no fim.
           Desktop (>900px): painel de marca à esquerda (com o rodapé) e formulário à direita. */
        #landingContainer {
            display: flex; flex-direction: column; align-items: stretch;
            position: absolute; top: 0; left: 0; right: 0; bottom: 0;
            overflow-y: auto; -webkit-overflow-scrolling: touch;
            text-align: left;
        }

        /* Painel de marca: no mobile os filhos entram diretamente no fluxo do contentor */
        .landing-hero { display: contents; }
        .landing-hero-top {
            position: relative; overflow: hidden; z-index: 1;
            padding: 28px 24px 92px; color: #FFFFFF;
            background: linear-gradient(145deg, var(--primary-color) 0%, var(--hover-color) 100%);
        }
        body.dark-mode .landing-hero-top, body.oled-mode .landing-hero-top {
            background: var(--card-bg); border-bottom: 1px solid var(--border-color);
        }
        /* Fundo animado do painel de marca: grelha a deslizar, foco de luz que percorre a grelha e brilhos difusos.
           Tudo animado com transform (composição na GPU); o foco usa uma camada que se move ao contrário
           para que a grelha realçada fique sempre alinhada com a grelha de fundo. */
        .landing-hero-fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
        .landing-hero-fx-grid {
            position: absolute; inset: 0;
            -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 0%, transparent 75%);
            mask-image: radial-gradient(ellipse at 30% 40%, #000 0%, transparent 75%);
        }
        .landing-hero-fx-grid::before, .landing-hero-fx-spot-grid {
            content: ""; position: absolute; will-change: transform;
            background-size: 44px 44px;
            animation: landingGridDrift 9s linear infinite;
        }
        .landing-hero-fx-grid::before {
            top: -44px; left: -44px; width: calc(100% + 44px); height: calc(100% + 44px);
            background-image:
                linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
        }

        /* Foco de luz (420px) centrado no ponto do percurso */
        .landing-hero-fx-spot {
            position: absolute; top: 0; left: 0; width: 420px; height: 420px; margin: -210px 0 0 -210px;
            border-radius: 50%; overflow: hidden; will-change: transform;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.07) 0%, transparent 65%);
            -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 68%);
            mask-image: radial-gradient(circle, #000 0%, transparent 68%);
            animation: landingSpotPathMobile 22s ease-in-out infinite;
        }
        /* Desfaz o movimento do foco: a grelha interior fica fixa em relação ao painel */
        .landing-hero-fx-spot-track {
            position: absolute; top: 166px; left: 166px; will-change: transform;
            animation: landingSpotPathMobileInv 22s ease-in-out infinite;
        }
        .landing-hero-fx-spot-grid {
            top: 0; left: 0; width: calc(100vw + 44px); height: calc(100vh + 44px);
            background-image:
                linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
            opacity: 0.85; transition: opacity 0.4s ease;
        }
        /* Desvio aplicado pelo cursor (desktop): o invólucro desloca o foco e o interior anula o desvio na grelha */
        .landing-hero-fx-cursor, .landing-hero-fx-cursor-inv { position: absolute; top: 0; left: 0; will-change: transform; }
        .landing-hero-fx.cursor-ativo .landing-hero-fx-spot-grid { opacity: 1; }

        .landing-hero-fx-glow { position: absolute; border-radius: 50%; will-change: transform; }
        .landing-hero-fx-glow.glow-a {
            width: 320px; height: 320px; right: -120px; bottom: -160px;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.18) 0%, transparent 70%);
            animation: landingGlowA 16s ease-in-out infinite alternate;
        }
        .landing-hero-fx-glow.glow-b {
            width: 260px; height: 260px; left: -110px; top: -110px;
            background: radial-gradient(circle, rgba(var(--success-rgb), 0.13) 0%, transparent 70%);
            animation: landingGlowB 20s ease-in-out infinite alternate;
        }
        body.dark-mode .landing-hero-fx-glow.glow-a, body.oled-mode .landing-hero-fx-glow.glow-a {
            background: radial-gradient(circle, rgba(var(--success-rgb), 0.16) 0%, transparent 70%);
        }
        body.dark-mode .landing-hero-fx-glow.glow-b, body.oled-mode .landing-hero-fx-glow.glow-b {
            background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
        }
        body.dark-mode .landing-hero-fx-spot-grid, body.oled-mode .landing-hero-fx-spot-grid {
            background-image:
                linear-gradient(rgba(var(--success-rgb), 0.35) 1px, transparent 1px),
                linear-gradient(90deg, rgba(var(--success-rgb), 0.35) 1px, transparent 1px);
        }
        body.dark-mode .landing-hero-fx-spot, body.oled-mode .landing-hero-fx-spot {
            background: radial-gradient(circle, rgba(var(--success-rgb), 0.06) 0%, transparent 65%);
        }

        @keyframes landingGridDrift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(44px, 44px, 0); } }
        @keyframes landingGlowA { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(-70px, -50px, 0) scale(1.15); } }
        @keyframes landingGlowB { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(90px, 60px, 0) scale(1.2); } }
        /* Percursos do foco (mobile: faixa do topo; desktop: painel inteiro) e respetivos inversos */
        @keyframes landingSpotPathMobile {
            0%, 100% { transform: translate3d(20vw, 90px, 0); }
            25% { transform: translate3d(78vw, 60px, 0); }
            50% { transform: translate3d(65vw, 260px, 0); }
            75% { transform: translate3d(15vw, 300px, 0); }
        }
        @keyframes landingSpotPathMobileInv {
            0%, 100% { transform: translate3d(-20vw, -90px, 0); }
            25% { transform: translate3d(-78vw, -60px, 0); }
            50% { transform: translate3d(-65vw, -260px, 0); }
            75% { transform: translate3d(-15vw, -300px, 0); }
        }
        @keyframes landingSpotPath {
            0%, 100% { transform: translate3d(14vw, 28vh, 0); }
            25% { transform: translate3d(42vw, 16vh, 0); }
            50% { transform: translate3d(36vw, 64vh, 0); }
            75% { transform: translate3d(10vw, 80vh, 0); }
        }
        @keyframes landingSpotPathInv {
            0%, 100% { transform: translate3d(-14vw, -28vh, 0); }
            25% { transform: translate3d(-42vw, -16vh, 0); }
            50% { transform: translate3d(-36vw, -64vh, 0); }
            75% { transform: translate3d(-10vw, -80vh, 0); }
        }
        @media (prefers-reduced-motion: reduce) {
            .landing-hero-fx-grid::before, .landing-hero-fx-glow { animation: none; }
            .landing-hero-fx-spot { display: none; }
        }

        .landing-hero-top > :not(.landing-hero-fx) { position: relative; z-index: 1; }

        .landing-hero-logo { width: 104px; height: auto; display: block; }

        .landing-hero-content { margin-top: 28px; }
        .landing-hero-eyebrow {
            display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px;
            padding: 5px 11px; border-radius: 999px; font-size: 11px; font-weight: 600;
            text-transform: uppercase; letter-spacing: 0.06em;
            background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.22);
        }
        .landing-hero-eyebrow::before {
            content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success-color);
            box-shadow: 0 0 0 3px rgba(var(--success-rgb), 0.25);
        }
        .landing-hero-title {
            font-size: clamp(22px, 7vw, 32px); font-weight: 600; line-height: 1.1;
            letter-spacing: -0.03em; margin-bottom: 10px;
        }
        /* Título sempre em duas linhas */
        .landing-hero-title .line { display: block; white-space: nowrap; }
        .landing-hero-title .accent { color: var(--success-color); }
        .landing-hero-text { font-size: 14.5px; line-height: 1.55; opacity: 0.85; max-width: 440px; }

        /* Coluna/cartão do formulário */
        .landing-main {
            display: flex; flex-direction: column; align-items: center; flex: 1 0 auto;
            padding: 0 16px; margin-top: -64px; z-index: 2;
        }
        .landing-box {
            background: var(--card-bg); padding: 30px 24px; border-radius: var(--radius-main);
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08); border: 1px solid var(--border-color);
            max-width: 440px; width: 100%; margin: 0 auto;
            animation: containerFadeIn 0.45s ease-out both;
        }
        /* O botão de tema fica no canto do ecrã (sobre a faixa de marca no mobile) */
        .landing-theme-btn { position: absolute; top: 20px; right: 16px; z-index: 3; }
        #landingContainer .landing-box .app-main-logo { display: none; }

        .landing-heading { margin-bottom: 24px; }
        .landing-heading h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; color: var(--text-main); margin-bottom: 6px; }
        .landing-heading p { font-size: 14.5px; color: var(--text-muted); }

        .app-main-logo { max-width: 200px; margin: 0 auto 30px auto; transition: transform 0.3s ease; }
        .app-main-logo:hover { transform: scale(1.02); }
        .landing-form { display: flex; flex-direction: column; gap: 20px; text-align: left; }

        .remember-container { display: flex; align-items: center; gap: 8px; margin-top: -5px; }
        .remember-container input[type="checkbox"] { width: 18px; height: 18px; margin: 0; padding: 0; cursor: pointer; accent-color: var(--primary-color); }
        .remember-container label { margin: 0; font-size: 14px; text-transform: none; font-weight: 500; cursor: pointer; color: var(--text-main); letter-spacing: normal; }

        /* Rodapé (suporte + copyright): no fim do ecrã no mobile, no painel de marca no desktop */
        .landing-footer {
            order: 1; display: flex; flex-direction: column; align-items: center; gap: 10px;
            padding: 28px 16px max(24px, env(safe-area-inset-bottom));
            font-size: 13px; color: var(--text-muted); text-align: center;
        }
        .landing-footer a {
            display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-muted); text-decoration: none;
            cursor: pointer; transition: all 0.2s; font-weight: 600; padding: 8px 16px; border-radius: var(--radius-sm);
            background: var(--card-bg); border: 1px solid var(--border-color);
        }
        .landing-footer a:hover { color: var(--primary-color); border-color: var(--primary-color); }
        body.dark-mode .landing-footer a:hover, body.oled-mode .landing-footer a:hover { color: var(--success-color); border-color: var(--success-color); }

        @media (max-width: 900px) {
            .landing-theme-btn .top-btn { color: #FFFFFF; background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.35); }
        }

        @media (min-width: 901px) {
            #landingContainer { flex-direction: row; overflow: hidden; }

            .landing-hero {
                display: flex; flex-direction: column; flex: 1 1 55%; min-width: 0;
                position: relative; overflow: hidden; color: #FFFFFF;
                padding: clamp(36px, 5vw, 64px) clamp(36px, 5vw, 72px);
                background: linear-gradient(145deg, var(--primary-color) 0%, var(--hover-color) 100%);
            }
            body.dark-mode .landing-hero, body.oled-mode .landing-hero {
                background: var(--card-bg); border-right: 1px solid var(--border-color);
            }
            /* static: o fundo animado passa a cobrir o painel inteiro */
            .landing-hero-top, body.dark-mode .landing-hero-top, body.oled-mode .landing-hero-top {
                position: static; overflow: visible; flex: 1;
                display: flex; flex-direction: column; justify-content: space-between;
                padding: 0; background: none; border: 0;
            }
            .landing-hero-fx-glow.glow-a { width: 520px; height: 520px; right: -180px; bottom: -200px; }
            .landing-hero-fx-glow.glow-b { width: 440px; height: 440px; left: -160px; top: -180px; }
            .landing-hero-fx-spot { width: 520px; height: 520px; margin: -260px 0 0 -260px; animation-name: landingSpotPath; animation-duration: 26s; }
            .landing-hero-fx-spot-track { top: 216px; left: 216px; animation-name: landingSpotPathInv; animation-duration: 26s; }

            .landing-hero-logo { width: 150px; }
            .landing-hero-content { margin-top: 40px; max-width: 600px; }
            .landing-hero-eyebrow { margin-bottom: 22px; padding: 6px 12px; font-size: 12px; }
            .landing-hero-title { font-size: clamp(28px, 3.2vw, 46px); line-height: 1.08; margin-bottom: 18px; }
            .landing-hero-text { font-size: 16px; line-height: 1.6; }

            .landing-footer {
                order: 0; position: relative; z-index: 1;
                flex-direction: row; gap: 16px; padding: 0; margin-top: 40px;
                color: rgba(255, 255, 255, 0.75);
            }
            .landing-footer a { color: #FFFFFF; background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); }
            .landing-footer a:hover { color: #FFFFFF; background: rgba(255, 255, 255, 0.18); border-color: #FFFFFF; }
            body.dark-mode .landing-footer, body.oled-mode .landing-footer { color: var(--text-muted); }
            body.dark-mode .landing-footer a, body.oled-mode .landing-footer a { color: var(--text-muted); background: transparent; border-color: var(--border-color); }

            .landing-main {
                flex: 0 0 clamp(440px, 42%, 600px); position: relative; margin-top: 0;
                padding: 80px 40px 40px; overflow-y: auto; -webkit-overflow-scrolling: touch;
            }
            /* margens automáticas centram o cartão sem o cortar quando a janela é baixa */
            .landing-box { margin: auto 0; max-width: 420px; padding: 44px 40px; }
            .landing-theme-btn { top: 24px; right: 24px; }

            .landing-heading { margin-bottom: 28px; }
            .landing-heading h1 { font-size: 28px; margin-bottom: 8px; }
            .landing-heading p { font-size: 15px; }
        }

        #loadingContainer {
            display: none; flex-direction: column; align-items: center; justify-content: center; 
            position: absolute; top: 0; left: 0; right: 0; bottom: 0; text-align: center; z-index: 9999;
        }
        #loadingText.saudacao {
            font-family: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif;
            font-size: 26px !important; font-weight: 600 !important; letter-spacing: -0.02em; line-height: 1.2; padding: 0 20px;
        }
        html.a-retomar-sessao #landingContainer { display: none; }
        html.a-retomar-sessao #loadingContainer { display: flex; }
        .spinner-icon { animation: spin 1s linear infinite; stroke: var(--primary-color); margin-top: 10px; }
        body.dark-mode .spinner-icon, body.oled-mode .spinner-icon { stroke: var(--success-color); }

        /* --- ESTILOS DO MODAL DE TEMAS PERSONALIZADOS --- */
        .theme-mode-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
            margin-bottom: 20px;
        }

        .theme-mode-card {
            background: var(--input-bg);
            border: 2px solid var(--border-color);
            border-radius: var(--radius-sm);
            padding: 16px 12px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            cursor: pointer;
            font-size: 13px;
            font-weight: 700;
            color: var(--text-muted);
            transition: all 0.2s ease;
            user-select: none;
        }

        .theme-mode-card:hover {
            border-color: var(--primary-color);
            color: var(--text-main);
            transform: translateY(-2px);
        }

        .theme-mode-card.active {
            border-color: var(--primary-color);
            color: var(--primary-color);
            background: rgba(var(--primary-rgb), 0.05);
        }

        body.dark-mode .theme-mode-card.active,
        body.oled-mode .theme-mode-card.active {
            background: rgba(255, 255, 255, 0.05);
        }

        .theme-colors-palette {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-bottom: 14px;
        }

        .color-swatch-btn {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            border: 3px solid transparent;
            cursor: pointer;
            transition: all 0.2s ease;
            outline: none;
            padding: 0;
        }

        .color-swatch-btn:hover {
            transform: scale(1.15);
        }

        .color-swatch-btn.active {
            border-color: var(--text-main);
            box-shadow: 0 0 0 2px var(--card-bg);
            transform: scale(1.1);
        }

        .theme-custom-picker-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 15px;
            margin-bottom: 20px;
        }

        .color-picker-input-wrapper {
            display: flex;
            align-items: center;
            gap: 10px;
            background: var(--input-bg);
            border: 1px solid var(--border-color);
            padding: 6px 12px;
            border-radius: var(--radius-sm);
            cursor: pointer;
        }

        .color-picker-input-wrapper input[type="color"] {
            width: 28px;
            height: 28px;
            padding: 0;
            border: none;
            background: transparent;
            cursor: pointer;
            border-radius: 4px;
        }

        #themeColorHexPreview {
            font-size: 13px;
            font-weight: 700;
            font-family: monospace;
            color: var(--text-main);
        }

        .theme-preview-box {
            background: var(--input-bg);
            border: 1px dashed var(--border-color);
            border-radius: var(--radius-sm);
            padding: 16px;
        }

        @media (max-width: 600px) {
            .theme-mode-grid {
                grid-template-columns: 1fr;
            }
        }
         
        /* LAYOUT PRINCIPAL (APP SHELL) */
        #appShell { display: none; width: 100%; height: 100%; overflow: hidden; position: absolute; top: 0; left: 0; right: 0; bottom: 0; }

        .sidebar {
            width: var(--sidebar-width); background: var(--card-bg); border-right: 1px solid var(--border-color);
            display: flex; flex-direction: column; height: 100%; position: absolute; top: 0; left: 0; bottom: 0;
            z-index: 100; transition: width 0.3s ease, transform 0.3s ease; padding-bottom: env(safe-area-inset-bottom);
        }
        
        .sidebar-header { 
            padding: 25px 20px 25px; 
            display: flex; 
            justify-content: space-between; 
            align-items: center; 
            padding-top: max(25px, env(safe-area-inset-top)); 
            transition: all 0.3s ease;
        }
        
        .logo-full img { max-width: 130px; transition: opacity 0.3s; }
        
        .logo-icon { 
            display: none; 
            justify-content: center; 
            align-items: center; 
            height: 36px; /* Altura fixa para condizer perfeitamente com o botão ao fazer swap */
        }
        .logo-icon img { max-width: 35px; }
        
        .desktop-toggle-btn {
            background: transparent;
            border: none;
            color: var(--text-main);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 6px;
            border-radius: var(--radius-sm);
            transition: all 0.2s ease;
            width: 36px;
            height: 36px;
        }
        .desktop-toggle-btn:hover {
            background: var(--input-bg);
            color: var(--primary-color);
        }
        body.dark-mode .desktop-toggle-btn:hover, body.oled-mode .desktop-toggle-btn:hover {
            color: var(--success-color);
        }

        /* Lógica do Ícone Expandir/Recolher SVG */
        .icon-expand { display: none; }
        #appShell.collapsed .icon-collapse { display: none; }
        #appShell.collapsed .icon-expand { display: block; }

        /* Lógica do estado colapsado (Desktop) */
        #appShell.collapsed .sidebar { width: var(--sidebar-width-collapsed); }
        #appShell.collapsed .main-wrapper { margin-left: var(--sidebar-width-collapsed); }
        #appShell.collapsed .sidebar-header { flex-direction: column; padding: 25px 10px; }
        #appShell.collapsed .logo-full { display: none; }
        
        #appShell.collapsed .logo-icon { display: flex; }
        #appShell.collapsed .desktop-toggle-btn { display: none; }
        
        /* HOVER: Troca do logótipo pequeno pelo botão de expandir */
        #appShell.collapsed .sidebar-header:hover .logo-icon { display: none; }
        #appShell.collapsed .sidebar-header:hover .desktop-toggle-btn { display: flex; margin: 0 auto; }

        #appShell.collapsed .nav-text, 
        #appShell.collapsed .nav-divider,
        #appShell.collapsed .beta-badge-nav,
        #appShell.collapsed .new-badge-nav,
        #appShell.collapsed .sidebar-version { display: none; }
        #appShell.collapsed .nav-item { justify-content: center; padding: 12px 0; width: 44px; margin: 0 auto; border-radius: var(--radius-main); }
        #appShell.collapsed .nav-item svg { margin: 0; }
        
        .nav-menu { padding: 10px 15px; display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
        .nav-divider { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin: 15px 10px 5px 10px; white-space: nowrap; }
        
        .nav-item {
            display: flex; align-items: center; gap: 12px; padding: 12px 15px; background: transparent; border: none; width: 100%; text-align: left;
            font-size: 15px; font-weight: 600; color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s ease; font-family: inherit; position: relative;
        }
        .nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .nav-item:hover { background: var(--input-bg); color: var(--primary-color); }
        .nav-item.active { background: rgba(var(--primary-rgb), 0.1); color: var(--primary-color); font-weight: 700; }
        body.dark-mode .nav-item.active, body.oled-mode .nav-item.active { background: rgba(var(--success-rgb), 0.1); color: var(--success-color); }
        body.dark-mode .nav-item:hover, body.oled-mode .nav-item:hover { color: var(--success-color); }
        .nav-item svg { stroke-width: 2.5px; flex-shrink: 0; }

        .beta-badge-nav {
            margin-left: auto; background: #FFEDD5; color: #9A3412;
            font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 12px; text-transform: uppercase;
        }
        body.dark-mode .beta-badge-nav, body.oled-mode .beta-badge-nav { background: #3B2A12; color: #F59E0B; }

        .new-badge-nav {
            margin-left: auto; background: rgba(var(--primary-rgb), 0.2); color: var(--primary-color);
            font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 12px; text-transform: uppercase;
        }
        body.dark-mode .new-badge-nav, body.oled-mode .new-badge-nav { background: rgba(var(--primary-rgb), 0.2); color: var(--primary-color); }

        .sidebar-footer { padding: 20px 15px; border-top: 1px solid var(--border-color); background: var(--card-bg); }
        .sidebar-version { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); margin-top: 15px; letter-spacing: 0.05em; text-transform: uppercase; }
        
        /* Dados do utilizador no fim do menu lateral, logo acima da versão (cartão compacto; abre as Definições) */
        .user-info {
            display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 10px; padding: 12px 8px 0 8px;
            border: 0; border-top: 1px solid var(--border-color); background: none; text-align: left; font-family: inherit; color: inherit; cursor: pointer;
        }
        .user-info:hover .user-avatar { box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18); }
        .user-avatar {
            flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%;
            background: var(--primary-color); color: #FFFFFF; font-family: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif;
            font-size: 14px; font-weight: 600; letter-spacing: 0.02em; transition: box-shadow 0.2s ease;
        }
        body.dark-mode .user-avatar, body.oled-mode .user-avatar { background: var(--success-color); color: var(--success-text); }
        .user-dados { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
        .user-linha { display: flex; align-items: center; gap: 6px; min-width: 0; }
        .user-nome { font-size: 13.5px; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
        .escola-nome { font-size: 12px; font-weight: 500; color: var(--text-muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        #appShell.collapsed .user-info { justify-content: center; padding: 12px 0 0; }
        #appShell.collapsed .user-dados { display: none; }

        .variante-badges { display: flex; flex-wrap: nowrap; gap: 3px; flex-shrink: 0; }
        .variante-badges .badge-sigla { padding: 1px 5px; border-radius: 4px; font-size: 9.5px; line-height: 1.5; letter-spacing: 0.03em; }
        .badge-lingua {
            display: inline-flex; align-items: center; gap: 6px;
            background: var(--input-bg); border: 1px solid var(--border-color);
            padding: 3px 8px 3px 3px; border-radius: var(--radius-sm);
            font-size: 11px; font-weight: 600; color: var(--text-muted);
            letter-spacing: 0.02em;
        }
        .badge-sigla {
            background: var(--primary-color); color: white;
            padding: 2px 5px; border-radius: 2px;
            font-weight: 800; font-size: 10px; text-transform: uppercase;
        }
        body.dark-mode .badge-sigla, body.oled-mode .badge-sigla {
            background: var(--success-color); color: var(--success-text);
        }
        body.dark-mode .badge-lingua, body.oled-mode .badge-lingua { background: var(--bg-color); }

        .nav-item.danger-btn:hover { background: rgba(255, 23, 68, 0.1); color: var(--danger-color); }
        body.dark-mode .nav-item.danger-btn:hover, body.oled-mode .nav-item.danger-btn:hover { background: rgba(255, 23, 68, 0.15); color: var(--danger-color); }

        .mobile-header {
            display: none; justify-content: space-between; align-items: center; padding: 15px 20px; padding-top: max(15px, env(safe-area-inset-top));
            background: var(--card-bg); border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 90;
        }
        .mobile-header img { max-height: 30px; }
        .menu-toggle { background: transparent; border: none; color: var(--text-main); cursor: pointer; display: flex; align-items: center; justify-content: center; }

        .main-wrapper { 
            margin-left: var(--sidebar-width); height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; 
            display: flex; flex-direction: column; background-color: var(--bg-color);
            transition: margin-left 0.3s ease;
        }
        .content-area { padding: 40px 5vw; max-width: 1400px; margin: 0 auto; width: 100%; flex: 1; padding-bottom: max(40px, env(safe-area-inset-bottom)); }

        .banner-container { width: 100%; margin-bottom: 35px; border-radius: var(--radius-sm); overflow: hidden; display: flex; justify-content: center;}
        .banner-container img { width: auto; max-width: 100%; height: auto; display: block; object-fit: contain; }

        /* No computador (ecrãs > 900px), oculta o banner em todas as vistas exceto no Perfil (dashboard) */
        @media (min-width: 901px) {
            body:not([data-active-view="dashboard"]) #bannerGlobalContainer {
                display: none !important;
            }
        }
        
        img.banner-light { display: block; } img.banner-dark { display: none; }
        body.dark-mode img.banner-light, body.oled-mode img.banner-light { display: none; } 
        body.dark-mode img.banner-dark, body.oled-mode img.banner-dark { display: block; }

        .app-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 40px; border-bottom: 2px solid var(--border-color); padding-bottom: 15px; }
        .title-container h2 { font-size: 36px; font-weight: 600; margin: 0; line-height: 1; color: var(--primary-color); letter-spacing: -0.02em; }
        body.dark-mode .title-container h2, body.oled-mode .title-container h2 { color: var(--success-color); }
        .title-container .subtitle { display: block; font-size: 14px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 8px; }
        .header-actions { display: flex; gap: 10px; }

        .ai-chat-header,
        .app-header {
            /* Garante que o conteúdo começa abaixo da câmara/Dynamic Island */
            padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
        }

        .top-btn {
            background: transparent; color: var(--text-main); border: 1px solid var(--border-color); height: 40px; padding: 0 15px; border-radius: var(--radius-sm);
            cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; transition: all 0.2s ease;
        }
        .top-btn.icon-only { width: 40px; padding: 0; }
        .top-btn:hover { background: var(--input-bg); border-color: var(--primary-color); color: var(--primary-color); }
        .top-btn.danger-btn:hover { background: rgba(255, 23, 68, 0.1); color: var(--danger-color); border-color: var(--danger-color); }
        body.dark-mode .top-btn.danger-btn:hover, body.oled-mode .top-btn.danger-btn:hover { background: rgba(255, 23, 68, 0.15); color: var(--danger-color); border-color: var(--danger-color); }

        /* Dashboard Profile Cards */
        .profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 25px; margin-bottom: 40px; }
        .profile-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main); padding: 25px; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
        .profile-card h3 { font-size: 14px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
        .profile-card p { font-size: 16px; font-weight: 600; margin-bottom: 5px; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
        .profile-card p svg { color: var(--primary-color); }
        body.dark-mode .profile-card p svg, body.oled-mode .profile-card p svg { color: var(--success-color); }

        /* Tool Cards */
        .app-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; margin-top: 20px; }
        .app-card {
            background: var(--card-bg); border: 2px solid var(--border-color); border-radius: calc(var(--radius-main) + 4px);
            padding: 40px 30px; text-align: center; cursor: pointer; transition: all 0.3s ease;
            display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; position: relative; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.02);
        }
        .app-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--primary-color); opacity: 0; transition: opacity 0.3s ease; }
        .app-card:hover::before { opacity: 1; }
        body.dark-mode .app-card::before, body.oled-mode .app-card::before { background: var(--success-color); }
        .app-card:hover { border-color: var(--primary-color); transform: translateY(-5px); box-shadow: 0 15px 30px rgba(var(--primary-rgb), 0.1); }
        body.dark-mode .app-card:hover, body.oled-mode .app-card:hover { box-shadow: 0 15px 30px rgba(var(--success-rgb), 0.1); border-color: var(--success-color); }
        .app-card-icon { background: var(--bg-color); width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; }
        .app-card:hover .app-card-icon { background: rgba(var(--primary-rgb), 0.1); transform: scale(1.1); }
        body.dark-mode .app-card:hover .app-card-icon, body.oled-mode .app-card:hover .app-card-icon { background: rgba(var(--success-rgb), 0.1); }
        .app-card-icon svg { color: var(--primary-color); transition: color 0.2s ease; width: 40px; height: 40px; }
        body.dark-mode .app-card-icon svg, body.oled-mode .app-card-icon svg { color: var(--success-color); }
        .app-acronym { font-size: 32px; font-weight: 800; margin: 0 0 5px 0; color: var(--text-main); letter-spacing: 0.02em; }
        .app-fullname { font-size: 15px; color: var(--text-muted); margin: 0; line-height: 1.4; font-weight: 500; }
        .beta-badge {
            position: absolute; top: 20px; right: 20px; background: rgba(255, 147, 23, 0.12); color: #B45309;
            font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.05em;
        }
        body.dark-mode .beta-badge, body.oled-mode .beta-badge { background: rgba(255, 147, 23, 0.2); color: #F59E0B; }

        /* Forms Geral */
        .form-container { background: var(--card-bg); padding: 40px; border-radius: var(--radius-main); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04); border: 1px solid var(--border-color); }
        .form-row { display: flex; gap: 25px; margin-bottom: 25px; flex-wrap: wrap; width: 100%; }
        .form-group { flex: 1; min-width: 220px; display: flex; flex-direction: column; }
        label { font-weight: 600; margin-bottom: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
        input, select, textarea, button { font-family: inherit; }
        
        input, select, textarea {
            padding: 14px 18px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 15px;
            background-color: var(--input-bg); color: var(--text-main); transition: all 0.2s ease; width: 100%; max-width: 100%; box-sizing: border-box;
        }
        select {
            -webkit-appearance: none;
            appearance: none;
            background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23475569" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
            background-repeat: no-repeat;
            background-position: right 15px center;
            background-size: 16px;
            padding-right: 40px;
        }
        body.dark-mode select, body.oled-mode select {
            background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2394A3B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
        }
        
        input[disabled], select[disabled] { opacity: 0.7; cursor: not-allowed; background-color: var(--bg-color); }
        input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
        input[type="number"] { text-align: center; font-weight: bold; }
        input:focus:not([disabled]), select:focus:not([disabled]), textarea:focus { outline: none; border-color: var(--primary-color); background-color: var(--card-bg); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15); }
        textarea { resize: vertical; min-height: 140px; line-height: 1.6; }

        /* Estilos DI - Diário do Investigador / AS MINHAS NOTAS */
        .di-tags { display: flex; gap: 10px; flex-wrap: wrap; }
        .di-tags label { margin: 0; cursor: pointer; }
        .di-tags input[type="radio"] { display: none; }
        .di-tag-pill { 
            display: inline-flex; align-items: center; gap: 6px; 
            padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; 
            border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-muted); 
            transition: all 0.2s; 
        }
        .di-tags input[type="radio"]:checked + .di-tag-pill {
            background: var(--primary-color); color: white; border-color: var(--primary-color);
        }
        body.dark-mode .di-tags input[type="radio"]:checked + .di-tag-pill,
        body.oled-mode .di-tags input[type="radio"]:checked + .di-tag-pill {
            background: var(--success-color); color: var(--success-text); border-color: var(--success-color);
        }
        
        /* Grelha de Post-its (3 a 4 por fila) */
        .di-grid-layout { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
        
        .di-note-card {
            background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); 
            padding: 20px; position: relative; transition: all 0.2s;
            display: flex; flex-direction: column; min-height: 220px; cursor: pointer;
            box-shadow: 0 4px 15px rgba(0,0,0,0.02);
        }
        .di-note-card.pinned { border-color: var(--primary-color); box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.1); }
        body.dark-mode .di-note-card.pinned, body.oled-mode .di-note-card.pinned { border-color: var(--success-color); box-shadow: 0 4px 15px rgba(var(--success-rgb), 0.1); }
        .di-note-card:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(0,0,0,0.05); border-color: var(--primary-color); }
        body.dark-mode .di-note-card:hover, body.oled-mode .di-note-card:hover { border-color: var(--success-color); box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
        
        .di-note-header { display: flex; justify-content: space-between; margin-bottom: 12px; align-items: flex-start;}
        .di-note-date { font-size: 11px; color: var(--text-muted); font-weight: 600; display: block; margin-top: 5px;}
        .di-note-text-preview { font-size: 15px; line-height: 1.6; color: var(--text-main); white-space: pre-wrap; flex: 1; overflow: hidden; display: -webkit-box; line-clamp: 5; -webkit-line-clamp: 5; -webkit-box-orient: vertical; }
        
        /* Menu de Três Pontos (...) e Dropdown */
        .di-menu-container { position: relative; display: inline-block; }
        .di-dropdown-menu {
            display: none; position: absolute; right: 0; top: 100%; 
            background: var(--card-bg); border: 1px solid var(--border-color); 
            border-radius: var(--radius-sm); box-shadow: 0 10px 25px rgba(0,0,0,0.15); 
            z-index: 100; min-width: 140px; overflow: hidden;
            animation: popIn 0.15s ease-out forwards;
        }
        .di-dropdown-menu.show { display: block; }
        .di-dropdown-item {
            padding: 10px 15px; font-size: 13px; font-weight: 600; color: var(--text-main); 
            background: transparent; border: none; width: 100%; text-align: left; cursor: pointer;
            display: flex; align-items: center; gap: 8px; transition: background 0.2s;
        }
        .di-dropdown-item:hover { background: var(--input-bg); color: var(--primary-color); }
        body.dark-mode .di-dropdown-item:hover, body.oled-mode .di-dropdown-item:hover { color: var(--success-color); }
        .di-dropdown-item.danger:hover { background: rgba(255, 23, 68, 0.1); color: var(--danger-color); }

        .di-feed-pill {
            border: 1px solid var(--primary-color); color: var(--primary-color); background: rgba(var(--primary-rgb), 0.05); 
            padding: 4px 10px; font-size: 11px; border-radius: 20px; font-weight: 700; display: inline-block;
        }
        body.dark-mode .di-feed-pill, body.oled-mode .di-feed-pill { border-color: var(--success-color); color: var(--success-color); background: rgba(var(--success-rgb), 0.05); }

        /* Estilos Atlas AI Chat Input */
        .ai-input-wrapper { display: flex; gap: 12px; align-items: flex-end; background: var(--input-bg); padding: 8px 8px 8px 18px; border-radius: 24px; border: 1px solid var(--border-color); transition: all 0.2s ease; }
        .ai-input-wrapper:focus-within { border-color: var(--primary-color); background: var(--card-bg); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15); }
        #ai-input:focus { box-shadow: none !important; border: none !important; background: transparent !important; }

        button.gerar-btn {
            background-color: var(--primary-color); color: white; border: none; padding: 16px 32px; font-size: 16px; font-weight: 600;
            letter-spacing: 0.02em; border-radius: var(--radius-sm); cursor: pointer; width: 100%; margin-top: 15px;
            transition: all 0.2s ease; box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.15); display: flex; justify-content: center; align-items: center; gap: 10px;
        }
        button.gerar-btn:hover { background-color: var(--hover-color); box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.25); transform: translateY(-2px); }

        /* Lista de Relatorios */
        .report-list { display: flex; flex-direction: column; gap: 15px; }
        .report-item { 
            background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); 
            padding: 20px; display: flex; justify-content: space-between; align-items: center; transition: all 0.2s;
        }
        .report-item:hover { border-color: var(--primary-color); }
        .report-info h4 { margin: 0 0 5px 0; font-size: 18px; color: var(--primary-color); display: flex; align-items: center; gap: 8px;}
        body.dark-mode .report-info h4, body.oled-mode .report-info h4 { color: var(--success-color); }
        .report-info p { margin: 0; font-size: 14px; color: var(--text-muted); }
        .report-actions { display: flex; gap: 10px; }
        .empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); border: 2px dashed var(--border-color); border-radius: var(--radius-main); }

        .section-subtitle { font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 15px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border-color); padding-bottom: 8px; display: flex; align-items: center; }
        .info-btn { background: var(--input-bg); color: var(--text-muted); border: 1px solid var(--border-color); border-radius: 50%; width: 22px; height: 22px; font-size: 12px; font-weight: bold; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; margin-left: 10px; transition: all 0.2s; flex-shrink: 0; }
        .info-btn:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }
        
        .total-board { display: flex; flex-direction: row; gap: 15px; justify-content: space-between; align-items: stretch; width: 100%; }
        .total-board > span { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 12px; }
        .total-board > span > span { font-size: 20px; font-weight: 800; color: var(--primary-color); }
        body.dark-mode .total-board > span > span, body.oled-mode .total-board > span > span { color: var(--success-color); }
        .total-board > span:last-child { background: var(--text-main); border-color: var(--text-main); color: var(--card-bg); }
        .total-board > span:last-child > span { color: var(--card-bg) !important; font-size: 22px; font-weight: 800; }

        /* Modals */
        .modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--modal-backdrop); backdrop-filter: blur(4px); z-index: 10000; justify-content: center; align-items: center; padding: 20px; opacity: 0; transition: opacity 0.25s ease-out; }
        .modal-overlay.show { display: flex; opacity: 1; }
        .modal-content { background: var(--card-bg); padding: 0; border-radius: var(--radius-main); width: 100%; max-width: 900px; max-height: 95vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); border: 1px solid var(--border-color); transform: scale(0.98) translateY(10px); transition: transform 0.2s ease-out; }
        .modal-content.modal-sm { max-width: 450px; height: auto; text-align: center; }
        .modal-content.modal-md { max-width: 550px; height: auto; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; background: var(--card-bg); padding: 20px 30px; border-bottom: 1px solid var(--border-color); z-index: 2; flex-shrink: 0; }
        .modal-header h3 { margin: 0; color: var(--text-main); font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
        .close-btn { background: var(--input-bg); color: var(--text-muted); width: 36px; height: 36px; display: flex; justify-content: center; align-items: center; padding: 0; margin: 0; font-size: 20px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: all 0.2s; }
        .close-btn:hover { background: var(--danger-color); color: white; border-color: var(--danger-color); }
        .preview-container { background-color: var(--preview-bg); padding: 40px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; align-items: center; -webkit-overflow-scrolling: touch; }
        .modal-body { padding: 30px; color: var(--text-main); font-size: 16px; line-height: 1.6; overflow-y: auto; -webkit-overflow-scrolling: touch; }
        .modal-body li { margin-bottom: 12px; } 
        .modal-body strong { color: var(--primary-color); } 
        body.dark-mode .modal-body strong, body.oled-mode .modal-body strong { color: var(--success-color); }
        .modal-footer { padding: 20px 30px; background: var(--card-bg); border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 15px; z-index: 2; flex-shrink: 0; flex-wrap: wrap; }
        
        .btn-secondary { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); padding: 12px 24px; font-size: 15px; font-weight: 600; border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s ease; }
        .btn-secondary:hover { background: var(--input-bg); border-color: var(--text-muted); }
        .btn-primary { background-color: var(--primary-color); color: white; border: none; padding: 12px 28px; font-size: 15px; font-weight: 700; border-radius: var(--radius-sm); cursor: pointer; box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2); transition: all 0.2s ease; display: flex; align-items: center; gap: 8px; justify-content: center; }
        .btn-primary:hover { background-color: var(--hover-color); box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.5); }
        .download-btn { background-color: var(--success-color); color: var(--success-text); border: none; padding: 12px 28px; font-size: 15px; font-weight: 700; border-radius: var(--radius-sm); cursor: pointer; box-shadow: 0 4px 12px rgba(var(--success-rgb), 0.2); transition: all 0.2s ease; display: flex; align-items: center; gap: 8px; justify-content: center; }
        .download-btn:hover { background-color: var(--success-hover); box-shadow: 0 0 15px rgba(var(--success-rgb), 0.5); }
        .btn-danger { background-color: var(--danger-color); color: var(--danger-text); box-shadow: 0 4px 12px rgba(255, 23, 68, 0.2); }
        .btn-danger:hover { background-color: var(--danger-hover); box-shadow: 0 0 15px rgba(255, 23, 68, 0.5); }

        /* Seletores em Chip do Modal de Perfil */
        .pill-selector-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
            gap: 8px;
            margin-top: 6px;
        }

        .pill-checkbox-card {
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--input-bg);
            border: 1px solid var(--border-color);
            padding: 10px 14px;
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-main);
            transition: all 0.2s ease;
            user-select: none;
        }

        .pill-checkbox-card input[type="checkbox"] {
            width: 16px;
            height: 16px;
            margin: 0;
            accent-color: var(--primary-color);
            cursor: pointer;
        }

        .pill-checkbox-card:hover {
            border-color: var(--primary-color);
            background: var(--card-bg);
        }

        body.dark-mode .pill-checkbox-card:hover,
        body.oled-mode .pill-checkbox-card:hover {
            border-color: var(--success-color);
        }

        .helper-text {
            font-size: 11px;
            color: var(--text-muted);
            font-weight: 500;
            margin-top: 4px;
            display: block;
            letter-spacing: normal;
            text-transform: none;
        }
        
        /* A4 Preview Sheet */
        .a4-preview { background: #ffffff; width: 100%; max-width: 750px; padding: 60px 50px; border-radius: 2px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); font-family: 'Helvetica', 'Arial', sans-serif; color: #000000; text-align: left;}
        .a4-logo-header { text-align: center; margin-bottom: 25px; } .a4-logo-header img { width: 426px; max-width: 100%; height: auto; }
        .a4-title { text-align: center; font-size: 22px; font-weight: bold; margin-bottom: 35px; color: #111; }
        .a4-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 15px; margin-bottom: 25px; font-size: 13.5px; color: #111; }
        .a4-grid strong { color: #444; }
        .a4-divider { border-bottom: 2px solid #eaeaea; margin: 25px 0; }
        .a4-section-title { font-size: 12px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.05em; margin: 25px 0 10px 0; color: #ffffff; background-color: var(--primary-color); padding: 6px 10px; border-radius: 2px; }
        .a4-text-block { font-size: 13.5px; white-space: pre-wrap; line-height: 1.7; text-align: justify; color: #111; }

        /* --- ESTILOS DO ACORDEÃO (DEFINIÇÕES) --- */
        .accordion-header {
            display: flex; align-items: center; justify-content: space-between;
            background: var(--input-bg); padding: 15px 20px; border-radius: var(--radius-sm);
            border: 1px solid var(--border-color); cursor: pointer; font-weight: 700; color: var(--text-main);
            transition: all 0.2s; margin-bottom: 10px; font-size: 15px;
            position: relative; z-index: 2;
        }
        .accordion-header:hover { border-color: var(--primary-color); }
        .accordion-content {
            display: none; padding: 20px; border: 1px solid var(--border-color);
            border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
            margin-top: -11px; margin-bottom: 20px; background: var(--card-bg);
            animation: fadeIn 0.3s ease; position: relative; z-index: 1;
        }
        .accordion-content.active { 
            display: block; 
            border-color: var(--primary-color); 
        }
        .accordion-header.active {
            border-bottom-left-radius: 0; border-bottom-right-radius: 0;
            background: rgba(var(--primary-rgb), 0.05); border-color: var(--primary-color); color: var(--primary-color);
        }
        body.dark-mode .accordion-header.active, body.oled-mode .accordion-header.active {
            background: rgba(var(--success-rgb), 0.05); border-color: var(--success-color); color: var(--success-color);
        }
        body.dark-mode .accordion-content.active, body.oled-mode .accordion-content.active {
            border-color: var(--success-color);
        }
        .accordion-icon { transition: transform 0.3s; color: var(--text-muted); }
        .accordion-header.active .accordion-icon { transform: rotate(180deg); color: inherit; }
        
        /* VIEW SOBRE (Estilos específicos) */
        #view-sobre h1 { font-size: 32px; font-weight: 600; margin: 0 0 25px 0; letter-spacing: -0.04em; color: var(--text-main); }
        #view-sobre p { font-size: 16px; margin-bottom: 15px; }
        #view-sobre ul { margin-bottom: 25px; padding-left: 20px; }
        #view-sobre li { font-size: 16px; margin-bottom: 8px; }
        
        .link-notas { color: var(--primary-color); text-decoration: none; font-weight: 600; font-size: 14px; transition: opacity 0.2s ease; }
        .link-notas:hover { text-decoration: underline; opacity: 0.8; }
        body.dark-mode .link-notas, body.oled-mode .link-notas { color: var(--success-color); }
        
        .legal-box { background-color: var(--input-bg); border: 1px solid var(--border-color); padding: 25px; border-radius: var(--radius-sm); margin-top: 30px; margin-bottom: 30px; }
        .legal-box h2 { font-size: 20px; font-weight: 700; margin-top: 0; margin-bottom: 15px; color: var(--text-main); }
        .legal-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
        .legal-box p:last-child { margin-bottom: 0; }
        .legal-box strong { color: var(--text-main); }
        
        .bottom-logos { display: flex; align-items: center; gap: 50px; margin-top: 30px; flex-wrap: wrap; }
        .bottom-logos img { width: auto; transition: transform 0.3s ease; }
        .bottom-logos img:hover { transform: scale(1.03); }
        .logo-atlas { height: 70px; } .logo-flup { height: 70px; } .logo-meci { height: 75px; }

        /* --- PÁGINA DEFINIÇÕES --- */
        .def-pagina { max-width: 860px; }
        .def-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 24px; }
        .def-nav button {
            display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
            background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-main);
            font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s ease;
        }
        .def-nav button svg { width: 16px; height: 16px; color: var(--text-muted); }
        /* Sem o retângulo de destaque do toque no Android (não respeita os cantos arredondados);
           com teclado, o foco continua visível com um contorno arredondado */
        .def-nav button, .horario-vista-toggle button, .faixa-item, .user-info, .guia-ponto, .guia-acao, .guia-banner .btn-primary {
            -webkit-tap-highlight-color: transparent;
        }
        .def-nav button:focus, .horario-vista-toggle button:focus, .faixa-item:focus, .user-info:focus { outline: none; }
        .def-nav button:focus-visible, .horario-vista-toggle button:focus-visible, .faixa-item:focus-visible, .user-info:focus-visible {
            box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.35);
        }
        body.dark-mode .def-nav button:focus-visible, body.oled-mode .def-nav button:focus-visible,
        body.dark-mode .horario-vista-toggle button:focus-visible, body.oled-mode .horario-vista-toggle button:focus-visible,
        body.dark-mode .faixa-item:focus-visible, body.oled-mode .faixa-item:focus-visible,
        body.dark-mode .user-info:focus-visible, body.oled-mode .user-info:focus-visible { box-shadow: 0 0 0 3px rgba(var(--success-rgb), 0.35); }
        .def-nav button:hover { border-color: var(--primary-color); color: var(--primary-color); }
        .def-nav button.ativo, .def-nav button.ativo:hover { background: var(--primary-color); border-color: var(--primary-color); color: #FFFFFF; }
        .def-nav button.ativo svg, .def-nav button.ativo:hover svg { color: #FFFFFF; }
        body.dark-mode .def-nav button.ativo, body.oled-mode .def-nav button.ativo,
        body.dark-mode .def-nav button.ativo:hover, body.oled-mode .def-nav button.ativo:hover { background: var(--success-color); border-color: var(--success-color); color: var(--success-text); }
        body.dark-mode .def-nav button.ativo svg, body.oled-mode .def-nav button.ativo svg { color: var(--success-text); }
        /* Só a secção escolhida nos separadores fica visível */
        .def-secao { display: none; }
        .def-secao.ativa { display: block; animation: containerFadeIn 0.25s ease-out; }
        .def-nav button:hover svg { color: var(--primary-color); }
        body.dark-mode .def-nav button:hover, body.oled-mode .def-nav button:hover { border-color: var(--success-color); color: var(--success-color); }
        body.dark-mode .def-nav button:hover svg, body.oled-mode .def-nav button:hover svg { color: var(--success-color); }

        .def-secao {
            background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02); padding: 28px; margin-bottom: 24px; scroll-margin-top: 20px;
        }
        .def-secao-cabecalho { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border-color); }
        .def-secao-icone {
            display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px;
            border-radius: var(--radius-sm); background: rgba(var(--primary-rgb), 0.1); color: var(--primary-color);
        }
        .def-secao-icone svg { width: 20px; height: 20px; }
        body.dark-mode .def-secao-icone, body.oled-mode .def-secao-icone { background: rgba(var(--success-rgb), 0.1); color: var(--success-color); }
        .def-secao-cabecalho h3 { font-size: 20px; font-weight: 600; color: var(--text-main); margin: 0 0 4px; }
        .def-secao-cabecalho p { font-size: 14px; color: var(--text-muted); margin: 0; }
        .def-acoes { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border-color); }
        @media (max-width: 600px) {
            .def-secao { padding: 20px 16px; }
            .def-acoes .btn-primary { width: 100%; }
        }

        .backup-contagem { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--text-muted); }
        .backup-selecao { color: var(--primary-color); font-weight: 600; text-decoration: none; }
        body.dark-mode .backup-selecao, body.oled-mode .backup-selecao { color: var(--success-color); }

        /* O contentor do modal recebe o foco ao abrir (leitores de ecrã); não precisa de contorno visível */
        .modal-content:focus { outline: none; }

        /* --- GUIA DO ATLAS --- */
        .guia-banner {
            display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin: 10px 0 24px;
            border-radius: var(--radius-main); border: 1px solid rgba(var(--primary-rgb), 0.25);
            background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(var(--primary-rgb), 0.02));
        }
        .guia-banner-icone {
            flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 52px; height: 52px;
            border-radius: 16px; background: var(--primary-color); color: #FFFFFF; box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.3);
        }
        .guia-banner-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
        .guia-banner-texto strong { font-family: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif; font-size: 18px; font-weight: 600; color: var(--text-main); }
        .guia-banner-texto span { font-size: 14px; color: var(--text-muted); }
        body.dark-mode .guia-banner, body.oled-mode .guia-banner {
            border-color: rgba(var(--success-rgb), 0.25); background: linear-gradient(135deg, rgba(var(--success-rgb), 0.08), rgba(var(--success-rgb), 0.01));
        }
        body.dark-mode .guia-banner-icone, body.oled-mode .guia-banner-icone { background: var(--success-color); color: var(--success-text); box-shadow: 0 8px 20px rgba(var(--success-rgb), 0.2); }
        @media (max-width: 600px) {
            .guia-banner { flex-wrap: wrap; }
            .guia-banner .btn-primary { width: 100%; }
        }

        .guia-modal { --guia-cor: #3B82F6; max-width: 580px; padding: 0; overflow: hidden; }
        .guia-cabecalho { padding: 16px 22px; background: var(--card-bg); }
        .guia-nome { font-weight: 700; font-size: 14px; color: var(--text-main); }
        .guia-contador {
            font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
            color: var(--guia-cor); background: color-mix(in srgb, var(--guia-cor) 12%, transparent);
        }
        .guia-progresso { height: 3px; background: var(--border-color); }
        .guia-progresso span { display: block; height: 100%; width: 0; background: var(--guia-cor); transition: width 0.35s ease, background 0.35s ease; }
        .guia-corpo { padding: 28px 26px 22px; min-height: 380px; text-align: left; touch-action: pan-y; }
        .guia-slide { animation: guiaEntrar 0.35s ease both; }
        @keyframes guiaEntrar { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
        .guia-hero { text-align: center; margin-bottom: 22px; }
        .guia-icone {
            display: flex; align-items: center; justify-content: center; width: 76px; height: 76px; margin: 0 auto 16px;
            border-radius: 24px; color: var(--guia-cor);
            background: color-mix(in srgb, var(--guia-cor) 14%, transparent);
            box-shadow: 0 12px 30px color-mix(in srgb, var(--guia-cor) 22%, transparent);
        }
        .guia-icone svg { width: 34px; height: 34px; }
        .guia-badge {
            display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
            letter-spacing: 0.06em; text-transform: uppercase; color: var(--guia-cor);
            background: color-mix(in srgb, var(--guia-cor) 10%, transparent);
        }
        .guia-titulo { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; color: var(--text-main); margin: 12px 0 6px; }
        .guia-subtitulo { font-size: 14.5px; color: var(--text-muted); max-width: 420px; margin: 0 auto; line-height: 1.5; }
        .guia-pontos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
        .guia-pontos li {
            display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; color: var(--text-main);
            background: var(--input-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main);
        }
        .guia-pontos li svg {
            flex-shrink: 0; width: 20px; height: 20px; padding: 3px; border-radius: 50%; margin-top: 0;
            color: var(--guia-cor); background: color-mix(in srgb, var(--guia-cor) 14%, transparent);
        }
        .guia-acao {
            display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; padding: 4px 0; background: none; border: 0;
            font-family: inherit; font-size: 14px; font-weight: 700; color: var(--guia-cor); cursor: pointer;
        }
        .guia-acao:hover { text-decoration: underline; }
        .guia-rodape { padding: 14px 22px; background: var(--card-bg); display: flex; justify-content: space-between; align-items: center; }
        .guia-indicadores { display: flex; gap: 6px; align-items: center; }
        .guia-ponto { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 4px; background: var(--border-color); cursor: pointer; transition: all 0.3s ease; }
        .guia-ponto.ativo { width: 22px; background: var(--guia-cor); }
        @media (max-width: 600px) {
            .guia-corpo { padding: 22px 18px 18px; min-height: 0; }
            .guia-titulo { font-size: 21px; }
            .guia-indicadores { display: none; }
            .guia-rodape { justify-content: flex-end; }
        }
        @media (prefers-reduced-motion: reduce) { .guia-slide { animation: none; } }

        /* Estilos da secção Ajuda (perguntas frequentes) */
        .faq-search-container { text-align: center; margin-bottom: 40px; padding: 20px 0; }
        .faq-search-container h3 { font-size: 28px; color: var(--text-main); margin-bottom: 20px; font-weight: 600; letter-spacing: -0.02em; }
        body.dark-mode .faq-search-container h3, body.oled-mode .faq-search-container h3 { color: var(--success-color); }
        .faq-search-input { 
            width: 100%; max-width: 600px; padding: 16px 25px; border-radius: 30px; 
            border: 2px solid var(--border-color); font-size: 16px; background: var(--card-bg); 
            color: var(--text-main); box-shadow: 0 10px 30px rgba(0,0,0,0.03); transition: all 0.3s ease; 
        }
        .faq-search-input:focus { border-color: var(--primary-color); box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.1); outline: none; }
        body.dark-mode .faq-search-input:focus, body.oled-mode .faq-search-input:focus { border-color: var(--success-color); box-shadow: 0 10px 30px rgba(var(--success-rgb), 0.1); }
        
        .faq-category { margin-bottom: 35px; }
        .faq-category-title { font-size: 18px; font-weight: 700; color: var(--primary-color); margin-bottom: 15px; border-bottom: 2px solid var(--border-color); padding-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
        body.dark-mode .faq-category-title, body.oled-mode .faq-category-title { color: var(--success-color); }
        
        .faq-item { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-bottom: 12px; transition: all 0.2s ease; }
        .faq-item:hover { border-color: var(--primary-color); }
        body.dark-mode .faq-item:hover, body.oled-mode .faq-item:hover { border-color: var(--success-color); }
        .faq-item summary { padding: 18px 22px; font-weight: 600; font-size: 16px; cursor: pointer; color: var(--text-main); list-style: none; display: flex; justify-content: space-between; align-items: center; transition: background 0.2s; user-select: none; }
        .faq-item summary::-webkit-details-marker { display: none; }
        .faq-item summary::after { content: '+'; font-size: 24px; color: var(--primary-color); font-weight: 400; transition: transform 0.3s; line-height: 1; }
        body.dark-mode .faq-item summary::after, body.oled-mode .faq-item summary::after { color: var(--success-color); }
        .faq-item[open] summary::after { transform: rotate(45deg); }
        .faq-item summary:hover { background: var(--input-bg); border-radius: var(--radius-sm); }
        
        .faq-answer { padding: 0 22px 22px 22px; font-size: 15px; color: var(--text-muted); line-height: 1.6; border-top: 1px solid transparent; animation: popIn 0.3s ease-out forwards; }
        .faq-item[open] .faq-answer { border-top-color: var(--border-color); padding-top: 18px; }
        .faq-answer strong { color: var(--text-main); }
        .faq-answer ul { margin-top: 10px; padding-left: 20px; }
        .faq-answer li { margin-bottom: 5px; }
        
        .bottom-nav-bar { display: none; }
        .floating-more-menu, .menu-mais-fundo { display: none; }

        /* Responsive / Mobile */
        @media (max-width: 900px) {
            html, body { height: auto; min-height: 100%; overflow: auto; }
            #landingContainer { position: static; min-height: 100vh; overflow: visible; }
            #appShell { position: static; height: auto; overflow: visible; }
            
            .main-wrapper { margin-left: 0 !important; height: auto; overflow: visible; }
            
            /* REMOVE A SIDEBAR E O MENU ANTIGO NO MOBILE */
            .mobile-header { display: none !important; }
            .sidebar { display: none !important; }
            .sidebar-overlay { display: none !important; }
            
            .content-area { 
                padding-top: max(35px, env(safe-area-inset-top)) !important; 
                padding-bottom: max(110px, env(safe-area-inset-bottom) + 90px) !important; 
            }
            #loadingContainer { position: fixed; z-index: 9999; }

            /* --- ESTILOS DO BOTTOM NAV BAR (LIQUID GLASS) --- */
            .bottom-nav-bar {
                display: flex; position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
                width: calc(100% - 30px); max-width: 500px; justify-content: space-between; align-items: center;
                background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(255, 255, 255, 0.4);
                backdrop-filter: blur(25px) saturate(200%); -webkit-backdrop-filter: blur(25px) saturate(200%);
                border-radius: 35px; box-shadow: 0 15px 45px rgba(0, 0, 0, 0.1); padding: 8px 10px; z-index: 9000;
            }
            body.dark-mode .bottom-nav-bar {
                background: rgba(13, 22, 41, 0.75); border-color: rgba(255, 255, 255, 0.05); box-shadow: 0 15px 45px rgba(0, 0, 0, 0.4);
            }
            body.oled-mode .bottom-nav-bar {
                background: rgba(5, 5, 5, 0.75); border-color: rgba(255, 255, 255, 0.1); box-shadow: 0 15px 45px rgba(255, 255, 255, 0.02);
            }

            /* --- A bolha (indicador) ---
               Posição, tamanho e forma são calculados a cada fotograma em JS (física de mola), para a bolha seguir o
               dedo sem atraso, crescer para lá da barra quando é agarrada e encaixar com um ressalto ao largar. */
            .bottom-nav-bar { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
            .nav-indicator {
                position: absolute; top: 0; left: 0; width: 0; height: 0;
                background: rgba(var(--primary-rgb), 0.08); border-radius: 24px;
                box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.05);
                z-index: 1; pointer-events: none; transform-origin: 0 0; will-change: transform;
                transition: background-color 0.2s ease, box-shadow 0.2s ease;
            }
            body.dark-mode .nav-indicator, body.oled-mode .nav-indicator {
                background: rgba(var(--success-rgb), 0.08); box-shadow: inset 0 0 0 1px rgba(var(--success-rgb), 0.05);
            }
            /* Agarrada: lente de vidro que se sobrepõe à barra */
            .nav-indicator.agarrada {
                background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12)), rgba(var(--primary-rgb), 0.10);
                box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), inset 0 2px 10px rgba(255, 255, 255, 0.6), 0 10px 28px rgba(11, 25, 44, 0.16), 0 0 0 0.5px rgba(var(--primary-rgb), 0.12);
                backdrop-filter: blur(4px) saturate(180%); -webkit-backdrop-filter: blur(4px) saturate(180%);
            }
            body.dark-mode .nav-indicator.agarrada, body.oled-mode .nav-indicator.agarrada {
                background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.03)), rgba(var(--success-rgb), 0.12);
                box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), inset 0 2px 10px rgba(255, 255, 255, 0.08), 0 10px 28px rgba(0, 0, 0, 0.45);
            }

            .bottom-nav-item {
                background: transparent; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
                gap: 4px; color: var(--text-muted); padding: 8px 5px; border-radius: 24px; cursor: pointer; flex: 1;
                position: relative; z-index: 2; outline: none; -webkit-tap-highlight-color: transparent; /* Remove o retângulo de clique no Android */
            }
            @media (hover: hover) { .bottom-nav-item:hover { color: var(--text-main); } }

            /* A cor de destaque vem de uma cópia dos ícones recortada pela forma da bolha: fica colorido exatamente
               o que está debaixo da bolha (meio ícone, se a bolha só cobrir metade). */
            .nav-cor-janela {
                position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 3; pointer-events: none;
                overflow: hidden; border-radius: 24px; transform-origin: 0 0; will-change: transform;
            }
            .nav-cor {
                position: absolute; top: 0; left: 0; box-sizing: border-box; pointer-events: none; transform-origin: 0 0; will-change: transform;
                display: flex; justify-content: space-between; align-items: center;
                color: var(--primary-color);
            }
            body.dark-mode .nav-cor, body.oled-mode .nav-cor { color: var(--success-color); }
            .nav-cor .bottom-nav-item { color: inherit; cursor: default; }

            .bottom-nav-item svg { width: 22px; height: 22px; margin-bottom: 2px; }
            .bottom-nav-item span { font-size: 10px; font-weight: 700; letter-spacing: 0.02em; font-family: inherit; }

            /* --- MENU "MAIS" (LIQUID GLASS): painel com a largura da barra inferior, por cima dela --- */
            .menu-mais-fundo {
                display: block; position: fixed; inset: 0; z-index: 8998; background: rgba(11, 25, 44, 0.08);
                opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
            }
            .menu-mais-fundo.show { opacity: 1; pointer-events: auto; }
            .floating-more-menu {
                display: block; position: fixed; left: 50%; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 84px);
                width: calc(100% - 30px); max-width: 500px; max-height: calc(100dvh - 140px); overflow-y: auto;
                background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(255, 255, 255, 0.4);
                backdrop-filter: blur(25px) saturate(200%); -webkit-backdrop-filter: blur(25px) saturate(200%);
                box-shadow: 0 15px 45px rgba(0, 0, 0, 0.1); border-radius: 28px; z-index: 8999; padding: 16px;
                transform: translateX(-50%) translateY(16px) scale(0.98); opacity: 0; pointer-events: none;
                transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease; transform-origin: bottom center;
            }
            .floating-more-menu.show { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; pointer-events: auto; }
            body.dark-mode .floating-more-menu { background: rgba(13, 22, 41, 0.75); border-color: rgba(255, 255, 255, 0.05); box-shadow: 0 15px 45px rgba(0, 0, 0, 0.4); }
            body.oled-mode .floating-more-menu { background: rgba(5, 5, 5, 0.75); border-color: rgba(255, 255, 255, 0.1); box-shadow: 0 15px 45px rgba(255, 255, 255, 0.02); }
            body.dark-mode .menu-mais-fundo, body.oled-mode .menu-mais-fundo { background: rgba(0, 0, 0, 0.2); }

            .menu-mais-grupo {
                font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
                color: var(--text-muted); margin: 2px 4px 8px;
            }
            .menu-mais-grelha { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
            .menu-mais-grelha.colunas-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
            .menu-mais-item {
                display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px;
                background: transparent; border: 0; border-radius: 16px; cursor: pointer; font-family: inherit;
                font-size: 12px; font-weight: 600; color: var(--text-main); text-align: center; line-height: 1.2;
                -webkit-tap-highlight-color: transparent; transition: background 0.2s ease;
            }
            .menu-mais-item:active, .menu-mais-item:hover { background: rgba(var(--primary-rgb), 0.06); }
            .menu-mais-icone {
                display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 14px;
                background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.7); color: var(--primary-color);
                box-shadow: 0 2px 8px rgba(11, 25, 44, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.6);
            }
            .menu-mais-icone svg { width: 22px; height: 22px; }
            body.dark-mode .menu-mais-icone, body.oled-mode .menu-mais-icone {
                color: var(--success-color); background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.08);
                box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
            }
            body.dark-mode .menu-mais-item:active, body.oled-mode .menu-mais-item:active,
            body.dark-mode .menu-mais-item:hover, body.oled-mode .menu-mais-item:hover { background: rgba(var(--success-rgb), 0.06); }

            .menu-mais-rodape { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding-top: 12px; border-top: 1px solid rgba(11, 25, 44, 0.08); }
            body.dark-mode .menu-mais-rodape, body.oled-mode .menu-mais-rodape { border-top-color: rgba(255, 255, 255, 0.08); }
            .menu-mais-acao {
                display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 46px; padding: 11px 14px; border-radius: 14px;
                white-space: nowrap; line-height: 1.2;
                background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.7); color: var(--text-main);
                box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
                font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent;
            }
            body.dark-mode .menu-mais-acao, body.oled-mode .menu-mais-acao {
                background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.08); box-shadow: none;
            }
            .menu-mais-acao svg { width: 17px; height: 17px; flex-shrink: 0; }
            .menu-mais-acao span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
            @media (max-width: 380px) {
                .menu-mais-acao { font-size: 13px; padding: 11px 10px; gap: 6px; }
            }
            /* Etiqueta "Beta" presa ao canto superior direito do quadrado do ícone */
            .menu-mais-icone { position: relative; }
            .menu-mais-beta {
                position: absolute; top: -7px; right: -13px; padding: 1px 5px; border-radius: 6px;
                font-size: 8.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.4;
                background: #FFEDD5; color: #B45309; border: 1.5px solid #FFFFFF; box-shadow: 0 1px 3px rgba(11, 25, 44, 0.12);
            }
            body.dark-mode .menu-mais-beta, body.oled-mode .menu-mais-beta { background: #3B2A12; color: #F59E0B; border-color: var(--card-bg); }
            .menu-mais-acao.perigo, body.dark-mode .menu-mais-acao.perigo, body.oled-mode .menu-mais-acao.perigo {
                color: var(--danger-color); background: rgba(255, 23, 68, 0.08); border-color: rgba(255, 23, 68, 0.2);
            }
        }
        
        @media (max-width: 600px) {
            .content-area { padding: 25px 15px; padding-bottom: max(35px, env(safe-area-inset-bottom)); }
            .form-container { padding: 25px 15px; }
            input, select, textarea { font-size: 16px; width: 100%; max-width: 100%; box-sizing: border-box; }
            
            .app-header { flex-direction: column; align-items: stretch; gap: 15px; margin-bottom: 25px; }
            /* Dashboard: o sino das notificações fica no canto, ao lado da saudação */
            #view-dashboard .app-header { position: relative; }
            #view-dashboard .title-container h2 { padding-right: 52px; }
            #view-dashboard .app-header .header-actions { position: absolute; top: 0; right: 0; width: auto; }
            #view-dashboard .app-header .header-actions .top-btn { flex: 0 0 auto; width: 44px; height: 44px; }
            .header-actions { flex-wrap: wrap; width: 100%; }
            .header-actions .top-btn { white-space: nowrap; }
            .top-btn { flex: 1; justify-content: center; }
            .title-container h2 { font-size: 28px; }
            
            .app-card { padding: 25px 20px; }
            
            .form-row { gap: 15px; margin-bottom: 15px; flex-direction: column; width: 100%; margin-left: 0; margin-right: 0; }
            .form-group { min-width: 0 !important; width: 100%; max-width: 100%; }
            .form-row.hours-row { flex-direction: row; flex-wrap: wrap; gap: 10px; }
            .form-row.hours-row .form-group { flex: 1 1 30%; min-width: 60px !important; }
            
            .total-board { flex-direction: column; gap: 12px; }
            .total-board > span { width: 100%; flex-direction: row; justify-content: space-between; padding: 15px; }
            
            .a4-preview { padding: 30px 20px; }
            .a4-grid { grid-template-columns: 1fr; gap: 10px; }
            
            .modal-footer { flex-direction: column; }
            .modal-footer button { width: 100%; justify-content: center; }
            
            .report-item { flex-direction: column; align-items: flex-start; gap: 15px; }
            .report-actions { width: 100%; }
            .report-actions button { flex: 1; }
            
            .bottom-logos { gap: 35px; justify-content: flex-start; } 
            .logo-atlas, .logo-flup, .logo-meci { height: 30px; }
        }

            /* --- ESTILOS GESTÃO DE TURMAS --- */
        .turmas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
        .turma-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: calc(var(--radius-main) + 2px); padding: 25px; position: relative; transition: all 0.3s ease; display: flex; flex-direction: column; gap: 15px; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
        .turma-card:hover { border-color: var(--primary-color); transform: translateY(-4px); box-shadow: 0 15px 30px rgba(var(--primary-rgb), 0.1); }
        body.dark-mode .turma-card:hover, body.oled-mode .turma-card:hover { border-color: var(--success-color); box-shadow: 0 15px 30px rgba(var(--success-rgb), 0.1); }
        .turma-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 5px; }
        .turma-title { font-size: 26px; font-weight: 800; color: var(--text-main); margin: 0; line-height: 1.1; letter-spacing: -0.02em; }
        .turma-badge { font-size: 11px; font-weight: 800; background: rgba(var(--primary-rgb), 0.1); color: var(--primary-color); padding: 5px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.05em; }
        body.dark-mode .turma-badge, body.oled-mode .turma-badge { background: rgba(var(--success-rgb), 0.1); color: var(--success-color); }
        .turma-stats { display: flex; flex-wrap: wrap; gap: 15px; font-size: 14px; color: var(--text-muted); font-weight: 600; }
        .turma-stats span { display: flex; align-items: center; gap: 6px; background: var(--input-bg); padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
        .turma-desc { font-size: 14px; color: var(--text-main); line-height: 1.6; display: -webkit-box; line-clamp: 3; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 5px; }
        
        /* O Efeito Quadro de Giz para a Planta da Sala */
        .chalkboard-input {
            background-color: #1e293b !important;
            color: #a6e22e !important;
            font-family: 'Courier New', Courier, monospace !important;
            border: 4px solid #0f172a !important;
            border-radius: 8px;
            padding: 20px !important;
            box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
            font-size: 14px !important;
            line-height: 1.5 !important;
        }
        .chalkboard-input::placeholder { color: rgba(166, 226, 46, 0.4); }
        body.dark-mode .chalkboard-input, body.oled-mode .chalkboard-input { background-color: #0b111a !important; border-color: #050a0f !important; }
        
        .desk-input {
            background: transparent;
            border: 2px dashed rgba(166, 226, 46, 0.3);
            color: #a6e22e;
            font-family: 'Courier New', Courier, monospace;
            text-align: center;
            padding: 10px 4px;
            border-radius: 4px;
            width: 100%;
            transition: all 0.2s;
            font-size: 13px;
            font-weight: bold;
        }
        .desk-input:focus { border-color: #a6e22e; background: rgba(166, 226, 46, 0.1); outline: none; }
        .desk-input::placeholder { color: rgba(166, 226, 46, 0.2); font-weight: normal; }
        
        .board-label {
            background: rgba(255,255,255,0.1); color: #fff; padding: 5px 20px; border-radius: 4px; 
            margin-bottom: 20px; font-weight: bold; font-family: 'Funnel Sans', sans-serif; 
            letter-spacing: 2px; font-size: 12px; display: inline-block;
        }

        /* --- ESTILOS DO HORÁRIO (DASHBOARD) --- */
        .horario-semana-grid {
            display: grid;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            gap: 12px;
            margin-bottom: 40px;
        }

        /* Separadores de dias: vista de um dia de cada vez (sempre no mobile/tablet; "Dia" no desktop) */
        .horario-dias-tabs { display: none; }
        .horario-dia-tab {
            display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
            background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
            color: var(--text-muted); font-family: inherit; cursor: pointer; transition: all 0.2s ease;
            -webkit-tap-highlight-color: transparent;
        }
        .horario-dia-tab .tab-dia { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
        .horario-dia-tab .tab-num { font-family: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif; font-size: 18px; font-weight: 600; line-height: 1.1; color: var(--text-main); }
        .horario-dia-tab .tab-pontos { display: flex; gap: 3px; height: 5px; }
        .horario-dia-tab .tab-pontos i { width: 5px; height: 5px; border-radius: 50%; background: var(--primary-color); }
        .horario-dia-tab.hoje { border-color: var(--primary-color); }
        .horario-dia-tab.hoje .tab-dia { color: var(--primary-color); }
        .horario-dia-tab.ativo { background: var(--primary-color); border-color: var(--primary-color); color: #FFFFFF; }
        .horario-dia-tab.ativo .tab-dia, .horario-dia-tab.ativo .tab-num { color: #FFFFFF; }
        .horario-dia-tab.ativo .tab-pontos i { background: #FFFFFF; }
        body.dark-mode .horario-dia-tab .tab-pontos i, body.oled-mode .horario-dia-tab .tab-pontos i { background: var(--success-color); }
        body.dark-mode .horario-dia-tab.hoje, body.oled-mode .horario-dia-tab.hoje { border-color: var(--success-color); }
        body.dark-mode .horario-dia-tab.hoje .tab-dia, body.oled-mode .horario-dia-tab.hoje .tab-dia { color: var(--success-color); }
        body.dark-mode .horario-dia-tab.ativo, body.oled-mode .horario-dia-tab.ativo { background: var(--success-color); border-color: var(--success-color); }
        body.dark-mode .horario-dia-tab.ativo .tab-dia, body.dark-mode .horario-dia-tab.ativo .tab-num,
        body.oled-mode .horario-dia-tab.ativo .tab-dia, body.oled-mode .horario-dia-tab.ativo .tab-num { color: var(--success-text); }
        body.dark-mode .horario-dia-tab.ativo .tab-pontos i, body.oled-mode .horario-dia-tab.ativo .tab-pontos i { background: var(--success-text); }


        @media (max-width: 900px) {
            .horario-dias-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
            /* Um dia de cada vez (o separador já indica o dia, por isso o título da coluna é escondido) */
            .horario-semana-grid { display: block; touch-action: pan-y; }
            .dia-coluna { display: none; }
            .dia-coluna.dia-ativo { display: block; }
            .dia-coluna .dia-titulo { display: none; }
            .horario-semana-grid.anim-seguinte .dia-ativo { animation: horarioDiaSeguinte 0.25s ease-out; }
            .horario-semana-grid.anim-anterior .dia-ativo { animation: horarioDiaAnterior 0.25s ease-out; }
        }
        @media (min-width: 901px) {
            .horario-wrapper.vista-dia .horario-dias-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
            .horario-wrapper.vista-dia .horario-dia-tab { flex-direction: row; justify-content: center; gap: 8px; padding: 10px 0; }
            .horario-wrapper.vista-dia .horario-dia-tab .tab-num { font-size: 20px; }
            .horario-wrapper.vista-dia .horario-semana-grid { display: block; }
            .horario-wrapper.vista-dia .dia-coluna { display: none; }
            .horario-wrapper.vista-dia .dia-coluna.dia-ativo { display: block; }
            .horario-wrapper.vista-dia .dia-coluna .dia-titulo { display: none; }
            .horario-wrapper.vista-dia .horario-semana-grid.anim-seguinte .dia-ativo { animation: horarioDiaSeguinte 0.25s ease-out; }
            .horario-wrapper.vista-dia .horario-semana-grid.anim-anterior .dia-ativo { animation: horarioDiaAnterior 0.25s ease-out; }
            /* No desktop, o dia divide-se em duas colunas: Manhã e Tarde (os eventos de todo o dia ficam por cima) */
            .horario-wrapper.vista-dia .dia-ativo .horario-todo-dia { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin-bottom: 14px; }
            .horario-wrapper.vista-dia .dia-ativo .horario-periodos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
            .horario-wrapper.vista-dia .dia-ativo .horario-periodo { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
            .horario-wrapper.vista-dia .dia-ativo .horario-periodo-titulo { display: flex; }
            .horario-wrapper.vista-dia .dia-ativo .horario-periodo-vazio { display: block; }
            .horario-wrapper.vista-dia .dia-ativo .bloco-aula, .horario-wrapper.vista-dia .dia-ativo .bloco-evento { margin-bottom: 0; }
        }
        @keyframes horarioDiaSeguinte { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
        @keyframes horarioDiaAnterior { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

        /* --- GRELHA DE HORAS (DESKTOP) ---
           Vista principal do horário no desktop; a vista "Dia" (igual à do mobile) está no botão Grelha/Dia.
           No mobile/tablet mostra-se sempre a vista de um dia. */
        .horario-grelha { display: none; }
        .horario-vista-toggle { display: none; }
        @media (min-width: 901px) {
            .horario-vista-toggle {
                display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-sm);
                background: var(--input-bg); border: 1px solid var(--border-color);
            }
            .horario-vista-toggle button {
                display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 0; border-radius: 3px;
                background: transparent; color: var(--text-muted); font-family: inherit; font-size: 13px; font-weight: 600;
                cursor: pointer; transition: all 0.2s ease;
            }
            .horario-vista-toggle button:hover { color: var(--text-main); }
            .horario-vista-toggle button.ativo { background: var(--card-bg); color: var(--primary-color); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
            body.dark-mode .horario-vista-toggle button.ativo, body.oled-mode .horario-vista-toggle button.ativo { color: var(--success-color); }

            .horario-wrapper.vista-grelha .horario-semana-grid { display: none; }
            .horario-wrapper.vista-grelha .horario-grelha { display: block; }
        }

        .horario-grelha {
            background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02); overflow: hidden;
        }
        .hg-linha { display: grid; grid-template-columns: 52px repeat(5, minmax(0, 1fr)); }
        .hg-cabecalho { border-bottom: 1px solid var(--border-color); }
        .hg-cabecalho > div {
            padding: 12px 6px 10px; text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
            text-transform: uppercase; color: var(--text-muted); border-left: 1px solid var(--border-color);
        }
        .hg-cabecalho > div:first-child { border-left: 0; }
        .hg-cabecalho .hg-data {
            display: block; margin-top: 2px; font-family: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif;
            font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-main); text-transform: none;
        }
        .hg-cabecalho .hoje { color: var(--primary-color); }
        .hg-cabecalho .hoje .hg-data {
            display: flex; align-items: center; justify-content: center; width: fit-content; min-width: 34px; height: 34px;
            margin: 2px auto 0; padding: 0 6px;
            border-radius: 999px; background: var(--primary-color); color: #FFFFFF;
        }
        body.dark-mode .hg-cabecalho .hoje, body.oled-mode .hg-cabecalho .hoje { color: var(--success-color); }
        body.dark-mode .hg-cabecalho .hoje .hg-data, body.oled-mode .hg-cabecalho .hoje .hg-data { background: var(--success-color); color: var(--success-text); }

        /* Faixa dos eventos de todo o dia */
        .hg-todo-dia { border-bottom: 1px solid var(--border-color); }
        .hg-todo-dia > div { padding: 6px 4px; border-left: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
        .hg-todo-dia > div:first-child {
            border-left: 0; align-items: flex-end; justify-content: center; padding-right: 8px;
            font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); line-height: 1.2; text-align: right;
        }
        .hg-chip {
            padding: 3px 7px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; cursor: pointer;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
            background: rgba(139, 92, 246, 0.12); color: #8B5CF6; border-left: 3px solid #8B5CF6;
        }
        body.dark-mode .hg-chip, body.oled-mode .hg-chip { color: #A78BFA; border-left-color: #A78BFA; background: rgba(167, 139, 250, 0.12); }

        /* Corpo: régua das horas + 5 dias */
        .hg-corpo { position: relative; }
        .hg-regua { position: relative; }
        .hg-regua span.primeira { transform: none; }
        .hg-regua span {
            position: absolute; right: 8px; transform: translateY(-50%);
            font-size: 11px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums;
        }
        .hg-dia {
            position: relative; border-left: 1px solid var(--border-color); cursor: pointer;
            background-image: linear-gradient(to bottom, var(--border-color) 1px, transparent 1px);
            background-size: 100% var(--hg-hora);
        }
        .hg-dia.hoje { background-color: rgba(var(--primary-rgb), 0.035); }
        body.dark-mode .hg-dia.hoje, body.oled-mode .hg-dia.hoje { background-color: rgba(var(--success-rgb), 0.04); }

        .horario-grelha .hg-bloco {
            position: absolute; margin: 0; padding: 6px 8px; gap: 2px; overflow: hidden; z-index: 1;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); background: var(--card-bg);
        }
        .horario-grelha .hg-bloco:hover { transform: none; z-index: 3; }
        .horario-grelha .hg-bloco::after { display: none; }
        .horario-grelha .hg-bloco .bloco-aula-hora { font-size: 12px; padding-right: 0; }
        .horario-grelha .hg-bloco .bloco-aula-turma, .horario-grelha .hg-bloco .bloco-evento-titulo { font-size: 13px; line-height: 1.25; }
        /* Títulos com no máximo 2 linhas (1 nos blocos médios ou partilhados); o resto vê-se ao passar o rato */
        .horario-grelha .hg-bloco .bloco-aula-turma, .horario-grelha .hg-bloco .bloco-evento-titulo {
            display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; flex-shrink: 0;
        }
        .horario-grelha .hg-bloco.medio .bloco-aula-turma, .horario-grelha .hg-bloco.medio .bloco-evento-titulo,
        .horario-grelha .hg-bloco.estreito .bloco-aula-turma, .horario-grelha .hg-bloco.estreito .bloco-evento-titulo { -webkit-line-clamp: 1; }
        .horario-grelha .hg-bloco.medio .bloco-aula-sala, .horario-grelha .hg-bloco.medio .bloco-evento-desc, .horario-grelha .hg-bloco.medio .bloco-estado,
        .horario-grelha .hg-bloco.estreito .bloco-aula-sala, .horario-grelha .hg-bloco.estreito .bloco-evento-desc, .horario-grelha .hg-bloco.estreito .bloco-estado,
        .horario-grelha .hg-bloco.estreito .disc { display: none; }
        .horario-grelha .hg-bloco.estreito { padding: 5px 6px; }
        .horario-grelha .hg-bloco.compacto { flex-direction: row; align-items: center; gap: 6px; padding: 2px 6px; white-space: nowrap; }
        .horario-grelha .hg-bloco.compacto > * { display: block; overflow: hidden; text-overflow: ellipsis; }
        .horario-grelha .hg-bloco.compacto .bloco-aula-sala, .horario-grelha .hg-bloco.compacto .bloco-evento-desc, .horario-grelha .hg-bloco.compacto .bloco-estado,
        .horario-grelha .hg-bloco.compacto .disc { display: none; }
        .horario-grelha .hg-bloco.compacto .bloco-aula-hora { flex-shrink: 0; }

        /* Linha "agora" no dia de hoje */
        .hg-arrastavel { cursor: grab; touch-action: none; }
        .importar-ics { background: var(--input-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 18px; }
        .importar-ics label { font-size: 13px; font-weight: 700; color: var(--text-main); display: block; margin-bottom: 4px; }
        .importar-ics p { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; }
        .importar-ics input[type="file"] { font-size: 13px; padding: 8px; background: var(--card-bg); }
        .hg-arrastavel.a-arrastar { cursor: grabbing; z-index: 5; opacity: 0.92; box-shadow: 0 10px 24px rgba(11, 25, 44, 0.2); transition: none; }
        .intervalo-semana { display: flex; flex-direction: column; line-height: 1.25; }
        .resumo-semana-horario { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
        .resumo-semana-horario:empty { display: none; }
        .hg-agora { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger-color); z-index: 2; pointer-events: none; }
        .hg-agora::before {
            content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%;
            background: var(--danger-color);
        }

        /* --- FAIXA "AGORA · A SEGUIR" --- */
        .faixa-agora { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: -10px; }
        .faixa-agora:empty { display: none; }
        .faixa-item {
            display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 14px 16px; text-align: left;
            background: var(--card-bg); border: 1px solid var(--border-color); border-left: 4px solid var(--border-color);
            border-radius: var(--radius-main); font-family: inherit; color: var(--text-main); cursor: pointer; transition: all 0.2s ease;
        }
        .faixa-item:hover { border-color: var(--primary-color); }
        .faixa-item.agora { border-left-color: var(--primary-color); background: rgba(var(--primary-rgb), 0.05); }
        .faixa-item.vazio { cursor: default; }
        .faixa-item.vazio:hover { border-color: var(--border-color); }
        .faixa-rotulo { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
        .faixa-item.agora .faixa-rotulo { color: var(--primary-color); }
        .faixa-rotulo i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blocoEstadoPulso 1.6s ease-in-out infinite; }
        .faixa-item strong { font-family: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .faixa-item strong small { font-family: 'Funnel Sans', system-ui, sans-serif; font-size: 13px; font-weight: 500; color: var(--text-muted); }
        .faixa-meta { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        body.dark-mode .faixa-item.agora, body.oled-mode .faixa-item.agora { border-left-color: var(--success-color); background: rgba(var(--success-rgb), 0.05); }
        body.dark-mode .faixa-item.agora .faixa-rotulo, body.oled-mode .faixa-item.agora .faixa-rotulo { color: var(--success-color); }
        body.dark-mode .faixa-item:hover, body.oled-mode .faixa-item:hover { border-color: var(--success-color); }
        @media (prefers-reduced-motion: reduce) { .faixa-rotulo i { animation: none; } }

        /* Aula/evento a decorrer ou próximo (só no dia de hoje) */
        .bloco-estado {
            display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin-bottom: 2px;
            padding: 3px 7px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; line-height: 1.3;
            background: rgba(var(--primary-rgb), 0.1); color: var(--primary-color);
        }
        .bloco-estado.agora { background: var(--primary-color); color: #FFFFFF; }
        .bloco-estado.agora::before {
            content: ""; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
            animation: blocoEstadoPulso 1.6s ease-in-out infinite;
        }
        body.dark-mode .bloco-estado, body.oled-mode .bloco-estado { background: rgba(var(--success-rgb), 0.12); color: var(--success-color); }
        body.dark-mode .bloco-estado.agora, body.oled-mode .bloco-estado.agora { background: var(--success-color); color: var(--success-text); }
        .bloco-aula.bloco-agora, .bloco-evento.bloco-agora { box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25); }
        /* Aulas/eventos que já terminaram: fundo cinzento opaco (não deixa ver a grelha por trás), textos e barra em cinzento.
           !important para se sobrepor às cores de turma/evento dos modos escuro/OLED e aos estilos inline. */
        .bloco-aula.bloco-passado, .bloco-evento.bloco-passado, .hg-chip.bloco-passado,
        .horario-grelha .hg-bloco.bloco-passado {
            background: var(--bg-color); border-left-color: var(--border-color) !important; box-shadow: none;
        }
        .bloco-passado .bloco-aula-hora, .bloco-passado .bloco-aula-turma, .bloco-passado .bloco-evento-titulo,
        .bloco-passado .bloco-aula-sala, .hg-chip.bloco-passado { color: var(--text-muted) !important; }
        body.dark-mode .bloco-aula.bloco-agora, body.dark-mode .bloco-evento.bloco-agora,
        body.oled-mode .bloco-aula.bloco-agora, body.oled-mode .bloco-evento.bloco-agora { box-shadow: 0 0 0 2px rgba(var(--success-rgb), 0.3); }
        @keyframes blocoEstadoPulso { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
        @media (prefers-reduced-motion: reduce) {
            .bloco-estado.agora::before, .horario-semana-grid .dia-ativo { animation: none !important; }
        }
        /* Manhã/Tarde: só têm efeito na vista Dia do desktop; nas outras vistas os blocos seguem em lista */
        .horario-todo-dia, .horario-periodos, .horario-periodo { display: contents; }
        .horario-periodo-titulo { display: none; align-items: center; gap: 8px; margin: 0 0 2px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
        .horario-periodo-titulo::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }
        .horario-periodo-titulo span { font-weight: 600; letter-spacing: 0; text-transform: none; opacity: 0.8; }
        .horario-periodo-vazio { display: none; padding: 14px; border: 1px dashed var(--border-color); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; font-weight: 600; text-align: center; }
        .dia-coluna { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main); padding: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
        .dia-titulo { font-size: 13px; text-transform: uppercase; color: var(--text-muted); border-bottom: 3px solid var(--primary-color); padding-bottom: 10px; margin-top: 0; margin-bottom: 15px; text-align: center; letter-spacing: 0.05em; font-weight: 800; }
        body.dark-mode .dia-titulo, body.oled-mode .dia-titulo { border-bottom-color: var(--success-color); }
        
        /* Aulas das Turmas */
        .bloco-aula { background: var(--input-bg); border: 1px solid var(--border-color); padding: 12px; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 13px; display: flex; flex-direction: column; gap: 5px; border-left: 4px solid var(--primary-color); transition: transform 0.2s; cursor: pointer; position: relative; }
        .bloco-aula:hover { transform: translateX(3px); border-color: var(--primary-color); }
        .bloco-aula::after { content: '✎'; position: absolute; right: 10px; top: 12px; font-size: 14px; opacity: 0; transition: opacity 0.2s; color: var(--primary-color); }
        .bloco-aula:hover::after { opacity: 1; }
        body.dark-mode .bloco-aula, body.oled-mode .bloco-aula { border-left-color: var(--success-color); }
        body.dark-mode .bloco-aula:hover, body.oled-mode .bloco-aula:hover { border-color: var(--success-color); }
        body.dark-mode .bloco-aula::after, body.oled-mode .bloco-aula::after { color: var(--success-color); }
        .bloco-aula-hora { font-weight: 800; color: var(--text-main); font-size: 13px; padding-right: 14px; }
        .bloco-aula-turma { font-weight: 700; color: var(--primary-color); }
        body.dark-mode .bloco-aula-turma, body.oled-mode .bloco-aula-turma { color: var(--success-color); }
        .bloco-aula-sala { color: var(--text-muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
        
        /* Eventos Avulsos */
        .bloco-evento { background: var(--input-bg); border: 1px solid var(--border-color); padding: 12px; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 13px; display: flex; flex-direction: column; gap: 5px; border-left: 4px solid #8B5CF6; transition: transform 0.2s; cursor: pointer; position: relative; }
        .bloco-evento:hover { transform: translateX(3px); border-color: #8B5CF6; }
        .bloco-evento::after { content: '✎'; position: absolute; right: 10px; top: 12px; font-size: 14px; opacity: 0; transition: opacity 0.2s; color: #8B5CF6; }
        .bloco-evento:hover::after { opacity: 1; }
        body.dark-mode .bloco-evento, body.oled-mode .bloco-evento { border-left-color: #A78BFA; }
        body.dark-mode .bloco-evento:hover, body.oled-mode .bloco-evento:hover { border-color: #A78BFA; }
        body.dark-mode .bloco-evento::after, body.oled-mode .bloco-evento::after { color: #A78BFA; }
        .bloco-evento-titulo { font-weight: 800; color: #8B5CF6; font-size: 14px; }
        body.dark-mode .bloco-evento-titulo, body.oled-mode .bloco-evento-titulo { color: #A78BFA; }
        .bloco-evento-desc { color: var(--text-muted); font-size: 12px; line-height: 1.4; margin-top: -2px; }

        /* --- ESTILOS DE NOTIFICAÇÕES E TOAST --- */
        #notification-toast {
            position: fixed; bottom: 30px; right: 30px; background: var(--card-bg);
            border: 1px solid var(--border-color); border-radius: var(--radius-main);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); z-index: 9999; display: none;
            overflow: hidden; animation: popIn 0.3s ease-out forwards;
        }
        body.dark-mode #notification-toast, body.oled-mode #notification-toast {
            box-shadow: 0 10px 30px rgba(var(--success-rgb), 0.05); border-color: var(--success-color);
        }
        .toast-content { display: flex; align-items: stretch; }
        /* Aviso temporário (toast) no fundo do ecrã */
        .toast-atlas { position: fixed; right: 30px; bottom: calc(30px + env(safe-area-inset-bottom, 0px)); z-index: 20000; display: flex; align-items: center; gap: 12px; max-width: 380px; padding: 14px 18px; background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border-color); border-left: 4px solid var(--primary-color); border-radius: var(--radius-main); box-shadow: 0 10px 30px rgba(11, 25, 44, 0.14); font-size: 14px; font-weight: 600; line-height: 1.4; cursor: pointer; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 0.2s ease, transform 0.25s ease; }
        .toast-atlas.visivel { opacity: 1; transform: none; pointer-events: auto; }
        .toast-atlas-icone { flex-shrink: 0; color: var(--primary-color); }
        body.dark-mode .toast-atlas.sucesso, body.oled-mode .toast-atlas.sucesso, body.dark-mode .toast-atlas.info, body.oled-mode .toast-atlas.info { border-left-color: var(--success-color); }
        body.dark-mode .toast-atlas.sucesso .toast-atlas-icone, body.oled-mode .toast-atlas.sucesso .toast-atlas-icone, body.dark-mode .toast-atlas.info .toast-atlas-icone, body.oled-mode .toast-atlas.info .toast-atlas-icone { color: var(--success-color); }
        .toast-atlas.aviso { border-left-color: #D97706; }
        .toast-atlas.aviso .toast-atlas-icone { color: #D97706; }
        .toast-atlas.erro { border-left-color: var(--danger-color); }
        .toast-atlas.erro .toast-atlas-icone { color: var(--danger-color); }
        @media (max-width: 900px) { .toast-atlas { left: 15px; right: 15px; max-width: none; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); } }
        @media (prefers-reduced-motion: reduce) { .toast-atlas { transition: none; } }
        @media print { .toast-atlas { display: none !important; } }

        /* Modelos e versões de relatórios */
        .lista-modelos { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
        .lista-modelos-vazia { font-size: 13px; color: var(--text-muted); margin: 6px 0; }
        .item-modelo { display: flex; align-items: center; gap: 10px; background: var(--input-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 12px; }
        .item-modelo > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
        .item-modelo strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .item-modelo span { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .item-modelo .btn-primary, .item-modelo .btn-secondary { padding: 6px 14px; font-size: 13px; }
        .item-modelo-apagar { background: none; border: none; color: var(--danger-color); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }
        .novo-modelo { border-top: 1px solid var(--border-color); padding-top: 14px; }
        .novo-modelo label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 6px; }
        /* Partilha com o orientador */
        .partilha-orientador { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-color); }
        .partilha-orientador h4 { margin: 0 0 6px; font-size: 15px; color: var(--text-main); }
        .partilha-orientador > p { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }
        .partilha-orientador-estado { font-size: 13px; color: var(--text-muted); margin: 8px 0 0; }
        .partilha-orientador-link { display: flex; gap: 8px; }
        .partilha-orientador-link input { flex: 1; min-width: 0; font-size: 12px; font-family: monospace; }
        .partilha-orientador-link .btn-primary { padding: 0 14px; white-space: nowrap; }
        .partilha-orientador-desativar { margin-top: 8px; background: none; border: none; padding: 0; color: var(--danger-color); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: underline; }
        #partilhaOrientadorComentarios h5 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
        .partilha-comentario { background: var(--input-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; }
        .partilha-comentario strong { font-size: 14px; }
        .partilha-comentario span { font-size: 12px; color: var(--text-muted); margin-left: 8px; }
        .partilha-comentario p { margin: 6px 0 4px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
        .partilha-comentario button { background: none; border: none; padding: 0; color: var(--text-muted); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }
        /* Pesquisa global */
        .nav-pesquisa { margin-bottom: 6px; border: 1px solid var(--border-color); background: var(--input-bg); }
        .nav-atalho { margin-left: auto; font-family: inherit; font-size: 11px; font-weight: 700; color: var(--text-muted); border: 1px solid var(--border-color); border-radius: 6px; padding: 1px 6px; background: var(--card-bg); }
        #appShell.collapsed .nav-atalho { display: none; }
        .menu-mais-pesquisa { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; border: 1px solid var(--border-color); background: var(--input-bg); color: var(--text-muted); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
        .modal-content.pesquisa-global { max-width: 640px; width: 100%; padding: 0; overflow: hidden; align-self: flex-start; margin-top: 34vh; transition: margin-top 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
        /* Quando se começa a escrever, a caixa sobe para dar espaço aos resultados */
        .modal-content.pesquisa-global.com-resultados { margin-top: 10vh; }
        .pesquisa-global-campo { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-color); color: var(--text-muted); }
        .pesquisa-global-campo input { flex: 1; min-width: 0; border: none !important; background: transparent !important; box-shadow: none !important; font-size: 17px; padding: 4px 0 !important; color: var(--text-main); outline: none; }
        .pesquisa-global-campo input::-webkit-search-cancel-button { display: none; }
        .pesquisa-global-fechar { font: inherit; font-size: 12px; font-weight: 700; color: var(--text-muted); border: 1px solid var(--border-color); border-radius: 6px; padding: 2px 8px; background: var(--input-bg); cursor: pointer; }
        .pesquisa-global-resultados { max-height: min(60vh, 520px); overflow-y: auto; padding: 8px; }
        .pesquisa-global-dica { color: var(--text-muted); font-size: 14px; text-align: center; padding: 24px 12px; margin: 0; }
        .pesquisa-global-grupo + .pesquisa-global-grupo { margin-top: 6px; }
        .pesquisa-global-grupo-titulo { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding: 8px 10px 4px; }
        .pesquisa-global-grupo-titulo span { font-weight: 600; text-transform: none; letter-spacing: 0; }
        .pesquisa-global-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 9px 10px; border: none; border-radius: 10px; background: transparent; color: var(--text-main); font: inherit; font-size: 14px; cursor: pointer; }
        .pesquisa-global-item span { font-size: 12px; color: var(--text-muted); }
        .pesquisa-global-item:hover, .pesquisa-global-item:focus-visible { background: rgba(var(--primary-rgb), 0.08); outline: none; }
        body.dark-mode .pesquisa-global-item:hover, body.dark-mode .pesquisa-global-item:focus-visible, body.oled-mode .pesquisa-global-item:hover, body.oled-mode .pesquisa-global-item:focus-visible { background: rgba(var(--success-rgb), 0.1); }
        @media (max-width: 900px) { .modal-content.pesquisa-global { margin-top: 28vh; } .modal-content.pesquisa-global.com-resultados { margin-top: 12px; } }
        @media (prefers-reduced-motion: reduce) { .modal-content.pesquisa-global { transition: none; } }
        /* Esqueletos de carregamento */
        .esqueleto-lista { display: grid; gap: 14px; grid-column: 1 / -1; width: 100%; }
        .esqueleto-cartaos { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
        .esqueleto { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main); padding: 18px; display: flex; gap: 12px; }
        .esqueleto-cartao { flex-direction: column; min-height: 120px; }
        .esqueleto-linha { align-items: center; }
        .esq-coluna { display: flex; flex-direction: column; gap: 8px; flex: 1; }
        .esq-bloco { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--input-bg) 0%, var(--border-color) 50%, var(--input-bg) 100%); background-size: 200% 100%; animation: esqueletoBrilho 1.4s ease-in-out infinite; }
        .esq-icone { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
        .esq-titulo { height: 16px; width: 55%; }
        .esq-texto { height: 12px; width: 90%; }
        .esq-texto.curto { width: 40%; }
        @keyframes esqueletoBrilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }
        @media (prefers-reduced-motion: reduce) { .esq-bloco { animation: none; } }
        .indicador-ligacao { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 2500; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; box-shadow: 0 6px 18px rgba(11, 25, 44, 0.15); background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-main); }
        .indicador-ligacao[hidden] { display: none; }
        [data-teclado]:focus-visible { outline: 3px solid rgba(var(--primary-rgb), 0.45); outline-offset: 2px; }
        body.dark-mode [data-teclado]:focus-visible, body.oled-mode [data-teclado]:focus-visible { outline-color: rgba(var(--success-rgb), 0.5); }
        .indicador-ligacao::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #F59E0B; }
        .indicador-ligacao.a-sincronizar::before { background: var(--primary-color); animation: indicadorPulsar 1.2s ease-in-out infinite; }
        body.dark-mode .indicador-ligacao.a-sincronizar::before, body.oled-mode .indicador-ligacao.a-sincronizar::before { background: var(--success-color); }
        @keyframes indicadorPulsar { 50% { opacity: 0.3; } }
        @media (prefers-reduced-motion: reduce) { .indicador-ligacao.a-sincronizar::before { animation: none; } }
        .toast-body { padding: 15px 20px; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: background 0.2s; }
        .toast-body:hover { background: var(--input-bg); }
        .toast-dot { width: 10px; height: 10px; background-color: var(--danger-color); border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px rgba(255, 23, 68, 0.6); }
        .toast-text { font-size: 14px; font-weight: 600; color: var(--text-main); margin: 0; }
        .toast-close { background: transparent; border: none; border-left: 1px solid var(--border-color); padding: 0 15px; cursor: pointer; color: var(--text-muted); font-size: 18px; transition: all 0.2s; }
        .toast-close:hover { background: var(--danger-color); color: white; border-color: transparent; }
        
        .notif-item { background: var(--input-bg); border: 1px solid var(--border-color); padding: 15px 20px; border-radius: var(--radius-sm); margin-bottom: 15px; display: flex; flex-direction: column; gap: 12px; }
        .notif-header { display: flex; justify-content: space-between; align-items: flex-start; }
        .notif-title { font-size: 15px; font-weight: 700; color: var(--text-main); margin: 0; }
        .notif-sender { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
        .notif-badge { background: rgba(var(--primary-rgb), 0.1); color: var(--primary-color); font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 12px; text-transform: uppercase; }
        body.dark-mode .notif-badge, body.oled-mode .notif-badge { background: rgba(var(--success-rgb), 0.1); color: var(--success-color); }
        .notif-actions { display: flex; gap: 10px; margin-top: 5px; }

        /* --- ESTILOS DO MODAL PWA (INSTALAÇÃO) --- */
        #pwa-install-toast {
            position: fixed; top: 20px; right: 20px; background: var(--card-bg);
            border: 2px solid var(--primary-color); border-radius: var(--radius-main);
            box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.15); z-index: 10001;
            padding: 15px 20px; display: none; align-items: center; gap: 15px;
            animation: popIn 0.4s ease-out forwards; max-width: 340px;
        }
        body.dark-mode #pwa-install-toast, body.oled-mode #pwa-install-toast {
            border-color: var(--success-color); box-shadow: 0 10px 30px rgba(var(--success-rgb), 0.15);
        }
        .pwa-toast-text { font-size: 13px; color: var(--text-main); line-height: 1.4; font-weight: 500; margin: 0; }
        .pwa-toast-text strong { display: block; font-size: 15px; margin-bottom: 2px; color: var(--primary-color); }
        body.dark-mode .pwa-toast-text strong, body.oled-mode .pwa-toast-text strong { color: var(--success-color); }
        .pwa-toast-buttons { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
        .pwa-btn { padding: 8px 12px; font-size: 12px; font-weight: 700; border-radius: var(--radius-sm); cursor: pointer; border: none; transition: all 0.2s; }
        .pwa-btn-install { background: var(--primary-color); color: white; }
        .pwa-btn-install:hover { background: var(--hover-color); transform: translateY(-1px); }
        body.dark-mode .pwa-btn-install, body.oled-mode .pwa-btn-install { background: var(--success-color); color: var(--success-text); }
        .pwa-btn-dismiss { background: transparent; color: var(--text-muted); border: 1px solid var(--border-color); }
        .pwa-btn-dismiss:hover { background: var(--input-bg); }
        
        @media (max-width: 600px) {
            #pwa-install-toast { top: 15px; left: 15px; right: 15px; max-width: none; flex-direction: column; text-align: center; }
            .pwa-toast-buttons { flex-direction: row; width: 100%; }
            .pwa-btn { flex: 1; }
        }

        /* --- ESTILOS DO WIZARD DE PLANIFICAÇÕES --- */
        .wizard-nav { display: flex; gap: 10px; margin-bottom: 25px; overflow-x: auto; padding-bottom: 5px; }
        .wizard-step-btn { flex: 1; min-width: 130px; white-space: nowrap; border-radius: 30px; padding: 10px 15px; font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.3s; border: none; }
        .wizard-step-btn.active { background: var(--primary-color); color: white; box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2); }
        body.dark-mode .wizard-step-btn.active, body.oled-mode .wizard-step-btn.active { background: var(--success-color); color: var(--success-text); box-shadow: 0 4px 12px rgba(var(--success-rgb), 0.2); }
        .wizard-step-btn.inactive { background: var(--input-bg); color: var(--text-muted); border: 1px solid var(--border-color); }
        .wizard-step-btn.inactive:hover { background: var(--border-color); color: var(--text-main); }
        .plan-step-content { display: none; animation: fadeIn 0.3s ease-out forwards; }
        .plan-step-content.active { display: block; }
        
        /* LINHAS DO PROCEDURE (TIME ENGINE) */
        .proc-row { background: var(--card-bg); padding: 20px; border: 1px dashed var(--border-color); border-radius: var(--radius-sm); margin-bottom: 15px; position: relative; transition: all 0.2s; }
        .proc-row:hover { border-color: var(--primary-color); box-shadow: 0 5px 15px rgba(0,0,0,0.03); }
        body.dark-mode .proc-row:hover, body.oled-mode .proc-row:hover { border-color: var(--success-color); }
        .proc-header-info { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; border-bottom: 1px solid var(--input-bg); padding-bottom: 10px; }
        .proc-time-display { font-size: 18px; font-weight: 800; color: var(--primary-color); background: rgba(var(--primary-rgb), 0.1); padding: 4px 12px; border-radius: 20px; }
        body.dark-mode .proc-time-display, body.oled-mode .proc-time-display { color: var(--success-color); background: rgba(var(--success-rgb), 0.1); }

        /* --- BOTÃO DE INSPIRAÇÃO ATLAS AI --- */
        .ai-inspire-btn {
            background: linear-gradient(135deg, #0044FF, #8B5CF6);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            border: 1px solid rgba(139, 92, 246, 0.3);
            border-radius: 12px;
            padding: 2px 8px;
            font-size: 10px;
            font-weight: 800;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-left: 10px;
            transition: all 0.2s;
        }
        .ai-inspire-btn:hover {
            box-shadow: 0 2px 10px rgba(139, 92, 246, 0.2);
            transform: translateY(-1px);
        }
        body.dark-mode .ai-inspire-btn, body.oled-mode .ai-inspire-btn {
            background: linear-gradient(135deg, #00FF66, #0044FF);
            -webkit-background-clip: text;
            background-clip: text;
            border-color: rgba(var(--success-rgb), 0.3);
        }
        
        /* --- DASHBOARD: COMMAND CENTER --- */
        .dashboard-layout { display: grid; grid-template-columns: 2.6fr 1fr; gap: 25px; align-items: start; margin-top: 10px; }
        .dash-main { display: flex; flex-direction: column; gap: 40px; }
        .dash-sidebar { display: flex; flex-direction: column; gap: 25px; }

        /* Widgets de Ferramentas Compactos */
        .tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 15px; }
        .tool-widget { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main); padding: 20px 15px; text-align: center; cursor: pointer; transition: all 0.2s ease; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; position: relative; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
        .tool-widget:hover { border-color: var(--primary-color); transform: translateY(-4px); box-shadow: 0 12px 25px rgba(var(--primary-rgb), 0.1); }
        body.dark-mode .tool-widget:hover, body.oled-mode .tool-widget:hover { border-color: var(--success-color); box-shadow: 0 12px 25px rgba(var(--success-rgb), 0.1); }
        .tool-widget-icon { width: 54px; height: 54px; background: var(--input-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--primary-color); transition: all 0.3s; }
        body.dark-mode .tool-widget-icon, body.oled-mode .tool-widget-icon { color: var(--success-color); }
        .tool-widget:hover .tool-widget-icon { background: rgba(var(--primary-rgb), 0.1); transform: scale(1.1); }
        body.dark-mode .tool-widget:hover .tool-widget-icon, body.oled-mode .tool-widget:hover .tool-widget-icon { background: rgba(var(--success-rgb), 0.1); }
        .tool-widget h4 { margin: 0; font-size: 18px; font-weight: 800; color: var(--text-main); letter-spacing: 0.02em; line-height: 1; }
        .tool-widget span.tool-desc { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

        /* Widgets Laterais (Informação) */
        .info-widget { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-main); padding: 25px; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
        .info-widget-title { font-size: 13px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: 20px; border-bottom: 2px solid var(--input-bg); padding-bottom: 12px; font-weight: 800; display: flex; align-items: center; gap: 8px;}
        .info-item { margin-bottom: 18px; }
        /* Painel do estágio */
        .painel-estagio .info-widget-title { display: flex; align-items: center; gap: 8px; }
        .painel-estagio-ajuda { margin-left: auto; }
        .rsa-aulas-dadas { margin-top: -6px; }
        .painel-estagio-numeros { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
        .painel-estagio-numeros div { display: flex; flex-direction: column; gap: 2px; }
        .painel-estagio-numeros strong { font-family: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif; font-size: 26px; font-weight: 600; line-height: 1.1; color: var(--primary-color); font-variant-numeric: tabular-nums; }
        body.dark-mode .painel-estagio-numeros strong, body.oled-mode .painel-estagio-numeros strong { color: var(--success-color); }
        .painel-estagio-numeros span { font-size: 12px; color: var(--text-muted); font-weight: 600; }
        .painel-estagio-detalhe { font-size: 12px; color: var(--text-muted); margin: 14px 0 0; }
        .painel-estagio-meses { display: flex; align-items: flex-end; gap: 6px; height: 84px; margin-top: 16px; padding-top: 6px; border-top: 1px solid var(--input-bg); }
        .pe-mes { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
        .pe-barra { width: 100%; max-width: 22px; min-height: 2px; border-radius: 4px 4px 2px 2px; background: rgba(var(--primary-rgb), 0.75); }
        body.dark-mode .pe-barra, body.oled-mode .pe-barra { background: rgba(var(--success-rgb), 0.75); }
        .pe-mes small { font-size: 10px; color: var(--text-muted); font-weight: 600; }
        .info-item:last-child { margin-bottom: 0; }
        .info-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; display: block; letter-spacing: 0.02em; }
        .info-value { font-size: 15px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px; line-height: 1.4; }
        .info-value.highlight { color: var(--primary-color); font-size: 16px; font-weight: 800; }
        body.dark-mode .info-value.highlight, body.oled-mode .info-value.highlight { color: var(--success-color); }

        /* Adaptação Mobile */
        @media (max-width: 1050px) {
            .dashboard-layout { grid-template-columns: 1fr; }
            .dash-sidebar { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
        }

    
        /* --- ESTILOS DO ATLAS DOCS --- */
        .docs-toolbar {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 6px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm) var(--radius-sm) 0 0;
            padding: 8px 12px;
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .docs-tool-btn {
            background: transparent;
            border: 1px solid transparent;
            border-radius: var(--radius-sm);
            color: var(--text-main);
            width: 34px;
            height: 34px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            transition: all 0.2s;
        }

        .docs-tool-btn:hover {
            background: var(--input-bg);
            border-color: var(--border-color);
            color: var(--primary-color);
        }

        body.dark-mode .docs-tool-btn:hover, body.oled-mode .docs-tool-btn:hover {
            color: var(--success-color);
        }

        .docs-tool-btn:active {
            transform: scale(0.95);
        }

        .docs-tool-btn svg { flex-shrink: 0; }

        /* Estado ativo (negrito, alinhamento, listas... na posição do cursor) */
        .docs-tool-btn.active {
            background: rgba(var(--primary-rgb), 0.12);
            border-color: rgba(var(--primary-rgb), 0.25);
            color: var(--primary-color);
        }
        body.dark-mode .docs-tool-btn.active, body.oled-mode .docs-tool-btn.active {
            background: rgba(var(--success-rgb), 0.12);
            border-color: rgba(var(--success-rgb), 0.25);
            color: var(--success-color);
        }

        .docs-tool-spacer { flex: 1; }

        .docs-color-letra {
            position: relative; font-weight: 800; font-size: 15px; line-height: 1; padding-bottom: 4px; color: var(--text-main);
        }
        .docs-color-barra {
            position: absolute; left: -2px; right: -2px; bottom: 0; height: 3px; border-radius: 2px; background: #E53935;
        }
        .docs-color-realce {
            font-weight: 800; font-size: 13px; background: #FFFF00; color: #111827; padding: 1px 4px; border-radius: 2px;
        }

        /* Procurar e substituir */
        .docs-find-bar {
            display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
            background: var(--card-bg); border: 1px solid var(--border-color); border-top: none;
            padding: 8px 12px;
        }
        .docs-find-grupo { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 260px; }
        .docs-find-bar input[type="text"] { flex: 1; min-width: 0; height: 34px; padding: 6px 10px; font-size: 13px; }
        .docs-find-count { font-size: 12px; font-weight: 700; color: var(--text-muted); white-space: nowrap; min-width: 52px; text-align: center; }
        .docs-find-acao { padding: 6px 10px; font-size: 12.5px; height: 34px; white-space: nowrap; }
        ::highlight(doc-procura) { background-color: rgba(255, 213, 0, 0.45); }
        ::highlight(doc-procura-atual) { background-color: #FF9800; color: #000000; }

        /* Modo foco: o editor ocupa o ecrã inteiro */
        #docs-editor-view.docs-modo-foco {
            position: fixed; inset: 0; z-index: 9500; background: var(--bg-color);
            overflow-y: auto; padding: 20px max(20px, calc((100vw - 1000px) / 2));
        }
        #docs-editor-view.docs-modo-foco .app-header { display: none; }

        .docs-tool-separator {
            width: 1px;
            height: 22px;
            background: var(--border-color);
            margin: 0 4px;
        }

        .docs-select {
            padding: 6px 10px;
            font-size: 13px;
            font-weight: 600;
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            background: var(--card-bg);
            color: var(--text-main);
            cursor: pointer;
            outline: none;
            height: 34px;
            width: auto;
        }

        .docs-color-wrapper {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 34px;
            height: 34px;
            cursor: pointer;
            border-radius: var(--radius-sm);
        }

        .docs-color-wrapper:hover {
            background: var(--input-bg);
        }

        .docs-color-wrapper input[type="color"] {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
        }

        /* Folha de Escrita */
        .docs-page-container {
            background: var(--input-bg);
            padding: 30px 20px;
            border: 1px solid var(--border-color);
            border-top: none;
            border-radius: 0 0 var(--radius-sm) var(--radius-sm);
            min-height: 70vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            overflow-y: auto;
        }

        .docs-editor-sheet {
            background: #FFFFFF;
            color: #111827;
            width: 100%;
            max-width: 850px;
            min-height: 900px;
            padding: 60px 65px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
            border: 1px solid #E2E8F0;
            border-radius: 4px;
            font-family: 'Funnel Sans', system-ui, -apple-system, sans-serif;
            font-size: 15px;
            line-height: 1.7;
            outline: none;
            overflow-wrap: break-word;
        }

        body.dark-mode .docs-editor-sheet, body.oled-mode .docs-editor-sheet {
            background: #0B1322;
            color: #F8FAFC;
            border-color: #1E293B;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
        }

        /* Texto de exemplo quando a folha está vazia */
        .docs-editor-sheet:empty::before {
            content: attr(placeholder);
            color: #94A3B8;
            pointer-events: none;
        }

        .docs-editor-sheet h1 { font-size: 1.9em; line-height: 1.25; margin: 0.6em 0 0.4em; }
        .docs-editor-sheet h2 { font-size: 1.5em; line-height: 1.3; margin: 0.6em 0 0.4em; }
        .docs-editor-sheet h3 { font-size: 1.2em; line-height: 1.35; margin: 0.6em 0 0.4em; }
        .docs-editor-sheet p { margin: 0 0 0.6em; }
        .docs-editor-sheet a { color: var(--primary-color); text-decoration: underline; cursor: text; }

        .docs-editor-sheet blockquote {
            border-left: 4px solid var(--primary-color);
            margin: 12px 0;
            padding: 8px 16px;
            color: var(--text-muted);
            font-style: italic;
            background: rgba(var(--primary-rgb), 0.03);
        }

        .docs-editor-sheet hr {
            border: none;
            border-top: 1px solid var(--border-color);
            margin: 20px 0;
        }

        .docs-editor-sheet ul, .docs-editor-sheet ol {
            margin-left: 25px;
            margin-bottom: 12px;
        }

        .docs-status-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 15px;
            font-size: 12px;
            font-weight: 600;
            color: var(--text-muted);
            border-top: 1px solid var(--border-color);
            background: var(--card-bg);
        }

        @media (max-width: 600px) {
            /* Barra de ferramentas desliza na horizontal em vez de ocupar várias linhas */
            .docs-toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; contain: inline-size; }
            .docs-toolbar > * { flex-shrink: 0; }
            .docs-tool-spacer { display: none; }
            .docs-find-grupo { min-width: 100%; }
            .docs-page-container { padding: 15px 8px; }
            .docs-editor-sheet { padding: 30px 20px; min-height: 60vh; }
            .docs-status-bar { flex-direction: column; align-items: flex-start; gap: 4px; }
        }

    /* =========================================================
        ATLAS AI - EXPERIÊNCIA IMERSIVA FULL-SCREEN (MOBILE & DESKTOP)
        ========================================================= */

        /* --- ESTRUTURA GERAL (DESKTOP) --- */
        .ai-layout-container {
            display: grid;
            grid-template-columns: 300px 1fr;
            gap: 20px;
            height: calc(100vh - 210px);
            min-height: 540px;
            margin-top: 10px;
            position: relative;
        }

        .ai-sidebar {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-main);
            padding: 16px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
        }

        .ai-sidebar-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }

        .ai-new-chat-btn {
            width: 100%;
            margin-bottom: 14px;
            padding: 10px 14px;
            font-size: 13px;
        }

        .ai-chat-list {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 6px;
            padding-right: 4px;
        }

        .ai-chat-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 12px;
            border-radius: var(--radius-sm);
            border: 1px solid transparent;
            background: var(--input-bg);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .ai-chat-item:hover {
            border-color: var(--border-color);
            background: var(--card-bg);
            transform: translateX(2px);
        }

        .ai-chat-item.active {
            border-color: var(--primary-color);
            background: rgba(var(--primary-rgb), 0.06);
        }

        body.dark-mode .ai-chat-item.active,
        body.oled-mode .ai-chat-item.active {
            border-color: var(--success-color);
            background: rgba(var(--success-rgb), 0.08);
        }

        .ai-chat-item-info {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            flex: 1;
            padding-right: 8px;
        }

        .ai-chat-item-title {
            font-size: 13.5px;
            font-weight: 600;
            color: var(--text-main);
            display: block;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .ai-chat-item-date {
            font-size: 11px;
            color: var(--text-muted);
        }

        .ai-chat-main {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-main);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
        }

        .ai-chat-header {
            padding: 12px 18px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: var(--card-bg);
            gap: 10px;
        }

        .ai-messages-container {
            flex: 1;
            overflow-y: auto;
            padding: 24px;
            display: flex;
            flex-direction: column;
            gap: 14px;
            scroll-behavior: smooth;
        }

        .ai-msg-acoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border-color); }
        .ai-msg-acoes button { font: inherit; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-muted); cursor: pointer; }
        .ai-msg-acoes button:hover { color: var(--primary-color); border-color: var(--primary-color); }
        .ai-msg.a-escrever::after { content: '▍'; animation: indicadorPulsar 1s ease-in-out infinite; color: var(--primary-color); }
        .ai-contexto { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 6px 4px 0; cursor: pointer; }
        .ai-contexto input { width: auto; margin: 0; }
        .ai-msg {
            max-width: 82%;
            padding: 13px 18px;
            border-radius: 8px;
            font-size: 14.5px;
            line-height: 1.6;
            word-break: break-word;
        }

        .ai-msg.user {
            align-self: flex-end;
            background: var(--primary-color);
            color: #FFFFFF;
            border-bottom-right-radius: 2px;
        }

        .ai-msg.assistant {
            align-self: flex-start;
            background: var(--input-bg);
            color: var(--text-main);
            border: 1px solid var(--border-color);
            border-bottom-left-radius: 2px;
        }

        .ai-input-wrapper {
            display: flex;
            gap: 10px;
            padding: 14px 18px;
            border-top: 1px solid var(--border-color);
            background: var(--card-bg);
            align-items: center;
        }

        .ai-input-wrapper input {
            flex: 1;
            padding: 12px 16px;
            font-size: 14.5px;
            border-radius: 24px;
            border: 1px solid var(--border-color);
            background: var(--input-bg);
            transition: border-color 0.2s;
        }

        .ai-input-wrapper input:focus {
            border-color: var(--primary-color);
            background: var(--card-bg);
        }

        /* Fundo desfocado para o menu de histórico (Drawer) */
        .ai-sidebar-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: var(--modal-backdrop);
            backdrop-filter: blur(4px);
            z-index: 9998;
        }
        .ai-sidebar-overlay.show {
            display: block;
        }

        /* Controlo de visibilidade entre Desktop e Mobile no Atlas AI */
        .ai-mobile-only {
            display: none !important;
        }

        .ai-desktop-only {
            display: flex !important;
        }

        @media (max-width: 900px) {
            .ai-mobile-only {
                display: inline-flex !important;
            }
            .ai-desktop-only {
                display: none !important;
            }
        }

        /* --- REGRAS ESPECÍFICAS PARA MOBILE (< 900px) --- */
        @media (max-width: 900px) {

            /* 1. Recolhe e esconde o menu inferior quando no Atlas AI */
            body[data-active-view="atlas-ai"] .bottom-nav-bar,
            body[data-active-view="ai"] .bottom-nav-bar {
                transform: translate(-50%, 150%) scale(0.85) !important;
                opacity: 0 !important;
                pointer-events: none !important;
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
            }

            /* 2. Remove banners e cabeçalho formal volumoso */
            body[data-active-view="atlas-ai"] #bannerGlobalContainer,
            body[data-active-view="ai"] #bannerGlobalContainer,
            body[data-active-view="atlas-ai"] #view-ai > .app-header,
            body[data-active-view="ai"] #view-ai > .app-header {
                display: none !important;
            }

            /* 3. Expande todo o contentor para 100% da janela móvel (ecrã total) */
            body[data-active-view="atlas-ai"] .main-wrapper,
            body[data-active-view="ai"] .main-wrapper {
                height: 100dvh !important;
                overflow: hidden !important;
            }

            body[data-active-view="atlas-ai"] .content-area,
            body[data-active-view="ai"] .content-area {
                padding: 0 !important;
                max-width: 100% !important;
                height: 100dvh !important;
                display: flex !important;
                flex-direction: column !important;
                overflow: hidden !important;
            }

            body[data-active-view="atlas-ai"] #view-ai,
            body[data-active-view="ai"] #view-ai {
                height: 100% !important;
                display: flex !important;
                flex-direction: column !important;
                flex: 1 !important;
                overflow: hidden !important;
            }

            body[data-active-view="atlas-ai"] .ai-layout-container,
            body[data-active-view="ai"] .ai-layout-container {
                grid-template-columns: 1fr !important;
                height: 100% !important;
                min-height: unset !important;
                margin: 0 !important;
                gap: 0 !important;
            }

            body[data-active-view="atlas-ai"] .ai-chat-main,
            body[data-active-view="ai"] .ai-chat-main {
                border: none !important;
                border-radius: 0 !important;
                height: 100% !important;
                flex: 1 !important;
            }

            /* 4. Barra Superior Flutuante Minimalista */
            body[data-active-view="atlas-ai"] .ai-chat-header,
            body[data-active-view="ai"] .ai-chat-header {
                padding: max(12px, env(safe-area-inset-top)) 14px 10px 14px !important;
                background: var(--card-bg) !important;
                border-bottom: 1px solid var(--border-color) !important;
                z-index: 100;
                box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
            }

            /* 5. Gaveta de Histórico Deslizante */
            .ai-sidebar {
                position: fixed !important;
                top: 0 !important;
                bottom: 0 !important;
                left: 0 !important;
                width: 82% !important;
                max-width: 320px !important;
                z-index: 9999 !important;
                border-radius: 0 !important;
                border-top: none !important;
                border-bottom: none !important;
                border-left: none !important;
                transform: translateX(-100%);
                transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
                padding-top: max(20px, env(safe-area-inset-top)) !important;
                padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
                box-shadow: 10px 0 35px rgba(0, 0, 0, 0.3) !important;
            }

            .ai-sidebar.open {
                transform: translateX(0) !important;
            }

            /* 6. Mensagens otimizadas */
            body[data-active-view="atlas-ai"] .ai-messages-container,
            body[data-active-view="ai"] .ai-messages-container {
                padding: 16px 14px 14px 14px !important;
            }

            .ai-msg {
                max-width: 90% !important;
                font-size: 14px !important;
                padding: 11px 15px !important;
            }

            /* 7. Barra de Prompt colada ao fundo (Safe Area Inset) */
            body[data-active-view="atlas-ai"] .ai-input-wrapper,
            body[data-active-view="ai"] .ai-input-wrapper {
                padding: 8px 12px max(10px, env(safe-area-inset-bottom)) 12px !important;
                border-radius: 0 !important;
                border-top: 1px solid var(--border-color) !important;
                background: var(--card-bg) !important;
                box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.04);
                z-index: 100;
            }

            body[data-active-view="atlas-ai"] .ai-input-wrapper input {
                padding: 10px 14px !important;
                font-size: 14px !important;
            }
        }

        /* --- IMPRESSÃO --- */
        .area-impressao { display: none; }
        @media print {
            @page { margin: 14mm; }
            @page horario { size: A4 landscape; margin: 10mm; }
            html, body, body.dark-mode, body.oled-mode { background: #FFFFFF !important; color: #0B192C !important; min-height: 0 !important; height: auto !important; }
            .sidebar, .bottom-nav-bar, .floating-more-menu, .modal-overlay, .indicador-ligacao, .notification-toast, #pwa-install-toast,
            .header-actions, .top-btn, .btn-primary, .btn-secondary, .botao-imprimir, .info-btn, .menu-mais-pesquisa { display: none !important; }
            #appShell, .main-wrapper, .content-area { margin: 0 !important; padding: 0 !important; width: 100% !important; max-width: none !important; overflow: visible !important; height: auto !important; }
            .app-view { box-shadow: none !important; }
            .bloco-aula, .bloco-evento, .di-note-card, .turma-card, .dia-coluna { break-inside: avoid; box-shadow: none !important; }
            a { color: inherit; text-decoration: none; }
            /* Imprimir só uma secção (copiada para #areaImpressao): o resto da página fica de fora */
            body.a-imprimir > *:not(#areaImpressao) { display: none !important; }
            .area-impressao { display: block !important; background: #FFFFFF; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
            /* O horário sai numa página horizontal e reduzido para caber inteiro (08:00–19:00) */
            .impressao-horario { page: horario; }
            /* Imprime sempre a semana em grelha (mesmo em vista Dia ou no telemóvel), com largura fixa para a folha horizontal */
            .impressao-horario > .horario-wrapper { width: 1240px; zoom: 0.84; }
            .impressao-horario .horario-grelha { display: block !important; }
            .impressao-horario .horario-semana-grid, .impressao-horario .horario-dias-tabs, .impressao-horario .horario-vista-toggle { display: none !important; }
            .area-impressao h1 { font-family: 'Funnel Display', sans-serif; font-size: 18pt; font-weight: 600; margin: 0 0 6mm; color: #0B192C; }
            .area-impressao .horario-grelha { max-height: none !important; height: auto !important; overflow: visible !important; }
            .area-impressao .dia-coluna, .area-impressao .horario-grelha, .area-impressao .hg-dia { background: #FFFFFF !important; }
            .impressao-di > div { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6mm; width: 100%; max-width: 100%; }
            .impressao-di .di-note-card { min-width: 0; }
            .area-impressao .di-note-card { background: #FFFFFF !important; border: 1px solid #CBD5E1 !important; }
        }
