/* Morgan Online - Estilos */
:root {
            --bg:        #0a0a0a;
            --sidebar:   #111111;
            --surface:   #161616;
            --surface2:  #1e1e1e;
            --border:    rgba(255,255,255,0.07);
            --border2:   rgba(255,255,255,0.12);
            --accent:    #7c3aed;
            --accent-h:  #6d28d9;
            --glow:      rgba(124,58,237,0.22);
            --text:      #f1f5f9;
            --muted:     #64748b;
            --dim:       #334155;
            --user-msg:  #1e1b4b;
            --ai-msg:    #161616;
            --green:     #10b981;
            --cyan:      #06b6d4;
            --pink:      #ec4899;
        }

        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
        html, body { height: 100%; overflow: hidden; }

        body {
            font-family: 'Inter', sans-serif;
            background: var(--bg);
            color: var(--text);
            display: flex;
        }

        /* ───── SIDEBAR ───── */
        .sidebar {
            width: 56px;
            background: var(--sidebar);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 12px 0;
            gap: 4px;
            flex-shrink: 0;
            z-index: 30;
            position: relative;
        }

        .sidebar-logo {
            width: 36px;
            height: 36px;
            margin-bottom: 12px;
            filter: drop-shadow(0 0 8px rgba(124,58,237,0.5));
            cursor: pointer;
        }

        /* Ícone do topo da sidebar = o próprio bichinho (reaproveita .msg-avatar.ai
           e todas as expressões/animações que já existem pro chat — não é mais
           uma imagem estática). */
        .sidebar .sidebar-pet-avatar {
            width: 36px;
            height: 36px;
            margin-bottom: 12px;
            margin-top: 0;
            cursor: pointer;
            filter: drop-shadow(0 0 8px rgba(124,58,237,0.35));
        }
        .sidebar .sidebar-pet-avatar .morgan-eye-mini {
            width: 9px;
            height: 6px;
        }

        .nav-btn {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 1.05rem;
            color: var(--muted);
            background: transparent;
            border: none;
            position: relative;
            transition: all 0.15s;
        }

        .nav-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
        .nav-btn.active { background: rgba(124,58,237,0.2); color: #a78bfa; }

        .nav-btn .tip {
            position: absolute;
            left: calc(100% + 10px);
            background: #1e1e1e;
            border: 1px solid var(--border2);
            color: var(--text);
            font-size: 0.72rem;
            font-weight: 500;
            padding: 4px 8px;
            border-radius: 6px;
            white-space: nowrap;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.15s;
            z-index: 100;
        }

        .nav-btn:hover .tip { opacity: 1; }

        .sidebar-spacer { flex: 1; }

        .sidebar-user {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--pink), var(--accent));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            font-weight: 700;
            cursor: pointer;
            margin-top: 8px;
            position: relative;
        }

        .sidebar-user .tip {
            position: absolute;
            left: calc(100% + 10px);
            background: #1e1e1e;
            border: 1px solid var(--border2);
            color: var(--text);
            font-size: 0.72rem;
            font-weight: 500;
            padding: 4px 8px;
            border-radius: 6px;
            white-space: nowrap;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.15s;
            z-index: 100;
        }

        .sidebar-user:hover .tip { opacity: 1; }

        /* ───── MAIN AREA ───── */
        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            height: 100vh; /* fallback pra navegador sem suporte a dvh */
            height: 100dvh; /* viewport "dinâmica": some da barra de endereço/teclado
                                do celular sem esconder o campo de mensagem embaixo.
                                100vh sozinho usa a altura MÁXIMA da tela (barra
                                recolhida), então em telas onde a barra aparece
                                expandida no primeiro load, o .chat-input-area (que é
                                o último item da coluna) fica alto demais e sai da
                                área visível — sem scroll de página pra recuperar,
                                porque html/body e todo pai no meio têm overflow:hidden
                                de propósito (só .chat-stream deve rolar). */
        }

        /* ───── VIEWS ───── */
        .view { display: none; flex: 1; overflow: hidden; flex-direction: column; }
        .view.active { display: flex; }

        /* ───── CHAT VIEW (full-height, Gemini-style) ───── */
        .chat-wrap {
            display: flex;
            flex-direction: column;
            height: 100%;
            overflow: hidden;
        }

        /* Welcome screen (when no conversation selected) */
        .chat-welcome {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 20px;
            padding: 40px 20px;
            background: radial-gradient(ellipse at 50% 30%, rgba(124,58,237,0.12) 0%, transparent 65%);
        }

        .chat-welcome h1 {
            font-size: 2rem;
            font-weight: 700;
            letter-spacing: -0.5px;
            text-align: center;
            color: var(--text);
        }

        .chat-welcome-input-wrap {
            width: 100%;
            max-width: 680px;
            background: var(--surface);
            border: 1px solid var(--border2);
            border-radius: 16px;
            display: flex;
            align-items: flex-end;
            gap: 10px;
            padding: 14px 16px;
            box-shadow: 0 4px 30px rgba(0,0,0,0.4);
            transition: border-color 0.2s, box-shadow 0.2s;
        }

        .chat-welcome-input-wrap:focus-within {
            border-color: rgba(124,58,237,0.5);
            box-shadow: 0 4px 30px rgba(124,58,237,0.15);
        }

        .chat-welcome-input-wrap textarea {
            flex: 1;
            background: transparent;
            border: none;
            outline: none;
            color: var(--text);
            font-size: 0.95rem;
            font-family: 'Inter', sans-serif;
            resize: none;
            min-height: 24px;
            max-height: 140px;
            line-height: 1.5;
            overflow-y: auto;
        }

        .chat-welcome-input-wrap textarea::placeholder { color: var(--muted); }

        /* Active conversation view */
        .chat-active {
            display: flex;
            flex-direction: column;
            height: 100%;
            overflow: hidden;
        }

        .chat-topbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 20px;
            border-bottom: 1px solid var(--border);
            background: var(--bg);
            flex-shrink: 0;
        }

        .chat-topbar h3 { font-size: 0.9rem; font-weight: 600; }
        .chat-online { font-size: 0.7rem; color: var(--green); margin-top: 2px; }

        .chat-stream {
            flex: 1;
            overflow-y: auto;
            padding: 24px 0;
            display: flex;
            flex-direction: column;
            gap: 0;
            scroll-behavior: smooth;
        }

        .chat-stream::-webkit-scrollbar { width: 4px; }
        .chat-stream::-webkit-scrollbar-track { background: transparent; }
        .chat-stream::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 4px; }

        .msg-row {
            display: flex;
            padding: 4px 24px;
            gap: 14px;
            max-width: 800px;
            width: 100%;
            margin: 0 auto;
        }

        .msg-row.user { flex-direction: row-reverse; }

        .msg-avatar {
            width: 30px;
            height: 30px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.78rem;
            font-weight: 700;
            flex-shrink: 0;
            margin-top: 2px;
        }

        .msg-avatar.ai   { background: linear-gradient(135deg,var(--accent),var(--cyan)); color:#fff; }
        .msg-avatar.user { background: var(--surface2); color: var(--text); }

        .msg-content { flex: 1; max-width: 720px; }
        .msg-row.user .msg-content { display: flex; justify-content: flex-end; }

        .msg-bubble {
            padding: 11px 16px;
            border-radius: 14px;
            font-size: 0.9rem;
            line-height: 1.6;
            white-space: pre-wrap;
            word-break: break-word;
        }

        .msg-row.user .msg-bubble {
            background: var(--user-msg);
            border: 1px solid rgba(124,58,237,0.3);
            border-bottom-right-radius: 4px;
            max-width: 540px;
        }

        .msg-row.ai .msg-bubble {
            background: transparent;
            color: var(--text);
            border-bottom-left-radius: 4px;
            padding-left: 0;
        }

        pre.code-block {
            background: #0d111e;
            border: 1px solid var(--border2);
            border-radius: 10px;
            padding: 14px 16px;
            font-family: 'Fira Code', monospace;
            font-size: 0.78rem;
            color: #7dd3fc;
            overflow-x: auto;
            margin-top: 8px;
            line-height: 1.5;
        }

        /* Chat Input (bottom fixed) */
        .chat-input-area {
            padding: 12px 16px 16px;
            background: var(--bg);
            border-top: 1px solid var(--border);
            flex-shrink: 0;
        }

        .chat-input-box {
            max-width: 800px;
            margin: 0 auto;
            background: var(--surface);
            border: 1px solid var(--border2);
            border-radius: 14px;
            display: flex;
            flex-direction: column;
            padding: 12px 14px 10px;
        }

        .chat-input-box:focus-within {
            border-color: rgba(124,58,237,0.5);
        }

        .chat-input-box textarea {
            flex: 1;
            background: transparent;
            border: none;
            outline: none;
            color: var(--text);
            font-size: 0.9rem;
            font-family: 'Inter', sans-serif;
            resize: none;
            min-height: 22px;
            max-height: 120px;
            overflow-y: auto;
            line-height: 1.5;
        }

        .chat-input-box textarea::placeholder { color: var(--muted); }

        
/* Botões de Ação do Chat */
.btn-voice {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    transition: all 0.2s;
    margin-right: 4px;
}
.btn-voice:hover {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.btn-send {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            background: var(--accent);
            border: none;
            color: white;
            font-size: 0.95rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: background 0.15s;
        }

        .btn-send:hover { background: var(--accent-h); }
        .btn-send:disabled { background: var(--dim); cursor: not-allowed; }

        /* ───── DASHBOARD VIEW ───── */
        .dash-wrap {
            flex: 1;
            overflow-y: auto;
            padding: 28px;
        }

        .page-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 22px; }
        .page-subtitle { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }

        .kpi-row {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 14px;
            margin-bottom: 22px;
        }

        .kpi {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 18px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .kpi-val { font-size: 1.7rem; font-weight: 800; letter-spacing: -1px; }
        .kpi-lbl { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }

        .kpi-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            font-size: 1.1rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .kpi-icon.v { background: rgba(124,58,237,.15); }
        .kpi-icon.c { background: rgba(6,182,212,.15); }
        .kpi-icon.g { background: rgba(16,185,129,.15); }
        .kpi-icon.p { background: rgba(236,72,153,.15); }

        .dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

        .panel {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 20px;
        }

        .panel-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 14px; }

        .act-item {
            display: flex;
            gap: 10px;
            align-items: flex-start;
            padding: 10px;
            border-radius: 8px;
            margin-bottom: 6px;
            background: rgba(255,255,255,0.02);
            border: 1px solid var(--border);
        }

        .act-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
        .act-h { font-size: 0.8rem; font-weight: 600; }
        .act-d { font-size: 0.72rem; color: var(--muted); }
        .act-t { font-size: 0.66rem; color: var(--dim); margin-left: auto; flex-shrink: 0; }
        .act-empty { color: var(--muted); font-size: 0.82rem; padding: 20px; text-align: center; }

        .chart-svg-wrap { height: 160px; margin-bottom: 12px; }

        .chart-footer { display: flex; justify-content: space-around; padding-top: 12px; border-top: 1px solid var(--border); text-align: center; }
        .chart-stat-val { font-size: 1.15rem; font-weight: 700; }
        .chart-stat-lbl { font-size: 0.7rem; color: var(--muted); }

        /* ───── GENERIC DATA VIEW ───── */
        .data-wrap {
            flex: 1;
            overflow-y: auto;
            padding: 24px 28px;
        }

        .data-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 16px;
        }

        .pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

        .pill {
            background: rgba(255,255,255,0.04);
            border: 1px solid var(--border);
            color: var(--muted);
            padding: 5px 12px;
            border-radius: 20px;
            font-size: 0.74rem;
            cursor: pointer;
            transition: all 0.15s;
        }

        .pill:hover, .pill.active { background: var(--accent); color: white; border-color: var(--accent); }

        .data-table { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

        table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
        th { background: rgba(255,255,255,0.03); padding: 11px 14px; text-align: left; color: var(--muted); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--border); }
        td { padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,0.03); vertical-align: middle; }
        tr:last-child td { border-bottom: none; }
        tr:hover td { background: rgba(255,255,255,0.015); }

        .badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 5px; font-size: 0.69rem; font-weight: 600; font-family: 'Fira Code', monospace; }
        .badge.g { background: rgba(16,185,129,.15); color: #34d399; }
        .badge.v { background: rgba(124,58,237,.15); color: #a78bfa; }
        .badge.c { background: rgba(6,182,212,.15); color: #38bdf8; }
        .badge.p { background: rgba(236,72,153,.15); color: #f472b6; }

        .empty-state { padding: 40px; text-align: center; color: var(--muted); font-size: 0.85rem; }

        /* ───── PROFILE VIEW ───── */
        .profile-wrap {
            flex: 1;
            overflow-y: auto;
            padding: 28px;
        }

        .profile-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 28px;
            max-width: 560px;
            margin-bottom: 18px;
        }

        .profile-avatar {
            width: 72px;
            height: 72px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--pink), var(--accent));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.8rem;
            font-weight: 700;
            margin-bottom: 14px;
        }

        .f-label { display: block; font-size: 0.73rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
        .f-input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; color: var(--text); font-size: 0.87rem; outline: none; margin-bottom: 12px; }
        .f-input:focus { border-color: var(--accent); }
        .f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

        /* ───── SETTINGS VIEW ───── */
        .settings-wrap { flex: 1; overflow-y: auto; padding: 28px; }
        .stabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
        .stab { padding: 8px 16px; font-size: 0.82rem; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
        .stab.active { color: var(--text); border-bottom-color: var(--accent); }

        /* ───── MODAL ───── */
        .modal-bg {
            position: fixed; inset: 0;
            background: rgba(0,0,0,0.7);
            backdrop-filter: blur(6px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 999;
        }

        .modal-box {
            background: var(--surface);
            border: 1px solid var(--border2);
            border-radius: 14px;
            padding: 24px;
            width: 100%;
            max-width: 460px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .modal-title { font-size: 1rem; font-weight: 700; }

        /* ───── BUTTONS ───── */
        .btn-primary {
            background: var(--accent);
            color: white;
            border: none;
            border-radius: 8px;
            padding: 9px 18px;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            transition: background 0.15s;
        }

        .btn-primary:hover { background: var(--accent-h); }

        .btn-ghost {
            background: rgba(255,255,255,0.05);
            color: var(--muted);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 8px 14px;
            font-size: 0.82rem;
            cursor: pointer;
        }

        .btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.08); }

        /* ───── INSPECTOR PANEL (in chat) ───── */
        .chat-layout { display: flex; flex: 1; overflow: hidden; }
        .chat-main-col { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
        .inspector-col {
            width: 280px;
            border-left: 1px solid var(--border);
            background: var(--sidebar);
            overflow-y: auto;
            padding: 16px;
            flex-shrink: 0;
        }

        .inspector-col h4 { font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

        .insp-box {
            background: rgba(0,0,0,0.3);
            border-radius: 8px;
            padding: 10px;
            margin-bottom: 10px;
            font-size: 0.74rem;
        }

        .insp-lbl { color: var(--muted); margin-bottom: 3px; }
        .insp-val { font-weight: 600; color: var(--text); }
        .insp-chain { font-family: 'Fira Code', monospace; color: #94a3b8; font-size: 0.7rem; line-height: 1.6; }

        /* ─── SCROLLBAR GLOBAL ─── */
        ::-webkit-scrollbar { width: 4px; height: 4px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 4px; }
    

        /* ── Avatar Animado Morgan (Chat) ── */
        .msg-avatar.ai {
            background: #090a10;
            border: 1px solid rgba(139, 92, 246, 0.45);
            box-shadow: 0 0 10px rgba(139, 92, 246, 0.35);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            overflow: visible;
            transition: border-color 0.35s ease, box-shadow 0.35s ease;
        }

        /*
         * Olho Mini — formato "dome" (largo+arredondado no topo, plano embaixo)
         * igual ao ícone original da Morgan. NÃO usar height > width.
         */
        .morgan-eye-mini {
            width: 8px;
            height: 5px;
            /* dome: canto superior totalmente arredondado, inferior reto */
            border-radius: 50% 50% 20% 20% / 80% 80% 20% 20%;
            background: #d1fae5;
            box-shadow: none;
            animation: morganBotBlink 3.6s infinite ease-in-out;
            transition: all 0.3s ease;
        }

        /* ── PADRÃO (default): verde suave ── */
        /* (usa a cor base acima, sem override) */

        /* ── PENSANDO: um olho menor/levantado, pontinhos ── */
        .msg-avatar.ai.thinking {
            border-color: rgba(139,92,246,0.8);
            box-shadow: 0 0 14px rgba(139,92,246,0.65);
        }
        .msg-avatar.ai.thinking .morgan-eye-mini:first-child {
            transform: scaleY(0.6) translateY(-1px);
            animation: morganEyeThink 1.8s infinite ease-in-out;
        }
        .msg-avatar.ai.thinking .morgan-eye-mini:last-child {
            transform: scaleY(0.85) translateY(-2px);
            animation: morganEyeThink 1.8s 0.4s infinite ease-in-out;
        }

        /* ── DORMINDO: curva para baixo (olho fechado), sem brilho ── */
        .msg-avatar.ai.sleeping {
            border-color: rgba(71, 85, 105, 0.5);
            box-shadow: 0 0 6px rgba(71, 85, 105, 0.3);
        }
        .msg-avatar.ai.sleeping .morgan-eye-mini {
            width: 8px;
            height: 3px;
            border-radius: 0 0 50% 50% / 0 0 80% 80%; /* curva para baixo */
            background: #94a3b8;
            box-shadow: none;
            animation: morganEyeZzz 4s infinite ease-in-out;
        }

        /* ── FELIZ: olho levemente arqueado/fechado no topo ── */
        .msg-avatar.ai.happy {
            border-color: rgba(74, 222, 128, 0.7);
            box-shadow: 0 0 12px rgba(74, 222, 128, 0.45);
        }
        .msg-avatar.ai.happy .morgan-eye-mini {
            width: 9px;
            height: 4px;
            border-radius: 50% 50% 30% 30% / 80% 80% 20% 20%;
            background: #bbf7d0;
            box-shadow: none;
            animation: morganEyeHappy 2s infinite ease-in-out;
        }

        /* ── ENTEDIADO: olho achatado, semi-fechado ── */
        .msg-avatar.ai.bored {
            border-color: rgba(100, 116, 139, 0.5);
            box-shadow: 0 0 6px rgba(100, 116, 139, 0.3);
        }
        .msg-avatar.ai.bored .morgan-eye-mini {
            width: 9px;
            height: 3px;
            border-radius: 50% 50% 20% 20% / 70% 70% 30% 30%;
            background: #94a3b8;
            box-shadow: none;
            animation: none;
        }

        /* ── SURPRESO: olho maior/redondo ── */
        .msg-avatar.ai.surprised {
            border-color: rgba(56, 189, 248, 0.7);
            box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
        }
        .msg-avatar.ai.surprised .morgan-eye-mini {
            width: 9px;
            height: 9px;
            border-radius: 50%;
            background: #e0f2fe;
            box-shadow: none;
            animation: morganEyeSurprise 0.3s ease-out;
        }

        /* ── DEBOCHADO/SARCÁSTICO: um olho semi-fechado, outro normal ── */
        .msg-avatar.ai.sarcastic .morgan-eye-mini:first-child {
            width: 8px;
            height: 3px;
            border-radius: 50% 50% 20% 20% / 70% 70% 30% 30%;
            transform: rotate(-8deg);
            animation: none;
        }
        .msg-avatar.ai.sarcastic .morgan-eye-mini:last-child {
            width: 8px;
            height: 3px;
            border-radius: 50% 50% 20% 20% / 70% 70% 30% 30%;
            transform: rotate(8deg);
            animation: none;
        }

        /* ── BRAVO: olhos com sobrancelha (inclinados para dentro) ── */
        .msg-avatar.ai.angry {
            border-color: rgba(239, 68, 68, 0.7);
            box-shadow: 0 0 14px rgba(239, 68, 68, 0.4);
        }
        .msg-avatar.ai.angry .morgan-eye-mini:first-child {
            width: 8px;
            height: 5px;
            border-radius: 50% 50% 20% 20% / 80% 80% 20% 20%;
            transform: rotate(20deg) translateY(-1px);
            background: #fca5a5;
            animation: none;
        }
        .msg-avatar.ai.angry .morgan-eye-mini:last-child {
            width: 8px;
            height: 5px;
            border-radius: 50% 50% 20% 20% / 80% 80% 20% 20%;
            transform: rotate(-20deg) translateY(-1px);
            background: #fca5a5;
            animation: none;
        }

        /* ── Keyframes ── */
        @keyframes morganBotBlink {
            0%, 92%, 100% { transform: scaleY(1); }
            96%           { transform: scaleY(0.1); }
        }
        @keyframes morganEyeThink {
            0%, 100% { transform: scaleY(0.75) translateY(-1px); }
            50%      { transform: scaleY(0.5) translateY(-2px); }
        }
        @keyframes morganEyeZzz {
            0%, 100% { transform: scaleX(1); }
            50%      { transform: scaleX(0.85); }
        }
        @keyframes morganEyeHappy {
            0%, 100% { transform: scaleY(1); }
            50%      { transform: scaleY(1.15) translateY(-1px); }
        }
        @keyframes morganEyeSurprise {
            from { transform: scale(0.5); }
            to   { transform: scale(1); }
        }

        /* ══════════════════════════════════════════════════════════
           Cards de resultado (morgan-bot-card) — robot mascot
           ══════════════════════════════════════════════════════════ */
        .morgan-bot-card {
            display: flex;
            gap: 16px;
            align-items: flex-start;
            background: linear-gradient(135deg, rgba(20,24,38,0.95), rgba(13,16,26,0.95));
            border: 1px solid rgba(139,92,246,0.3);
            box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
            border-radius: 18px;
            padding: 20px 22px;
            margin: 10px 0;
            width: 100%;
            max-width: 780px;
            color: #e2e8f0;
            font-family: var(--font-sans);
            position: relative;
            overflow: hidden;
            animation: morganBotFadeIn 0.35s ease-out;
        }
        @keyframes morganBotFadeIn {
            from { opacity: 0; transform: translateY(8px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        .morgan-bot-card.error {
            border-color: rgba(244,63,94,0.4);
            box-shadow: 0 10px 30px rgba(244,63,94,0.15), inset 0 1px 0 rgba(255,255,255,0.05);
        }
        .morgan-bot-card.not-found {
            border-color: rgba(129,140,248,0.4);
            box-shadow: 0 10px 30px rgba(99,102,241,0.15);
        }

        /* Cabeça do robô mascote (cards grandes) */
        .morgan-bot-head {
            width: 54px;
            height: 54px;
            min-width: 54px;
            background: #090a10;
            border-radius: 14px;
            border: 1.5px solid rgba(139,92,246,0.45);
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            box-shadow: 0 0 16px rgba(139,92,246,0.35);
            flex-shrink: 0;
        }
        .morgan-bot-card.error .morgan-bot-head {
            border-color: #f43f5e;
            box-shadow: 0 0 18px rgba(244,63,94,0.45);
        }
        .morgan-bot-card.not-found .morgan-bot-head {
            border-color: #38bdf8;
            box-shadow: 0 0 18px rgba(56,189,248,0.4);
        }

        /* Rosto e olhos dos cards */
        .morgan-bot-face {
            display: flex;
            gap: 8px;
            align-items: center;
            justify-content: center;
        }
        .morgan-bot-eye {
            width: 12px;
            height: 8px;
            border-radius: 50% 50% 20% 20% / 80% 80% 20% 20%;
            background: #d1fae5;
            animation: morganBotBlink 3.6s infinite ease-in-out;
        }
        .morgan-bot-card.error .morgan-bot-eye {
            background: #fca5a5;
            animation: morganBotAlert 1.2s infinite ease-in-out;
        }
        .morgan-bot-card.not-found .morgan-bot-eye {
            background: #bae6fd;
            animation: morganBotLookAround 3.2s infinite ease-in-out;
        }
        @keyframes morganBotAlert {
            0%, 100% { transform: scale(1); opacity: 1; }
            50%      { transform: scale(0.85); opacity: 0.6; }
        }
        @keyframes morganBotLookAround {
            0%, 100% { transform: translate(0, 0) scaleY(1); }
            28%      { transform: translate(-3px, -1px) scaleY(0.9); }
            70%      { transform: translate(3px, -1px) scaleY(0.9); }
            94%      { transform: translate(0, 0) scaleY(0.1); }
        }

        /* Conteúdo dos cards */
        .morgan-bot-body { flex: 1; min-width: 0; }
        .morgan-bot-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 0.72rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            padding: 3px 9px;
            border-radius: 999px;
            margin-bottom: 8px;
        }
        .morgan-bot-card.error .morgan-bot-badge {
            background: rgba(244,63,94,0.15);
            color: #fb7185;
            border: 1px solid rgba(244,63,94,0.3);
        }
        .morgan-bot-card.not-found .morgan-bot-badge {
            background: rgba(99,102,241,0.15);
            color: #a5b4fc;
            border: 1px solid rgba(129,140,248,0.3);
        }
        .morgan-bot-title {
            font-size: 1.05rem;
            font-weight: 700;
            color: #fff;
            margin-bottom: 6px;
        }
        .morgan-bot-text {
            font-size: 0.88rem;
            line-height: 1.55;
            color: #cbd5e1;
            margin-bottom: 14px;
        }
        .morgan-bot-details {
            font-size: 0.76rem;
            color: #94a3b8;
            background: rgba(0,0,0,0.3);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 8px;
            padding: 10px 12px;
            margin-bottom: 14px;
            font-family: monospace;
            word-break: break-all;
        }
        .morgan-bot-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }
        .morgan-bot-btn {
            font-size: 0.8rem;
            padding: 7px 14px;
            border-radius: 8px;
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(255,255,255,0.05);
            color: #e2e8f0;
            cursor: pointer;
            transition: all 0.2s;
        }
        .morgan-bot-btn:hover { background: rgba(255,255,255,0.12); }
        .morgan-bot-btn.primary {
            background: rgba(124,58,237,0.25);
            border-color: rgba(124,58,237,0.5);
            color: #c4b5fd;
        }
        .morgan-bot-btn.primary:hover { background: rgba(124,58,237,0.4); }


/* Morgan AI Footer */
.morgan-ai-footer {
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 4px;
    text-align: center;
    opacity: 0.7;
    font-weight: 300;
}

/* Thinking Row / Bubble */
.thinking-row {
    display: flex;
    padding: 4px 24px;
    gap: 14px;
    margin: 0 auto;
    max-width: 800px;
    width: 100%;
}

.thinking-bubble {
    flex: 1;
    background: rgba(124,58,237,0.06);
    border: 1px solid rgba(124,58,237,0.18);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 4px;
}

.msg-bubble p {
    margin: 0 0 8px 0;
}
.msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Thinking Block Structure */
.thinking-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 8px;
}
.thinking-dot {
    width: 8px;
    height: 8px;
    background: #eab308;
    border-radius: 50%;
    animation: pulseDot 1.5s infinite;
}
.thinking-dot.done {
    background: #10b981;
    animation: none;
}
@keyframes pulseDot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 4px rgba(234, 179, 8, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(234, 179, 8, 0); }
}
.thinking-label {
    flex: 1;
    font-weight: 600;
    color: #cbd5e1;
}
.thinking-label.done {
    color: #94a3b8;
}
.thinking-toggle {
    font-size: 0.7rem;
    transition: transform 0.3s;
    color: #64748b;
    transform: rotate(180deg);
}
.thinking-toggle.open {
    transform: rotate(0deg);
}
.thinking-body {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(124,58,237,0.2);
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s, margin 0.3s, padding 0.3s;
    max-height: 500px;
    opacity: 1;
}
.thinking-body.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.thinking-step {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
    color: #94a3b8;
}

/* AI Actions */
.morgan-ai-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}
.ai-action-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 6px;
    transition: all 0.2s;
}
.ai-action-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}


/* AI Actions UI */
.morgan-ai-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}
.action-left, .action-right {
    display: flex;
    gap: 4px;
    align-items: center;
}
.ai-action-icon {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.ai-action-icon:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}


