        * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

        @keyframes nexus-magma {
            0%   { border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%; transform: rotate(0deg); }
            25%  { border-radius: 40% 60% 45% 55% / 60% 40% 55% 45%; transform: rotate(90deg); }
            50%  { border-radius: 55% 45% 60% 40% / 45% 55% 45% 55%; transform: rotate(180deg); }
            75%  { border-radius: 45% 55% 40% 60% / 55% 45% 60% 40%; transform: rotate(270deg); }
            100% { border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%; transform: rotate(360deg); }
        }

        .nexus-glow {
            position: absolute;
            inset: -6px;
            background: linear-gradient(135deg, rgba(109,40,217,.98) 0%, rgba(37,99,235,.95) 50%, rgba(124,58,237,.95) 100%);
            filter: blur(10px);
            animation: nexus-magma 12s linear infinite;
        }
        body {
            font-family: 'Segoe UI', system-ui, sans-serif;
            background: linear-gradient(135deg, #020617 0%, #0f172a 100%);
            color: #f8fafc;
            min-height: 100vh;
        }

        .glass-panel {
            background: rgba(30, 41, 59, 0.4);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid rgba(255, 255, 255, 0.08);
            box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
        }

        .glass-card {
            background: rgba(30, 41, 59, 0.7);
            border: 1px solid rgba(255, 255, 255, 0.05);
            transition: transform 0.2s, border-color 0.2s;
        }
        .glass-card:hover {
            border-color: rgba(99, 102, 241, 0.4);
            transform: translateY(-2px);
        }

        ::-webkit-scrollbar { width: 6px; height: 6px; }
        ::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
        ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
        ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

        .view { display: none !important; }
        .view.active { display: flex !important; }
        .tab-content { display: none !important; }
        .tab-content.active { display: block !important; }

        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
        .animate-fade { animation: fadeIn 0.3s ease-out forwards; }

        @keyframes tag-destaque {
            0%, 100% {
                box-shadow: 0 0 5px var(--tg, #fff6), 0 0 0px var(--tg, #fff3);
                transform: scale(1) translateX(0);
            }
            30%  { transform: scale(1.06) translateX(-1px); }
            40%  { transform: scale(1.06) translateX(1px); }
            50%  { transform: scale(1.06) translateX(-1px); }
            60%  { transform: scale(1.06) translateX(0); }
            80%  { box-shadow: 0 0 14px var(--tg, #fffa), 0 0 5px var(--tg, #fff8); }
        }
        .tag-destaque-anim {
            animation: tag-destaque 2.4s ease-in-out infinite;
            display: inline-block;
        }

        .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
        .cal-dia {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            border: 1px solid transparent;
            transition: all 0.2s;
            position: relative;
        }
        .cal-dia:hover:not(:disabled) { background: rgba(99, 102, 241, 0.2); border-color: rgba(99, 102, 241, 0.4); }
        .cal-dia.selecionado { background: #4f46e5; color: white; border-color: #6366f1; }
        .cal-dia.hoje:not(.selecionado) { border-color: #4f46e5; color: #818cf8; }
        .cal-dia:disabled { opacity: 0.3; cursor: not-allowed; }
        .cal-dot {
            position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
            width: 4px; height: 4px; border-radius: 50%; background: #f59e0b;
        }

        #mapa-atribuicao { border-radius: 0.75rem; z-index: 10; }
        .leaflet-popup-content-wrapper { background: #1e293b; color: #f8fafc; border: 1px solid rgba(255,255,255,0.1); }
        .leaflet-popup-tip { background: #1e293b; }
        .leaflet-tooltip { background: #1e293b; color: #f8fafc; border: 1px solid rgba(255,255,255,0.15); box-shadow: 0 4px 12px rgba(0,0,0,0.4); font-size: 12px; padding: 5px 10px; }
        .leaflet-tooltip::before { border-right-color: #1e293b; }

        /* ── MAPA MOBILE ── */
        @media (max-width: 639px) {
            #mapa-mobile-bar { display: flex !important; }
            .mapa-controles-desktop { display: none !important; }

            #painel-lista-os {
                top: auto !important; left: 0 !important; right: 0 !important;
                bottom: 56px !important; width: 100% !important;
                max-height: 55vh !important;
                border-radius: 16px 16px 0 0 !important;
                transform: translateY(calc(100% + 60px));
                transition: transform 0.3s cubic-bezier(.4,0,.2,1);
            }
            #painel-lista-os.mob-open  { transform: translateY(0) !important; }

            #painel-atribuicao {
                top: auto !important; left: 0 !important; right: 0 !important;
                bottom: 56px !important; width: 100% !important;
                max-height: 65vh !important;
                border-radius: 16px 16px 0 0 !important;
                transform: translateY(calc(100% + 60px));
                transition: transform 0.3s cubic-bezier(.4,0,.2,1);
            }
            #painel-atribuicao.mob-open { transform: translateY(0) !important; }

            #painel-lista-os::before, #painel-atribuicao::before {
                content: ''; display: block; width: 36px; height: 4px;
                background: rgba(148,163,184,.35); border-radius: 2px;
                margin: 0 auto 10px;
            }
        }
        @media (min-width: 640px) { #mapa-mobile-bar { display: none !important; } }

        .av-tec-col.av-drop-zone { background: rgba(99,102,241,0.09) !important; }
        .av-os-block { transition: opacity 0.15s, filter 0.15s; user-select: none; }
        .av-os-block:hover { filter: brightness(1.2); }
        .av-os-block:active { cursor: grabbing; }

        #signature-pad { touch-action: none; background: #cbd5e1; border-radius: 0.5rem; }

        /* Loading overlay */
        #loading-firebase {
            position: fixed; inset: 0; z-index: 9999;
            background: #020617;
            display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
        }
        #loading-firebase.hidden { display: none; }
        .spinner {
            width: 40px; height: 40px; border: 3px solid rgba(99,102,241,0.2);
            border-top-color: #6366f1; border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        /* ── MÃO TÉCNICA — scroll apenas vertical ── */
        #view-tecnico,
        #modal-exec-os,
        #modal-detalhe-os-tec,
        #modal-agenda-tec,
        #modal-nao-exec {
            max-width: 100vw;
            overflow-x: hidden;
        }
        #view-tecnico .flex-1,
        #modal-exec-os .flex-1 {
            overflow-x: hidden;
        }
        /* garante que textos longos quebrem dentro dos cards da mão técnica */
        #view-tecnico p,
        #view-tecnico span,
        #view-tecnico div,
        #modal-exec-os p,
        #modal-exec-os span,
        #modal-detalhe-os-tec p,
        #modal-detalhe-os-tec span {
            word-break: break-word;
            overflow-wrap: break-word;
        }
        /* exceção: o seletor de dias da mão técnica pode rolar pro lado */
        #view-tecnico .scrollbar-none {
            overflow-x: auto !important;
        }

        /* ── IA CHAT ── */
        @keyframes ia-bounce {
            0%,80%,100% { transform: translateY(0); opacity:.4; }
            40%          { transform: translateY(-5px); opacity:1; }
        }
        .ia-dot {
            display: inline-block; width: 7px; height: 7px; border-radius: 50%;
            background: #a78bfa;
            animation: ia-bounce 1.2s infinite ease-in-out;
        }
        .ia-dot:nth-child(2) { animation-delay: .15s; }
        .ia-dot:nth-child(3) { animation-delay: .30s; }
        .ia-link {
            color: #818cf8; text-decoration: underline; text-underline-offset: 2px;
            word-break: break-all;
        }
        .ia-link:hover { color: #a5b4fc; }
        .ia-bubble-copy {
            opacity: 0; transition: opacity .15s;
        }
        .ia-msg-row:hover .ia-bubble-copy { opacity: 1; }
        #tab-ia.active { display: flex !important; flex-direction: column; }

        /* ── VoIP softphone ── */
        .voip-tecla {
            aspect-ratio: 1;
            display: flex; align-items: center; justify-content: center;
            background: rgba(30,41,59,0.7);
            border: 1px solid rgba(255,255,255,0.07);
            border-radius: 12px;
            font-size: 20px; font-weight: 800;
            color: #e2e8f0;
            cursor: pointer;
            transition: background 0.15s, transform 0.1s;
            -webkit-tap-highlight-color: transparent;
        }
        .voip-tecla:active { background: rgba(99,102,241,0.3); transform: scale(0.93); }
        #voip-ctrls-chamada.hidden { display: none !important; }
        #voip-ctrls-chamada { display: flex; }

        /* ── Chat (aba do gestor) em tela cheia no celular — sem card ── */
        @media (max-width: 767.98px) {
            #tab-chat { margin: -1rem; }
            #tab-chat > div {
                gap: 0;
                min-height: 0;
                height: calc(100vh - 128px);
                height: calc(100dvh - 128px);
            }
            #tab-chat .glass-panel {
                background: transparent;
                backdrop-filter: none;
                -webkit-backdrop-filter: none;
                border: 0;
                border-radius: 0;
                box-shadow: none;
            }
        }
        @media (min-width: 640px) and (max-width: 767.98px) {
            #tab-chat { margin: -1.5rem; }
        }