/* ── Chat Input Footer ── */
#chatInput {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    resize: none;
    width: 100%;
    max-height: 150px;
    padding: 0;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 8px;
}
#chatInput::placeholder { color: var(--muted); }

.chat-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 8px;
}
.agent-version-badge {
    font-size: 0.72rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
.agent-version-badge:hover { color: var(--text); }
.chat-input-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* AI Message Action Buttons */
.morgan-ai-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}
.action-left, .action-right {
    display: flex;
    gap: 2px;
    align-items: center;
}
.ai-action-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.ai-action-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}
.ai-action-icon {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.ai-action-icon:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}
.ai-action-icon.liked { color: var(--green) !important; }
.ai-action-icon.disliked { color: #f87171 !important; }

/* --- MORGAN AVATAR EMOTIONS --- */

/* Base transition for smooth eye animations */
.morgan-eye-mini {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), height 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
}

/* 1. BORED (Entediada) - Olhos meio fechados */
.msg-avatar.ai.bored .morgan-eye-mini {
    height: 4px;
    transform: translateY(2px);
    border-radius: 4px;
}

/* 2. SLEEPING (Dormindo) - Olhos quase fechados (uma linha) */
.msg-avatar.ai.sleeping .morgan-eye-mini {
    height: 2px;
    transform: translateY(4px);
    border-radius: 2px;
    background-color: var(--muted);
}
/* Efeito visual extra para dormindo (Zzz) */
@keyframes zzz {
    0% { opacity: 0; transform: translate(0, 0) scale(0.5); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translate(10px, -15px) scale(1); }
}
.msg-avatar.ai.sleeping::after {
    content: 'Zzz';
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.6rem;
    color: var(--muted);
    animation: zzz 2s infinite linear;
}

/* 3. ANGRY (Bravo) - Olhos inclinados para dentro */
.msg-avatar.ai.angry .morgan-eye-mini {
    height: 6px;
    border-radius: 2px 8px 2px 2px;
}
.msg-avatar.ai.angry .morgan-eye-mini:first-child {
    transform: rotate(20deg) translateY(2px);
}
.msg-avatar.ai.angry .morgan-eye-mini:last-child {
    transform: rotate(-20deg) translateY(2px);
}

/* 4. SARCASTIC (Debochado/Sarcástico) - Um olho meio fechado, o outro normal ou levantado */
.msg-avatar.ai.sarcastic .morgan-eye-mini:first-child {
    height: 8px;
    transform: translateY(-1px);
}
.msg-avatar.ai.sarcastic .morgan-eye-mini:last-child {
    height: 3px;
    transform: translateY(3px);
}

.msg-avatar { position: relative; }

/* ══════════════════════════════════════════════════════════
   MORGAN — NOVAS EXPRESSÕES (mecanismo de vida / bichinho)
   Mesma linguagem visual dos estados acima (dois "morgan-eye-mini"),
   só que cobrindo fome, sede, sono intermediário, doença e reações
   transitórias (estudando/apaixonada/assustada).
   ══════════════════════════════════════════════════════════ */

/* SONOLENTO: passo intermediário antes de dormir — pisca devagar e pesado */
.msg-avatar.ai.sonolento {
    border-color: rgba(100, 116, 139, 0.55);
    box-shadow: 0 0 8px rgba(100, 116, 139, 0.3);
}
.msg-avatar.ai.sonolento .morgan-eye-mini {
    width: 8px;
    height: 4px;
    border-radius: 50% 50% 30% 30% / 70% 70% 30% 30%;
    background: #cbd5e1;
    animation: morganEyeSonolento 3.2s infinite ease-in-out;
}
@keyframes morganEyeSonolento {
    0%, 80%, 100% { transform: scaleY(1); }
    90%           { transform: scaleY(0.25); }
}

/* CANSADO: mais leve que sonolento — olhos pesados, pisca lento */
.msg-avatar.ai.cansado {
    border-color: rgba(148, 163, 184, 0.5);
    box-shadow: 0 0 6px rgba(148, 163, 184, 0.25);
}
.msg-avatar.ai.cansado .morgan-eye-mini {
    width: 8px;
    height: 4px;
    border-radius: 50% 50% 30% 30% / 70% 70% 30% 30%;
    background: #94a3b8;
    transform: translateY(1px);
    animation: morganBotBlink 5.5s infinite ease-in-out;
}

/* COM FOME: olhos ansiosos, pulsando, tom quente */
.msg-avatar.ai.com-fome {
    border-color: rgba(251, 146, 60, 0.7);
    box-shadow: 0 0 14px rgba(251, 146, 60, 0.4);
}
.msg-avatar.ai.com-fome .morgan-eye-mini {
    width: 9px;
    height: 6px;
    border-radius: 50% 50% 30% 30% / 80% 80% 20% 20%;
    background: #fed7aa;
    animation: morganEyeFome 1.1s infinite ease-in-out;
}
@keyframes morganEyeFome {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.18); }
}

/* COM SEDE: olhos ressecados/piscando fino, tom frio + gotinha */
.msg-avatar.ai.com-sede {
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}
.msg-avatar.ai.com-sede .morgan-eye-mini {
    width: 8px;
    height: 4px;
    border-radius: 50% 50% 20% 20% / 70% 70% 30% 30%;
    background: #bae6fd;
    animation: morganEyeSede 2s infinite ease-in-out;
}
@keyframes morganEyeSede {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(0.55); }
}
.msg-avatar.ai.com-sede::after {
    content: '💧';
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.55rem;
    animation: zzz 2.2s infinite linear;
}

/* GRIPADO: doente — olhos tortos/assimétricos, tom esverdeado, saturação baixa */
.msg-avatar.ai.gripado {
    border-color: rgba(132, 204, 22, 0.5);
    box-shadow: 0 0 12px rgba(132, 204, 22, 0.3);
    filter: saturate(0.6);
}
.msg-avatar.ai.gripado .morgan-eye-mini {
    width: 8px;
    height: 5px;
    border-radius: 40% 60% 40% 60% / 60% 40% 60% 40%;
    background: #d9f99d;
    animation: morganEyeGripado 2.4s infinite ease-in-out;
}
.msg-avatar.ai.gripado .morgan-eye-mini:last-child {
    animation-delay: 0.3s;
}
@keyframes morganEyeGripado {
    0%, 100% { transform: rotate(-4deg) scaleY(1); }
    50%      { transform: rotate(4deg) scaleY(0.7); }
}

/* ESTUDANDO: reação transitória ao ensinar/corrigir — olhos "escaneando" */
.msg-avatar.ai.estudando {
    border-color: rgba(129, 140, 248, 0.7);
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.4);
}
.msg-avatar.ai.estudando .morgan-eye-mini {
    width: 8px;
    height: 4px;
    border-radius: 40% 40% 40% 40% / 60% 60% 40% 40%;
    background: #c7d2fe;
    animation: morganEyeEstudando 1.6s infinite ease-in-out;
}
@keyframes morganEyeEstudando {
    0%, 100% { transform: translateX(-1.5px); }
    50%      { transform: translateX(1.5px); }
}

/* APAIXONADO: reação transitória rara — olhos viram coraçãozinho */
.msg-avatar.ai.apaixonado {
    border-color: rgba(251, 113, 133, 0.7);
    box-shadow: 0 0 14px rgba(251, 113, 133, 0.45);
}
.msg-avatar.ai.apaixonado .morgan-eye-mini {
    background: transparent;
    animation: morganEyeApaixonado 1s infinite ease-in-out;
}
.msg-avatar.ai.apaixonado .morgan-eye-mini::before {
    content: '♥';
    display: block;
    font-size: 9px;
    line-height: 1;
    color: #fb7185;
    text-shadow: 0 0 6px rgba(251,113,133,0.8);
}
@keyframes morganEyeApaixonado {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.2); }
}

/* ASSUSTADO: reação transitória a erro/falha — olhos arregalados + tremor */
.msg-avatar.ai.assustado {
    border-color: rgba(226, 232, 240, 0.8);
    box-shadow: 0 0 14px rgba(226, 232, 240, 0.5);
    animation: morganShake 0.4s ease-in-out 2;
}
.msg-avatar.ai.assustado .morgan-eye-mini {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f8fafc;
    animation: morganEyeSurprise 0.2s ease-out;
}
@keyframes morganShake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-2px); }
    75%      { transform: translateX(2px); }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVO — MOBILE / TELAS PEQUENAS
   Sem @media nenhuma no arquivo inteiro antes disso: os grids de
   2/4 colunas fixas e os paddings largos (pensados pra desktop)
   quebravam (conteúdo cortado, colunas espremidas, texto
   sobrepondo ícone) em telas estreitas. Ajusta só o necessário,
   sem redesenhar nada — a sidebar vertical continua igual (ela já
   funciona bem em 56px, não é o problema real).
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Grids de 2 colunas viravam colunas espremidas/cortadas
       (ex.: dashboard "Atividade Recente" + gráfico lado a lado
       sem espaço nenhum) — empilha em 1 coluna. */
    .dash-2col { grid-template-columns: 1fr; }
    .f-row { grid-template-columns: 1fr; }

    /* Paddings largos (pensados pra tela grande) comendo metade da
       largura útil numa tela de 360-400px. */
    .dash-wrap,
    .data-wrap,
    .settings-wrap,
    .profile-wrap {
        padding: 16px;
    }

    .msg-row { padding: 4px 12px; gap: 10px; }
    .msg-row.user .msg-bubble { max-width: 82vw; }
    .chat-welcome { padding: 24px 16px; }
    .chat-input-area { padding: 8px 10px 12px; }

    /* Tela de boas-vindas: "justify-content:center" deixa um vazio
       enorme embaixo do input numa tela alta e estreita — sobe o
       conteúdo em vez de centralizar no meio do vazio. */
    .chat-welcome { justify-content: flex-start; padding-top: 14vh; }
    .chat-welcome h1 { font-size: 1.5rem; }

    /* Topbar do chat: título + status de um lado, seletor de
       projeto + botão do outro, tudo numa linha só — não cabia e
       ficava espremido. Agora quebra em 2 linhas. */
    .chat-topbar {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .chat-topbar > div:last-child {
        width: 100%;
        justify-content: stretch;
    }
    .chat-topbar > div:last-child select,
    .chat-topbar > div:last-child #chatProject {
        flex: 1;
        min-width: 0;
    }

    /* Cabeçalho das telas de listagem (Conhecimento, Regras...):
       título + botão "+ Novo ..." também não cabiam lado a lado. */
    .data-header { flex-wrap: wrap; gap: 10px; }
    .data-header > button, .data-header > div[style*="display:flex"] {
        width: 100%;
    }
    .data-header .btn-primary, .data-header .btn-ghost { width: auto; }

    /* Rodapé do gráfico do dashboard: 4 estatísticas numa linha só
       (com rótulos longos tipo "Snippets & Módulos") não cabiam —
       quebra em grade 2x2. */
    .chart-footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        text-align: left;
    }

    /* Tabelas (conhecimento, regras, projetos, memória, snippets,
       arquivos...) — no lugar de cortar/sobrepor colunas ou obrigar
       scroll horizontal pra ler uma linha, cada linha vira um
       "card" com rótulo: valor (rótulo espelhado do <thead> via
       JS, em data-label). */
    .data-table { overflow-x: visible; }
    .data-table table { min-width: 0; width: 100%; }
    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 10px 12px;
        margin-bottom: 8px;
        background: rgba(255,255,255,0.02);
    }
    /* Rótulo em cima, valor embaixo — funciona tanto pra valores
       curtos ("Confiança: 100%") quanto pra parágrafos inteiros
       (ex.: "Objeto" do conhecimento), sem texto justificado à
       direita ficando difícil de ler. */
    .data-table tbody td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        padding: 8px 0;
        border: none;
        text-align: left;
        white-space: normal;
        word-break: break-word;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 700;
        color: var(--muted);
    }
    /* Coluna de Ações: os botões já são autoexplicativos (ícone +
       title) — essa sim faz sentido em linha, não empilhada. */
    .data-table tbody td:last-child {
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
    }
    .data-table tbody td:last-child::before { content: ''; }

    /* KPIs, cards ricos e cards de erro/bot já usam width:100% +
       max-width — só reforça que nada deles força scroll lateral
       na página inteira. */
    .kpi-row { gap: 10px; }
    .morgan-rich-wrapper, .morgan-bot-card { max-width: 100%; }
}

@media (max-width: 420px) {
    /* Em telas bem estreitas (iPhone SE e similares) até o valor
       das KPIs e o título ficam apertados. */
    .kpi { padding: 14px 16px; }
    .kpi-val { font-size: 1.4rem; }
    .page-title { font-size: 1.15rem; }
}

/* ══════════════════════════════════════════════════════════
   PAINEL DA MORGAN — visual de Tamagotchi físico
   Moldura com barra de ícones em cima, "tela" no meio (avatar +
   humor + stats) e barra de ações embaixo, igual ao brinqueduo
   físico (fome/sede/sono/vida/humor nos ícones, botões de ação e
   um botão "Fechar" no lugar do Esc físico).
   ══════════════════════════════════════════════════════════ */

.morgan-tama-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.72);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.morgan-tama-device {
    width: 100%;
    max-width: 340px;
    background: linear-gradient(180deg, #1c1024, #12081a);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 28px;
    padding: 16px 14px 14px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55), 0 0 0 6px rgba(255, 255, 255, 0.02) inset;
}

.morgan-tama-topbar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 8px 10px;
}

.morgan-tama-icon {
    font-size: 1.05rem;
    opacity: 0.35;
    filter: grayscale(0.6);
    transition: all 0.3s ease;
}
.morgan-tama-icon.ok   { opacity: 0.95; filter: none; }
.morgan-tama-icon.low  { opacity: 0.95; filter: none; transform: scale(1.05); }
.morgan-tama-icon.crit { opacity: 1; filter: none; animation: morganTamaIconPulse 1s infinite ease-in-out; }
@keyframes morganTamaIconPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.25); }
}

.morgan-tama-screen {
    background: #05060a;
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 16px;
    padding: 18px 14px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.morgan-tama-avatar-wrap { margin-bottom: 8px; }
.morgan-tama-avatar.msg-avatar.ai {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    gap: 8px;
}
.morgan-tama-avatar.msg-avatar.ai .morgan-eye-mini {
    width: 15px;
    height: 10px;
}

.morgan-tama-screen-text {
    text-align: center;
    margin-bottom: 8px;
}
.morgan-tama-mood {
    font-weight: 700;
    font-size: 0.95rem;
    color: #ede9fe;
}
.morgan-tama-temperament {
    font-size: 0.7rem;
    color: #a78bfa;
    margin-top: 2px;
}
.morgan-tama-sick-note {
    font-size: 0.72rem;
    color: #bef264;
    margin-top: 6px;
}

.morgan-tama-stats {
    width: 100%;
}

.morgan-tama-bottombar {
    margin-top: 14px;
}

.morgan-tama-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.morgan-tama-actbtn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    padding: 8px 4px;
    cursor: pointer;
    color: #ede9fe;
    transition: background 0.2s ease, transform 0.15s ease;
}
.morgan-tama-actbtn:hover { background: rgba(139, 92, 246, 0.22); }
.morgan-tama-actbtn:active { transform: scale(0.94); }
.morgan-tama-actbtn:disabled { opacity: 0.5; cursor: default; }
.morgan-tama-actbtn-icon { font-size: 1.15rem; }
.morgan-tama-actbtn-label { font-size: 0.6rem; color: #c4b5fd; }

.morgan-tama-navrow { display: flex; }
.morgan-tama-devbtn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 10px;
    color: var(--muted, #94a3b8);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.morgan-tama-devbtn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.morgan-tama-devbtn:active { transform: scale(0.98); }
.morgan-tama-devbtn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    font-size: 0.75rem;
    opacity: 0.75;
}

/* Bloco de debug (só admin/god) — visual dos botões de ação de verdade
   (ícone em cima, rótulo embaixo, grade), mas num bloco à parte com borda
   tracejada e cor neutra, pra ficar claro que é ferramenta de dev e não
   uma ação normal do bichinho. Fica fora de `.morgan-tama-actions` (que é
   um grid fixo de 4 colunas) pra ter a largura toda do painel só pra ele,
   sem espremer nem vazar pra fora da tela. */
.morgan-tama-debugblock {
    width: 100%;
    margin-top: 10px;
    padding: 8px 8px 10px;
    border: 1px dashed rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.05);
    box-sizing: border-box;
}
.morgan-tama-debuglabel {
    text-align: center;
    font-size: 0.65rem;
    color: var(--muted, #94a3b8);
    margin-bottom: 8px;
}
.morgan-tama-debugactions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.morgan-tama-debugbtn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    padding: 6px 2px;
    cursor: pointer;
    color: var(--muted, #94a3b8);
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.morgan-tama-debugbtn:hover { background: rgba(148, 163, 184, 0.18); color: #fff; }
.morgan-tama-debugbtn:active { transform: scale(0.94); }
.morgan-tama-debugbtn:disabled { opacity: 0.5; cursor: default; }
.morgan-tama-debugbtn-icon { font-size: 1rem; }
.morgan-tama-debugbtn-label { font-size: 0.56rem; text-align: center; line-height: 1.15; }

/* Em mobile, o "aparelho" fica centralizado na tela (não grudado embaixo) —
   ícones nas bordas, tela grande no meio, botões de ação bem tocáveis embaixo. */
@media (max-width: 480px) {
    .morgan-tama-overlay { align-items: center; padding: 16px; }
    .morgan-tama-device {
        max-width: 380px;
        width: 100%;
        border-radius: 28px;
        padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px));
        max-height: 88vh;
        overflow-y: auto;
    }
    .morgan-tama-icon { font-size: 1.2rem; }
    .morgan-tama-avatar.msg-avatar.ai { width: 76px; height: 76px; }
    .morgan-tama-avatar.msg-avatar.ai .morgan-eye-mini { width: 17px; height: 11px; }
    .morgan-tama-mood { font-size: 1.05rem; }
    .morgan-tama-actbtn { padding: 12px 4px; }
    .morgan-tama-actbtn-icon { font-size: 1.35rem; }
    .morgan-tama-actbtn-label { font-size: 0.66rem; }
    .morgan-tama-devbtn { padding: 13px; font-size: 0.9rem; }
    .morgan-tama-debugbtn { padding: 8px 2px; }
    .morgan-tama-debugbtn-icon { font-size: 1.1rem; }
    .morgan-tama-debugbtn-label { font-size: 0.6rem; }
}
