/* ==========================================================================
   CHATPACK - Design system v2
   Identidade: azul-marinho + dourado (logotipo), tipografia Inter, ícones Lucide.
   Estrutura:
     1. Fontes e tokens          6. Layout do aplicativo (sidebar/topbar)
     2. Base e utilitários       7. Atendimento (lista + chat + composer)
     3. Botões e formulários     8. Modais
     4. Componentes (chips...)   9. Painéis (admin, clientes, interno, gestor)
     5. Login                   10. Responsivo
   ========================================================================== */

/* 1. Fontes e tokens ------------------------------------------------------- */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* Marca */
    --navy-950: #060d1c;
    --navy-900: #0a1730;
    --navy-800: #102447;
    --navy-700: #183462;
    --navy-600: #24457f;
    --gold-300: #ecd391;
    --gold-400: #ddb965;
    --gold-500: #c9a24a;
    --gold-600: #a8832f;

    /* Semânticas (compatíveis com os nomes usados no restante do sistema) */
    --primary: var(--navy-700);
    --primary-2: var(--navy-600);
    --primary-soft: rgba(24, 52, 98, .09);
    --accent: var(--gold-500);
    --accent-strong: var(--gold-600);
    --accent-soft: rgba(201, 162, 74, .16);
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --surface-3: #eceff6;
    --text: #0f1b33;
    --text-2: #3b4a66;
    --muted: #6b7a94;
    --border: #e3e8f1;
    --border-strong: #cdd5e3;
    --danger: #d64550;
    --danger-soft: rgba(214, 69, 80, .10);
    --ok: #1e9e6a;
    --ok-soft: rgba(30, 158, 106, .12);
    --warn: #d9911a;
    --warn-soft: rgba(217, 145, 26, .14);
    --info: #2f6fed;

    --whatsapp: #1fa855;
    --instagram: linear-gradient(135deg, #f58529 0%, #dd2a7b 45%, #8134af 75%, #515bd4 100%);

    --bubble-in: #ffffff;
    --bubble-in-text: var(--text);
    --bubble-out: #14305f;
    --bubble-out-text: #f4f7fd;
    --chat-bg: #eef1f7;
    --chat-dots: rgba(16, 36, 71, .05);

    --sidebar-bg: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
    --sidebar-text: #b9c5de;
    --sidebar-active: rgba(201, 162, 74, .16);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --shadow-sm: 0 1px 2px rgba(15, 27, 51, .06);
    --shadow: 0 6px 24px rgba(15, 27, 51, .08);
    --shadow-lg: 0 24px 64px rgba(6, 13, 28, .25);
    --focus: 0 0 0 3px rgba(201, 162, 74, .35);

    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 68px;

    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}

body.dark-mode, .dark-mode {
    --primary: var(--gold-400);
    --primary-2: var(--gold-300);
    --primary-soft: rgba(221, 185, 101, .12);
    --bg: #070e1d;
    --surface: #0f1a30;
    --surface-2: #132039;
    --surface-3: #192848;
    --text: #e7ecf6;
    --text-2: #bcc7dc;
    --muted: #8294b3;
    --border: #1d2d4e;
    --border-strong: #2a3d66;
    --danger: #f06a74;
    --danger-soft: rgba(240, 106, 116, .14);
    --ok: #3ccb92;
    --ok-soft: rgba(60, 203, 146, .14);
    --info: #6b9bff;
    --bubble-in: #17254a;
    --bubble-in-text: #e7ecf6;
    --bubble-out: #1f3f7d;
    --bubble-out-text: #f4f7fd;
    --chat-bg: #0a1429;
    --chat-dots: rgba(255, 255, 255, .035);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 8px 28px rgba(0, 0, 0, .35);
}

/* 2. Base e utilitários ---------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; line-height: 1.25; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
small { font-size: 12px; }
code { padding: 1px 6px; border-radius: 6px; background: var(--surface-3); font-size: 12px; }
hr, .soft-separator { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny-text { font-size: 12px; }
.full { width: 100%; }
.span-2 { grid-column: span 2; }
.icon { flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* Superfície padrão (nome legado "glass-card" mantido para compatibilidade) */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* 3. Botões e formulários -------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 16px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font-weight: 600; font-size: 13.5px; line-height: 1; white-space: nowrap; cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn.primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
.dark-mode .btn.primary { background: var(--gold-500); border-color: var(--gold-500); color: #0a1730; }
.dark-mode .btn.primary:hover { background: var(--gold-400); border-color: var(--gold-400); }
.btn.accent { background: var(--gold-500); border-color: var(--gold-500); color: #0a1730; }
.btn.accent:hover { background: var(--gold-400); border-color: var(--gold-400); }
.btn.ghost { background: transparent; }
.btn.subtle { background: var(--surface-3); border-color: transparent; }
.btn.subtle:hover { background: var(--border); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.94); background: var(--danger); }
.btn.warning { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.tiny { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 9px; }
.btn.icon-btn { padding: 0; width: 40px; }
.btn.small.icon-btn { width: 34px; }
.btn.tiny.icon-btn { width: 30px; }
.danger-text { color: var(--danger) !important; }

label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
input, textarea, select {
    width: 100%; min-height: 42px; padding: 10px 13px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover, textarea:hover, select:hover { border-color: var(--muted); }
input:focus, textarea:focus, select:focus { border-color: var(--gold-500); box-shadow: var(--focus); }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7a94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input[type="checkbox"], input[type="radio"] { width: 16px; min-height: 16px; height: 16px; padding: 0; accent-color: var(--gold-600); }
input[type="color"] { padding: 4px; min-height: 42px; cursor: pointer; }
input[type="file"] { padding: 8px; }
input[type="search"] { -webkit-appearance: none; }

.form-grid { display: grid; gap: 14px; align-items: end; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.form-grid.compact-form { gap: 12px; margin: 14px 0; }
.form-grid > .btn { align-self: end; }
.field-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }
.switch-row { display: flex; align-items: center; gap: 10px; min-height: 42px; }

.alert { padding: 12px 14px; border-radius: var(--radius); margin: 12px 0; font-size: 13px; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: rgba(214, 69, 80, .3); }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(30, 158, 106, .3); }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(217, 145, 26, .3); }
.alert.info { background: var(--primary-soft); color: var(--text-2); border-color: var(--border); }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 10000; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
    background: var(--navy-900); color: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); border-left: 4px solid var(--ok);
    font-weight: 500; font-size: 13.5px; animation: toast-in .22s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--gold-500); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 4. Componentes ----------------------------------------------------------- */
.badge, .status-pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
    border-radius: 999px; font-size: 11.5px; font-weight: 600;
    background: var(--surface-3); color: var(--text-2); text-transform: capitalize;
}
.badge.queue { background: var(--warn-soft); color: var(--warn); }
.badge.open { background: var(--ok-soft); color: var(--ok); }
.badge.closed { background: var(--surface-3); color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }

.tag-chip {
    display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
    background: color-mix(in srgb, var(--tag-color, var(--gold-500)) 16%, transparent);
    color: color-mix(in srgb, var(--tag-color, var(--gold-600)) 78%, var(--text));
    border: 1px solid color-mix(in srgb, var(--tag-color, var(--gold-500)) 35%, transparent);
}
.tag-chip.tiny { font-size: 10.5px; padding: 1px 7px; }
.queue-chip, .protocol-chip {
    display: inline-flex; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
    background: var(--surface-3); color: var(--text-2);
}
.protocol-chip { font-variant-numeric: tabular-nums; color: var(--muted); }

.avatar {
    --hue: 215;
    flex: 0 0 auto; position: relative; display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 50%;
    background: hsl(var(--hue) 45% 38%); color: #fff;
    font-weight: 700; font-size: 15px; letter-spacing: .02em; user-select: none;
    background-size: cover; background-position: center;
}
.avatar.sm { width: 34px; height: 34px; font-size: 12.5px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.channel-badge {
    position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%;
    display: grid; place-items: center; color: #fff; border: 2px solid var(--surface);
}
.channel-badge .icon { width: 10px; height: 10px; }
.channel-badge.whatsapp { background: var(--whatsapp); }
.channel-badge.instagram { background: var(--instagram); }
.channel-tag {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; color: #fff;
}
.channel-tag .icon { width: 11px; height: 11px; }
.channel-tag.whatsapp { background: var(--whatsapp); }
.channel-tag.instagram { background: var(--instagram); }

.empty-state { display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .empty-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: var(--accent-soft); color: var(--gold-600); margin-bottom: 6px; }
.empty-state h2 { color: var(--text); font-size: 18px; }
.empty-state p { max-width: 320px; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--gold-500); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 5. Login ----------------------------------------------------------------- */
.login-body { min-height: 100vh; background: var(--navy-950); }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr); }
.login-hero {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
    padding: 56px clamp(32px, 5vw, 72px); color: #e8edf8;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(201, 162, 74, .22), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(36, 69, 127, .55), transparent 60%),
        linear-gradient(160deg, var(--navy-900), var(--navy-950));
}
.login-hero::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px); background-size: 26px 26px;
    mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.login-hero > * { position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand img { width: 56px; height: 56px; object-fit: contain; border-radius: 14px; background: #fff; padding: 4px; }
.login-brand strong { display: block; font-size: 20px; letter-spacing: .14em; }
.login-brand span { font-size: 12.5px; color: var(--gold-300); letter-spacing: .06em; }
.login-hero h1 { font-size: clamp(30px, 3.4vw, 44px); font-weight: 750; line-height: 1.12; letter-spacing: -.02em; max-width: 520px; margin-bottom: 16px; }
.login-hero h1 em { font-style: normal; color: var(--gold-400); }
.login-hero p.lead { color: #b3c0da; max-width: 480px; font-size: 16px; line-height: 1.6; }
.login-features { display: grid; gap: 14px; margin-top: 40px; max-width: 480px; }
.login-feature { display: flex; gap: 14px; align-items: flex-start; }
.login-feature .fi { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(201, 162, 74, .14); color: var(--gold-400); border: 1px solid rgba(201, 162, 74, .25); }
.login-feature strong { display: block; font-size: 14.5px; color: #fff; }
.login-feature span { font-size: 13px; color: #9fb0cf; }
.login-hero-foot { font-size: 12.5px; color: #7f91b3; }
.login-channels { display: flex; gap: 10px; margin-top: 28px; }
.login-channels .channel-tag { padding: 6px 12px; font-size: 12px; }

.login-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.login-card-modern { width: min(420px, 100%); }
.login-card-modern .login-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 22px; }
.login-card-modern h2 { font-size: 26px; font-weight: 750; margin-bottom: 6px; }
.login-card-modern > p { color: var(--muted); margin-bottom: 26px; }
.login-form { display: grid; gap: 16px; }
.input-shell { position: relative; }
.input-shell .input-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.input-shell input { padding-left: 42px; min-height: 46px; }
.input-shell .toggle-visibility { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; }
.input-shell .toggle-visibility:hover { background: var(--surface-3); color: var(--text); }
.login-options { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.remember-me { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; color: var(--text-2); cursor: pointer; }
.link-button { border: 0; background: none; padding: 0; color: var(--gold-600); font-weight: 600; cursor: pointer; font-size: 13px; }
.link-button:hover { text-decoration: underline; }
.btn-login {
    min-height: 48px; border: 0; border-radius: var(--radius); cursor: pointer;
    background: linear-gradient(135deg, var(--navy-700), var(--navy-900)); color: #fff;
    font-weight: 650; font-size: 15px; box-shadow: 0 10px 24px rgba(16, 36, 71, .28);
    transition: transform .08s, box-shadow .15s, filter .15s;
}
.btn-login:hover { filter: brightness(1.08); box-shadow: 0 14px 30px rgba(16, 36, 71, .34); }
.btn-login:active { transform: translateY(1px); }
.btn-subtle { min-height: 42px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font-weight: 600; cursor: pointer; }
.reset-box { display: grid; gap: 12px; margin-top: 22px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.login-note { margin-top: 32px; text-align: center; font-size: 12px; color: var(--muted); }
.login-note a { color: var(--gold-600); font-weight: 600; }

/* 6. Layout do aplicativo -------------------------------------------------- */
.app-body { min-height: 100vh; }
#app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; transition: grid-template-columns .22s ease; }
#app.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar {
    position: relative; z-index: 30; display: flex; flex-direction: column; min-height: 0;
    background: var(--sidebar-bg); color: var(--sidebar-text);
    border-right: 1px solid rgba(255, 255, 255, .05);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 16px 14px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sidebar-brand img { width: 40px; height: 40px; border-radius: 12px; background: #fff; padding: 3px; object-fit: contain; flex: 0 0 auto; }
.brand-text { min-width: 0; line-height: 1.2; }
.brand-text strong { display: block; color: #fff; font-size: 15.5px; letter-spacing: .14em; }
.brand-text small { color: var(--gold-400); font-size: 11.5px; letter-spacing: .04em; }
.sidebar-toggle {
    flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .04); color: #d7e0f2; border-radius: 10px;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, .1); }
.sidebar-section-label { padding: 14px 22px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #5f7197; }

.tabs { display: grid; gap: 4px; padding: 6px 12px 12px; overflow-y: auto; flex: 1 1 auto; align-content: start; min-height: 0; }
.tabs::-webkit-scrollbar { width: 6px; }
.tabs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border: 0; }
.tab {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: 42px; padding: 0 12px; border: 0; border-radius: 11px;
    background: transparent; color: var(--sidebar-text); font-weight: 550; font-size: 13.5px; text-align: left; cursor: pointer;
    transition: background .15s, color .15s;
}
.tab:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.tab.active { background: var(--sidebar-active); color: #fff; }
.tab.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold-500); }
.tab-icon { display: grid; place-items: center; width: 22px; flex: 0 0 auto; }
.tab.active .tab-icon { color: var(--gold-400); }
.tab-label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-sidebar-tab { display: none; }
.side-badge {
    min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center;
    border-radius: 999px; background: var(--gold-500); color: #0a1730; font-size: 11px; font-weight: 800;
}
.sidebar-scroll-btn { display: none !important; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar-foot .tab { min-height: 40px; }

#app.sidebar-collapsed .brand-text,
#app.sidebar-collapsed .tab-label,
#app.sidebar-collapsed .sidebar-section-label { display: none; }
#app.sidebar-collapsed .sidebar-top { flex-direction: column; padding: 16px 0 10px; }
#app.sidebar-collapsed .sidebar-brand { justify-content: center; }
#app.sidebar-collapsed .tab { justify-content: center; padding: 0; }
#app.sidebar-collapsed .tab.active::before { left: -12px; }
#app.sidebar-collapsed .side-badge { position: absolute; top: 3px; right: 8px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
#app.sidebar-collapsed .tabs { padding-left: 10px; padding-right: 10px; }

.main-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; overflow: hidden; }
.topbar {
    flex: 0 0 var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title h1 { font-size: 19px; font-weight: 700; }
.topbar-title p { color: var(--muted); font-size: 13px; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.user-pill { display: flex; align-items: center; gap: 10px; padding: 5px 14px 5px 5px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #0a1730; background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); }
.user-info { display: grid; line-height: 1.2; }
.user-info span { font-weight: 600; font-size: 13px; }
.user-info strong { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.notification-toggle.active { color: var(--ok); border-color: var(--ok); }
.topbar .btn.icon-btn { width: 40px; }
.mobile-menu-btn { display: none; margin-right: 4px; }

/* Conteúdo das páginas (as seções são irmãs diretas de .main-panel) */
.main-panel > .page-panel { flex: 1 1 auto; margin: 0; border-radius: 0; border: 0; box-shadow: none; background: transparent; padding: 28px; overflow-y: auto; min-height: 0; }
.page-panel > h2:first-child, .panel-head-row h2 { font-size: 22px; font-weight: 750; }
.page-panel > .muted:first-of-type, .panel-head-row .muted { margin: 4px 0 20px; max-width: 760px; }
.panel-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.panel-card, .details-box, .start-form, .selected-client-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.details-box { margin: 16px 0; }
.details-box summary { cursor: pointer; font-weight: 650; }
.details-box[open] summary { margin-bottom: 14px; }
.start-form { display: grid; gap: 12px; margin-top: 16px; }
.selected-client-card { display: grid; gap: 4px; align-content: center; min-height: 84px; }
.selected-client-card small { color: var(--muted); }
.client-warning { color: var(--warn); font-weight: 600; font-size: 12.5px; margin-top: 4px; }
.list-actions { display: flex; gap: 8px; align-items: center; }
.list-actions.wide { margin: 14px 0 18px; max-width: 640px; }
.mini-results { display: grid; gap: 6px; margin-top: 8px; }
.mini-result { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.mini-result:hover { border-color: var(--gold-500); background: var(--accent-soft); }
.lock-line, .lock-line small { color: var(--warn); font-weight: 600; font-size: 12px; }

/* 7. Atendimento ----------------------------------------------------------- */
.content-grid { flex: 1 1 auto; display: grid; grid-template-columns: 380px minmax(0, 1fr); min-height: 0; background: var(--surface); }
.list-panel { display: flex; flex-direction: column; min-height: 0; border: 0; border-right: 1px solid var(--border); border-radius: 0; box-shadow: none; background: var(--surface); }
.list-panel .list-actions { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-field { position: relative; flex: 1 1 auto; }
.search-field .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 38px; background: var(--surface-2); border-color: transparent; }
.search-field input:focus { background: var(--surface); }
.conversation-list { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.conversation-list > .muted, .conversation-list > .alert { margin: 16px; }

.conversation-item {
    position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px;
    padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; background: var(--surface);
    transition: background .12s;
}
.conversation-item:hover { background: var(--surface-2); }
.conversation-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--gold-500); }
.conversation-item.pinned { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.conversation-item .ci-body { min-width: 0; display: grid; gap: 3px; }
.conversation-item .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conversation-item .row strong { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.conversation-item .ci-time { flex: 0 0 auto; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.conversation-item .ci-subject { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-item .last-message { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-item .last-message .lm-text { overflow: hidden; text-overflow: ellipsis; }
.conversation-item .last-message .icon { width: 14px; height: 14px; flex: 0 0 auto; }
.unread-dot { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--gold-500); color: #0a1730; font-size: 11px; font-weight: 800; }
.conversation-tags-inline { display: flex; flex-wrap: wrap; gap: 5px; }
.conversation-tags-inline:empty { display: none; }
.conversation-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.conversation-foot small { margin-right: auto; }
.sla-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: color-mix(in srgb, var(--sla-color, var(--ok)) 14%, transparent); color: color-mix(in srgb, var(--sla-color, var(--ok)) 85%, var(--text)); }
.sla-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sla-color, var(--ok)); }
.pin-indicator { color: var(--gold-600); display: inline-flex; }
.pin-indicator .icon { width: 13px; height: 13px; }
.pin-list-btn { border: 0; background: transparent; color: var(--muted); padding: 4px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.pin-list-btn:hover, .pin-list-btn.active { color: var(--gold-600); background: var(--accent-soft); }

.chat-panel { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--chat-bg); }
.chat-box { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
#chatEmpty { flex: 1 1 auto; background: var(--chat-bg); }

.chat-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.chat-head-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-back-btn { display: none; }
.chat-head-text { min-width: 0; }
.chat-client-name-row { display: flex; align-items: center; gap: 6px; }
.chat-client-name-row h2 { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-name-edit-btn { border: 0; background: transparent; color: var(--muted); padding: 4px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.chat-client-name-row:hover .chat-name-edit-btn, .chat-name-edit-btn:focus { opacity: 1; }
.chat-name-edit-btn:hover { background: var(--surface-3); color: var(--text); }
.chat-client-name-edit { display: flex; gap: 6px; align-items: center; }
.chat-client-name-edit input { min-height: 34px; padding: 4px 10px; }
#chatMeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.chat-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.chat-tags:empty { display: none; }
.chat-head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.transfer-wrap { display: flex; gap: 6px; align-items: center; }
.transfer-wrap select { min-height: 34px; padding: 4px 30px 4px 10px; font-size: 13px; width: 190px; }
.chat-search-toggle.active { background: var(--accent-soft); border-color: var(--gold-500); }

.actions-dropdown { position: relative; }
.actions-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 230px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    display: none;
}
.actions-dropdown:hover .actions-menu, .actions-dropdown:focus-within .actions-menu, .actions-dropdown.open .actions-menu { display: grid; gap: 2px; }
.actions-dropdown::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 8px; }
.action-menu-btn { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 13.5px; font-weight: 500; cursor: pointer; width: 100%; }
.action-menu-btn:hover { background: var(--surface-3); }

.chat-search-bar { padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-search-compact { position: relative; max-width: 420px; }
.chat-search-compact .chat-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; }
.chat-search-compact input { padding-left: 38px; padding-right: 36px; min-height: 36px; }
.chat-search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.chat-search-clear:hover { background: var(--surface-3); }

.messages {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 22px clamp(16px, 4vw, 56px); display: flex; flex-direction: column; gap: 6px;
    background-color: var(--chat-bg);
    background-image: radial-gradient(var(--chat-dots) 1.2px, transparent 1.2px); background-size: 22px 22px;
}
.messages > .muted { margin: auto; }
.day-divider { align-self: center; margin: 10px 0 4px; padding: 3px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 11.5px; font-weight: 600; box-shadow: var(--shadow-sm); }

.message {
    position: relative; max-width: min(620px, 74%); padding: 8px 12px 6px; border-radius: 14px;
    display: flex; flex-direction: column; gap: 4px; word-break: break-word; overflow-wrap: anywhere; white-space: normal;
    box-shadow: 0 1px 1px rgba(15, 27, 51, .08);
}
.message.in { align-self: flex-start; background: var(--bubble-in); color: var(--bubble-in-text); border-top-left-radius: 4px; }
.message.out { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-text); border-top-right-radius: 4px; }
.message.sticker-bubble { background: transparent; box-shadow: none; padding: 0; }
.message.redacted { opacity: .7; font-style: italic; }
.message.system-message { align-self: center; max-width: 80%; background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; font-size: 12px; box-shadow: none; text-align: center; }
.message.system-message .message-footer { justify-content: center; }
.message.internal-note-message { align-self: center; max-width: 80%; background: #fff7e0; color: #5a4310; border: 1px dashed var(--gold-500); box-shadow: none; }
.dark-mode .message.internal-note-message { background: rgba(201, 162, 74, .12); color: var(--gold-300); }
.message-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; white-space: normal; }
.message-footer small { display: inline-flex; align-items: center; gap: 4px; opacity: .72; font-size: 11px; }
.message.out .message-footer small { color: #c7d3ee; opacity: .85; }
.message-reply-btn { opacity: 0; border: 0; background: transparent; color: inherit; padding: 2px 6px; border-radius: 6px; cursor: pointer; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; transition: opacity .12s; }
.message:hover .message-reply-btn { opacity: .75; }
.message-reply-btn:hover { opacity: 1 !important; background: rgba(127, 127, 127, .18); }
.message-caption, .message-text { white-space: pre-wrap; }

.quoted-message { display: grid; gap: 1px; padding: 6px 10px; border-left: 3px solid var(--gold-500); border-radius: 6px; background: rgba(127, 127, 127, .14); font-size: 12.5px; white-space: normal; }
.quoted-message strong { font-size: 12px; color: var(--gold-600); }
.message.out .quoted-message strong { color: var(--gold-300); }
.quoted-message span { opacity: .85; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.chat-media { display: block; max-width: min(320px, 100%); max-height: 340px; border-radius: 10px; object-fit: cover; cursor: zoom-in; }
.chat-media.sticker-media { max-width: 150px; background: transparent; cursor: default; }
.chat-video { display: block; width: min(340px, 100%); max-height: 360px; border-radius: 10px; background: #000; }
.chat-audio { width: min(300px, 100%); height: 40px; }

.file-card {
    display: flex; align-items: center; gap: 12px; min-width: min(280px, 100%); max-width: 360px; padding: 10px 12px;
    border-radius: 12px; background: rgba(127, 127, 127, .13); color: inherit; white-space: normal; transition: background .15s;
}
.file-card:hover { background: rgba(127, 127, 127, .22); }
.file-card .file-ext {
    flex: 0 0 auto; width: 44px; height: 52px; display: grid; place-items: center; border-radius: 8px;
    background: var(--file-color, #6b7a94); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
    box-shadow: inset 0 -10px 16px rgba(0, 0, 0, .12);
}
.file-card .file-info { min-width: 0; display: grid; gap: 2px; flex: 1 1 auto; }
.file-card .file-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.file-card .file-meta { font-size: 11.5px; opacity: .7; }
.file-card .file-dl { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: rgba(127, 127, 127, .2); }
.file-card.ext-pdf { --file-color: #d64545; }
.file-card.ext-doc, .file-card.ext-docx, .file-card.ext-rtf, .file-card.ext-odt { --file-color: #2f6fed; }
.file-card.ext-xls, .file-card.ext-xlsx, .file-card.ext-csv, .file-card.ext-ods { --file-color: #1e9e6a; }
.file-card.ext-ppt, .file-card.ext-pptx, .file-card.ext-odp { --file-color: #e0792a; }
.file-card.ext-txt, .file-card.ext-md, .file-card.ext-log { --file-color: #6b7a94; }
.file-card.ext-zip, .file-card.ext-rar, .file-card.ext-7z { --file-color: #b8892a; }
.file-card.ext-json, .file-card.ext-xml { --file-color: #7a5cd6; }
.file-card.ext-mp4, .file-card.ext-mov, .file-card.ext-avi, .file-card.ext-mkv, .file-card.ext-webm { --file-color: #7a3fd6; }

.delivery-ticks { display: inline-flex; align-items: center; }
.delivery-ticks .icon { width: 15px; height: 15px; }
.delivery-ticks.delivered { color: #7fd1ff; }
.delivery-ticks.sent { color: #c7d3ee; }
.delivery-ticks.sending, .delivery-ticks.pending { color: #c7d3ee; }
.delivery-ticks.failed { color: #ff8a93; }
.message.in .delivery-ticks { display: none; }
.retry-btn { border: 0; background: rgba(255, 138, 147, .18); color: #ffb3b9; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.retry-btn:hover { background: rgba(255, 138, 147, .3); }
.message.pending-out { opacity: .78; }
.message.pending-out.pending-failed { opacity: 1; outline: 1px solid rgba(255, 138, 147, .5); }
.message-error { font-size: 11.5px; color: #ffb3b9; white-space: normal; display: flex; gap: 6px; align-items: flex-start; }
.message-error .icon { width: 13px; height: 13px; margin-top: 2px; }

.reply-preview {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 20px; padding: 8px 12px;
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold-500); border-radius: 10px 10px 0 0; font-size: 12.5px;
}
.reply-preview div { min-width: 0; display: grid; }
.reply-preview span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-preview button { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.reply-preview button:hover { background: var(--surface-3); }

/* Anexo pendente (pré-visualização + progresso) */
.attachment-preview { margin: 0 20px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.attachment-preview .ap-thumb { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 10px; background: var(--file-color, var(--surface-3)) center/cover no-repeat; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; text-transform: uppercase; overflow: hidden; }
.attachment-preview .ap-info { min-width: 0; flex: 1 1 auto; display: grid; gap: 3px; }
.attachment-preview .ap-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview .ap-meta { font-size: 12px; color: var(--muted); }
.attachment-preview .ap-meta.error { color: var(--danger); }
.attachment-preview .ap-bar { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.attachment-preview .ap-bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-500), var(--gold-400)); transition: width .15s; }
.attachment-preview .ap-remove { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.attachment-preview .ap-remove:hover { background: var(--surface-3); color: var(--danger); }
.attachment-preview.uploading .ap-remove { display: none; }

/* Composer */
.send-form { display: flex; align-items: flex-end; gap: 10px; padding: 12px 20px 16px; background: var(--surface); border-top: 1px solid var(--border); }
.composer-tools { display: flex; gap: 2px; align-items: center; padding-bottom: 3px; }
.tool-btn, .emoji-toggle, .file-picker, .audio-record-btn {
    position: relative; width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto;
    border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; margin: 0;
}
.tool-btn:hover, .emoji-toggle:hover, .file-picker:hover, .audio-record-btn:hover { background: var(--surface-3); color: var(--text); }
.file-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; min-height: 0; padding: 0; }
.audio-record-btn.recording { background: var(--danger-soft); color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(214, 69, 80, .12); } }
.send-input-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
.send-input-wrap textarea { min-height: 44px; max-height: 160px; height: 44px; padding: 11px 14px; border-radius: 14px; resize: none; background: var(--surface-2); border-color: transparent; line-height: 1.45; overflow-y: auto; }
.send-input-wrap textarea:focus { background: var(--surface); border-color: var(--gold-500); }
.send-btn {
    flex: 0 0 auto; height: 44px; padding: 0 20px; display: inline-flex; align-items: center; gap: 8px;
    border: 0; border-radius: 14px; cursor: pointer; font-weight: 650; font-size: 14px;
    background: var(--gold-500); color: #0a1730; transition: background .15s, transform .05s;
}
.send-btn:hover { background: var(--gold-400); }
.send-btn:active { transform: translateY(1px); }
.send-btn:disabled { opacity: .55; cursor: wait; }
.emoji-wrap { position: relative; }
.emoji-picker {
    position: absolute; left: 0; bottom: 48px; z-index: 50; width: 280px; padding: 10px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.emoji-option { border: 0; background: transparent; font-size: 22px; height: 40px; border-radius: 8px; cursor: pointer; }
.emoji-option:hover { background: var(--surface-3); }
.quick-reply-box { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 45; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; }
.quick-reply-option { display: grid; gap: 2px; width: 100%; padding: 9px 12px; border: 0; background: transparent; border-radius: 8px; text-align: left; cursor: pointer; }
.quick-reply-option:hover, .quick-reply-option.active { background: var(--accent-soft); }
.quick-reply-option strong { font-size: 13px; }
.quick-reply-option span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drop-overlay {
    position: absolute; inset: 0; z-index: 60; display: none; place-items: center; align-content: center; gap: 10px; text-align: center;
    background: rgba(10, 23, 48, .82); color: #fff; border: 3px dashed var(--gold-500); border-radius: 0; font-weight: 600; font-size: 17px;
}
.drop-overlay.show { display: grid; }
.drop-overlay .icon { width: 44px; height: 44px; color: var(--gold-400); }

/* 8. Modais ---------------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: rgba(6, 13, 28, .62); backdrop-filter: blur(4px); animation: fade-in .15s ease; }
@keyframes fade-in { from { opacity: 0; } }
.modal-card { width: min(560px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; padding: 0 24px 24px; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: pop-in .18s ease; background: var(--surface); }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-card.large { width: min(920px, 100%); }
.modal-card > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -24px 18px; padding: 18px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.modal-card > header h2 { font-size: 18px; }
.modal-scroll-list { max-height: 52vh; overflow-y: auto; }
.modal-scroll-list.short { max-height: 32vh; }
.modal-actions-row { display: flex; gap: 10px; }

/* 9. Painéis --------------------------------------------------------------- */
.data-list { display: grid; gap: 8px; }
.data-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.data-row > div:first-child { min-width: 0; display: grid; gap: 2px; }
.data-row strong { font-weight: 650; }
.data-row small { color: var(--muted); }
.data-row-button { cursor: pointer; text-align: left; width: 100%; font: inherit; }
.data-row-button:hover { border-color: var(--gold-500); background: var(--accent-soft); }
.row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.notes-list { display: grid; gap: 10px; margin-top: 14px; }
.note-item { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.note-item small { color: var(--muted); display: block; margin-bottom: 4px; }
.note-form { display: grid; gap: 10px; }

.admin-action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.admin-action-card {
    display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 2px; align-items: center; text-align: left;
    padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.admin-action-card:hover { border-color: var(--gold-500); box-shadow: var(--shadow); transform: translateY(-2px); }
.admin-action-card .aa-icon { grid-row: span 2; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: var(--primary-soft); color: var(--primary); }
.dark-mode .admin-action-card .aa-icon { background: var(--accent-soft); color: var(--gold-400); }
.admin-action-card.instagram .aa-icon { background: var(--instagram); color: #fff; }
.admin-action-card strong { font-size: 14.5px; }
.admin-action-card small { color: var(--muted); font-size: 12.5px; }
.admin-section-title { margin: 28px 0 12px; font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.admin-section-title:first-of-type { margin-top: 0; }

.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin: 14px 0; }
.perm-item { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-weight: 500; font-size: 13px; cursor: pointer; background: var(--surface); }
.perm-item:hover { border-color: var(--gold-500); }
.role-form { display: grid; gap: 14px; }
.user-edit-row { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.user-edit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }

.clients-list .client-row, .history-results .data-row { cursor: default; }
.history-results { display: grid; gap: 10px; }
.history-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; }
.history-toggle:hover { border-color: var(--gold-500); }
.history-chat { margin-top: 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--chat-bg); max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }

/* Chat interno */
.internal-panel { display: flex !important; flex-direction: column; }
.internal-panel.hidden { display: none !important; }
.internal-layout { flex: 1 1 auto; display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 0; margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.internal-sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.internal-start-box { padding: 16px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.internal-start-row { display: flex; gap: 8px; }
.internal-thread-header { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 16px 6px; }
.internal-thread-list { flex: 1 1 auto; overflow-y: auto; }
.internal-thread { display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); text-align: left; cursor: pointer; }
.internal-thread:hover { background: var(--surface-2); }
.internal-thread.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--gold-500); }
.internal-avatar { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--navy-700); }
.internal-thread-main { min-width: 0; flex: 1 1 auto; display: grid; }
.internal-thread-main strong, .internal-thread-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.internal-thread-meta { display: grid; justify-items: end; gap: 4px; font-size: 11.5px; color: var(--muted); }
.internal-unread { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--gold-500); color: #0a1730; font-size: 11px; font-weight: 800; }
.internal-chat-box { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.internal-chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.internal-chat-header > div { display: grid; }
.internal-messages { flex: 1 1 auto; }
.internal-empty { margin: auto; color: var(--muted); }

/* Painel do gestor */
.manager-dashboard { display: grid; gap: 20px; align-content: start; }
.dashboard-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--navy-800), var(--navy-900)); color: #fff; }
.dashboard-hero-title { display: flex; align-items: center; gap: 14px; }
.hero-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: rgba(201, 162, 74, .18); color: var(--gold-400); }
.dashboard-hero h2 { color: #fff; }
.dashboard-hero p { color: #a9b8d6; margin: 2px 0 0 !important; }
.dashboard-hero .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); color: #fff; }
.dashboard-hero .btn:hover { background: rgba(255, 255, 255, .16); }
.kpi-group { display: grid; gap: 10px; }
.kpi-group-title { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi-card { --tone-color: var(--primary); display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.kpi-card.tone-neutral { --tone-color: var(--navy-600); }
.kpi-card.tone-danger { --tone-color: var(--danger); }
.kpi-card.tone-info { --tone-color: var(--info); }
.kpi-card.tone-ok { --tone-color: var(--ok); }
.kpi-card.tone-warn { --tone-color: var(--warn); }
.kpi-icon { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--tone-color) 14%, transparent); color: var(--tone-color); font-size: 18px; }
.kpi-body { min-width: 0; display: grid; gap: 2px; }
.kpi-label { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 26px; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; }
.stats-grid { display: grid; gap: 18px; }
.manager-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.manager-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.manager-card.span-2 { grid-column: span 2; }
.manager-card > h3 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 15px; }
.manager-card .card-icon { flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.dark-mode .manager-card .card-icon { background: var(--accent-soft); color: var(--gold-400); }
.advanced-stats h3 { margin: 20px 0 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.advanced-stats h3:first-child { margin-top: 0; }
.productivity-table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.productivity-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.productivity-table th { text-align: left; padding: 10px 14px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.productivity-table td { padding: 10px 14px; border-top: 1px solid var(--border); }
.productivity-table td small { display: block; color: var(--muted); }
.followup-row, .audit-row, .file-row, .client-row, .queue-row, .role-row, .quick-reply-row, .emoji-row, .attendance-item { }

/* Instagram (config no admin) */
.integration-head { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius-lg); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 18px; }
.integration-head .ih-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--instagram); color: #fff; display: grid; place-items: center; }
.integration-head .ih-text { flex: 1 1 auto; min-width: 0; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); }
.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-chip.ok { background: var(--ok-soft); color: var(--ok); }
.status-chip.warn { background: var(--warn-soft); color: var(--warn); }
.status-chip.off { background: var(--surface-3); color: var(--muted); }
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); }
.step-list { counter-reset: step; display: grid; gap: 10px; margin: 8px 0 18px; padding: 0; list-style: none; }
.step-list li { counter-increment: step; position: relative; padding: 0 0 0 38px; font-size: 13px; color: var(--text-2); }
.step-list li::before { content: counter(step); position: absolute; left: 0; top: -1px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--gold-600); font-weight: 700; font-size: 12px; }
.auto-message-block { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); display: grid; gap: 10px; }
.auto-message-block h3 { font-size: 14px; }

/* 10. Responsivo ----------------------------------------------------------- */
@media (max-width: 1280px) {
    .content-grid { grid-template-columns: 340px minmax(0, 1fr); }
    .form-grid.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .user-info { display: none; }
    .user-pill { padding: 5px; }
}
@media (max-width: 1000px) {
    :root { --sidebar-w: 240px; }
    .manager-grid { grid-template-columns: 1fr; }
    .manager-card.span-2 { grid-column: auto; }
    .form-grid.three, .form-grid.four, .form-grid.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .user-edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-page { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .internal-layout { grid-template-columns: 260px minmax(0, 1fr); }
}
@media (max-width: 820px) {
    #app, #app.sidebar-collapsed, #app.sidebar-expanded { grid-template-columns: minmax(0, 1fr); }
    /* Menu vira gaveta lateral, aberta pelo botão do topo */
    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .22s ease; }
    #app.sidebar-expanded .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    #app.sidebar-collapsed .brand-text, #app.sidebar-collapsed .tab-label, #app.sidebar-collapsed .sidebar-section-label { display: initial; }
    #app.sidebar-collapsed .sidebar-top { flex-direction: row; padding: 18px 16px 14px; }
    #app.sidebar-collapsed .tab { justify-content: flex-start; padding: 0 12px; }
    #app.sidebar-collapsed .side-badge { position: static; min-width: 20px; height: 20px; font-size: 11px; padding: 0 6px; }
    #app.sidebar-expanded .main-panel::after { content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(6, 13, 28, .5); }
    .mobile-menu-btn { display: inline-flex !important; }
    .topbar { padding: 0 16px; }
    .topbar-title p, .notification-toggle span { display: none; }
    .main-panel > .page-panel { padding: 18px 16px; }
    /* Lista e conversa viram telas alternadas */
    .content-grid { grid-template-columns: 1fr; }
    .content-grid .chat-panel { display: none; }
    .content-grid.chat-open .list-panel { display: none; }
    .content-grid.chat-open .chat-panel { display: flex; }
    .chat-back-btn { display: inline-grid; }
    .chat-head { padding: 10px 12px; }
    .chat-head-actions .transfer-wrap { display: none; }
    .message { max-width: 88%; }
    .messages { padding: 14px 12px; }
    .send-form { padding: 10px 12px 12px; flex-wrap: wrap; }
    .send-btn span { display: none; }
    .send-btn { padding: 0 14px; }
    .attachment-preview, .reply-preview { margin: 0 12px; }
    .form-grid.two, .form-grid.three, .form-grid.four, .form-grid.five { grid-template-columns: 1fr; }
    .span-2, .manager-card.span-2 { grid-column: auto; }
    .internal-layout { grid-template-columns: 1fr; }
    .internal-sidebar { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--border); }
    .modal { padding: 12px; }
    .modal-card { padding: 0 16px 16px; }
    .modal-card > header { margin: 0 -16px 14px; padding: 14px 16px; }
}
@media (max-width: 520px) {
    .user-pill { display: none; }
    .dashboard-hero { flex-direction: column; align-items: flex-start; }
}
@media print { .sidebar, .topbar, .composer-tools, .send-form { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Páginas avulsas: redefinição de senha e configuração do webhook Menuia ------- */
.reset-body { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(440px, 100%); }
.login-card { padding: 36px 32px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); display: grid; gap: 14px; }
.login-card .login-logo { width: 84px; height: 84px; margin: 0 auto 4px; object-fit: contain; }
.login-card h1 { font-size: 22px; }
.login-card form { text-align: left; display: grid; gap: 12px; }
.login-card .btn.full { width: 100%; }
.setup-wrap { max-width: 1000px; margin: 0 auto; padding: 32px 20px; }
.setup-card { padding: 28px; display: grid; gap: 16px; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.device { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 10px; background: var(--surface-2); }
.setup-actions { display: grid; gap: 8px; }
.codebox { padding: 14px; border-radius: var(--radius); background: var(--navy-950); color: #cfe0ff; font-size: 12.5px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.user-pill { cursor: pointer; font: inherit; color: inherit; text-align: left; }

/* Largura confortável para formulários em telas grandes */
#callPanel .start-form, #callPanel .details-box, #callPanel > .form-grid { max-width: 980px; }
#profilePanel .form-grid { max-width: 760px; }

/* ===== v2.1: campanhas, vendas, agenda, pedidos, atendimento automático ===== */
.panel-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check-row input { width: auto; margin: 0; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 8px; }
.product-card { display: flex; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.product-card:hover { border-color: var(--gold-400, #caa052); box-shadow: 0 6px 20px rgba(10, 23, 48, .12); transform: translateY(-1px); }
.product-card.inactive { opacity: .6; }
.product-thumb { flex: 0 0 76px; height: 76px; border-radius: 10px; background: var(--border) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.product-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.product-info strong { overflow-wrap: anywhere; }
.product-price { color: var(--navy-700, #0f2347); font-weight: 700; }
body.dark-mode .product-price { color: var(--gold-300, #e0c180); }
.product-photos { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.photo-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.photo-item { position: relative; width: 84px; height: 84px; border-radius: 10px; background: var(--border) center/cover no-repeat; border: 1px solid var(--border); }
.photo-del { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #c0392b; color: #fff; display: grid; place-items: center; cursor: pointer; }
.photo-add { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.agenda-toolbar { max-width: 640px; }
.agenda-body { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.agenda-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.agenda-card h3 { margin: 0 0 10px; font-size: 15px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head span { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-cell { min-height: 46px; border-radius: 8px; padding: 4px 6px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--border); font-size: 12px; }
.cal-cell.empty { border: 0; }
.cal-cell small { font-size: 10px; opacity: .8; }
.cal-cell.free, .cal-legend .free { background: rgba(46, 160, 102, .12); }
.cal-cell.partial, .cal-legend .partial { background: rgba(202, 160, 82, .22); }
.cal-cell.full, .cal-legend .full { background: rgba(214, 69, 69, .22); }
.cal-cell.blocked, .cal-legend .blocked { background: repeating-linear-gradient(45deg, rgba(120,120,120,.2), rgba(120,120,120,.2) 6px, rgba(120,120,120,.08) 6px, rgba(120,120,120,.08) 12px); }
.cal-legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 11px; }
.cal-legend span { padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.rules-grid label { font-size: 12px; font-weight: 600; }
.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.simple-table th, .simple-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.orders-table { overflow-x: auto; margin-top: 12px; }
.order-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.order-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.campaign-row { align-items: center; }
.row-actions { display: flex; gap: 6px; }
.bot-options { display: flex; flex-direction: column; gap: 8px; }
.bot-opt-row { display: grid; grid-template-columns: 34px 170px 1fr 1fr; gap: 8px; align-items: center; }
.bot-opt-row .hidden { display: none; }
.bot-digit { width: 30px; height: 30px; border-radius: 50%; background: var(--navy-700, #0f2347); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.bot-names { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; margin: 8px 0; }
.bot-name-row { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
@media (max-width: 720px) {
    .bot-opt-row { grid-template-columns: 34px 1fr; }
    .bot-opt-row [data-f="user"], .bot-opt-row [data-f="label"] { grid-column: 1 / -1; }
}

/* ===== v2.2: contatos compartilhados e grupos ===== */
.channel-tag.group { background: var(--navy-700, #0f2347); }
.group-sender { --hue: 215; font-size: 12px; font-weight: 700; margin-bottom: 3px; color: hsl(var(--hue) 55% 36%); display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.group-sender small { font-weight: 500; color: var(--muted); font-size: 11px; }
.dark-mode .group-sender { color: hsl(var(--hue) 70% 72%); }
.contact-cards { display: flex; flex-direction: column; gap: 8px; min-width: 240px; }
.contact-cards-title { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; opacity: .75; }
.contact-card { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(127, 127, 127, .12); border: 1px solid rgba(127, 127, 127, .22); }
.contact-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.contact-card-body strong { font-size: 13.5px; overflow-wrap: anywhere; }
.contact-card-body small { font-size: 12px; opacity: .8; }
.contact-card-actions { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.contact-card-actions .btn { text-decoration: none; }

/* ===== Fase 4: sino de alertas, agenda pessoal, relatórios, encerrar com venda ===== */
.alerts-wrap { position: relative; }
.alerts-btn { position: relative; }
.alerts-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #c9382f; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.alerts-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, 92vw); max-height: 70vh; overflow: auto; z-index: 60; background: var(--panel, #fff); color: inherit; border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 14px; box-shadow: 0 18px 40px rgba(0,0,0,.28); }
.alerts-head { display: flex; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border, rgba(127,127,127,.2)); position: sticky; top: 0; background: inherit; }
.alert-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border, rgba(127,127,127,.15)); cursor: pointer; align-items: flex-start; }
.alert-item:hover { background: rgba(127,127,127,.09); }
.alert-item .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; background: #6b7691; }
.alert-item.bad .dot { background: #c9382f; } .alert-item.warn .dot { background: #d99b2b; } .alert-item.info .dot { background: #3b82f6; }
.alert-item .ai-t { font-size: 13px; font-weight: 650; } .alert-item .ai-x { font-size: 12px; opacity: .75; margin-top: 2px; }
.alert-item .ai-dismiss { margin-left: auto; background: none; border: 0; color: inherit; opacity: .55; cursor: pointer; }
.alerts-empty { padding: 22px 14px; text-align: center; }
.agenda-switch { display: flex; gap: 8px; margin-bottom: 16px; }
.agenda-switch .btn.active { outline: 2px solid #c9a24a; }
.agenda-note-form { margin: 14px 0; padding: 14px; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 12px; }
.agenda-group { margin-top: 18px; } .agenda-group h4 { margin: 0 0 8px; font-size: 14px; } .agenda-group h4 span { opacity: .6; font-weight: 500; }
.agenda-group.overdue h4 { color: #c9382f; }
.agenda-item { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 12px; margin-bottom: 8px; }
.agenda-item.is-done strong { text-decoration: line-through; opacity: .7; }
.agenda-item .ai-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.agenda-item .ai-kind { font-size: 11px; opacity: .7; display: inline-flex; gap: 4px; align-items: center; }
.agenda-item .ai-note { font-size: 13px; white-space: pre-wrap; opacity: .85; }
.agenda-item .ai-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.reports-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 14px 0; }
.reports-filters > div { display: flex; flex-direction: column; gap: 4px; }
.reports-table-wrap { overflow: auto; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 12px; }
.reports-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.reports-table th, .reports-table td { padding: 9px 11px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border, rgba(127,127,127,.15)); }
.reports-table th:first-child, .reports-table td:first-child { text-align: left; }
.reports-table tfoot td { font-weight: 700; }
.reports-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.reports-kpis .kpi { padding: 12px 14px; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 12px; }
.reports-kpis .kpi b { display: block; font-size: 20px; } .reports-kpis .kpi span { font-size: 12px; opacity: .7; }
.close-sale-choice { display: flex; gap: 10px; margin: 8px 0 12px; }
.close-sale-choice label { flex: 1; display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--border, rgba(127,127,127,.35)); border-radius: 10px; cursor: pointer; }

/* ===== Fase 5: histórico unificado e nova mensagem ===== */
.hu-clients { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.hu-hint { font-size: 12px; margin-bottom: 2px; }
.hu-client { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 12px; cursor: pointer; }
.hu-client:hover, .hu-client:focus-visible { background: rgba(127,127,127,.08); outline: none; }
.hu-client-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hu-client-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.hu-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.hu-client-card { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }
.hu-client-card > div { display: flex; flex-direction: column; }
.hu-find { display: flex; align-items: center; gap: 8px; position: sticky; top: -28px; z-index: 5; padding: 10px 0; background: var(--bg, inherit); }
.hu-find input { flex: 1; max-width: 480px; }
.hu-blocks { display: flex; flex-direction: column; gap: 22px; margin-top: 8px; }
.hu-block { border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 14px; overflow: hidden; background: var(--chat-bg, transparent); }
.hu-proto { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 16px; background: #0a1730; color: #fff; }
.hu-proto-main { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.hu-proto-tag { color: #f3c969; font-weight: 750; font-size: 13px; letter-spacing: .02em; }
.hu-block.open .hu-proto { background: #12356b; }
.hu-meta { padding: 8px 16px 0; font-size: 12px; opacity: .75; }
.hu-sale { padding: 4px 16px 0; font-size: 12.5px; color: #1d9b5e; }
.hu-sale.none { color: inherit; opacity: .7; }
.hu-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 6px; max-height: none; }
.hu-event { align-self: center; font-size: 12px; font-style: italic; opacity: .7; padding: 2px 10px; border-top: 1px dashed var(--border, rgba(127,127,127,.35)); border-bottom: 1px dashed var(--border, rgba(127,127,127,.35)); margin: 4px 0; }
.hu-restricted { font-size: 13px; opacity: .75; padding: 6px 0; }
.hu-load { align-self: flex-start; }
mark.hu-hit { background: #ffe58a; color: #1b1b1b; border-radius: 3px; padding: 0 1px; }
.message.hu-current { outline: 2px solid #c9a24a; outline-offset: 2px; }
.nm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; margin-top: 8px; }
.nm-step { padding: 16px 18px; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.nm-step h3 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.nm-num { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: #0a1730; color: #f3c969; font-size: 13px; align-items: center; justify-content: center; }
.nm-results { display: flex; flex-direction: column; gap: 6px; }
.nm-result { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 10px; cursor: pointer; }
.nm-result:hover, .nm-result:focus-visible { background: rgba(127,127,127,.09); outline: none; }
.nm-result-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nm-busy { font-size: 11.5px; color: #b7791f; font-weight: 600; }
.nm-selected { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px dashed var(--border, rgba(127,127,127,.4)); border-radius: 12px; }
.nm-selected.empty { opacity: .65; }
.nm-selected > div { display: flex; flex-direction: column; flex: 1; }
.nm-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.nm-account { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 12px; cursor: pointer; }
.nm-account.on { border-color: #c9a24a; box-shadow: 0 0 0 1px #c9a24a inset; }
.nm-account span { display: flex; flex-direction: column; }
.nm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nm-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nm-count { margin-left: auto; }
.nm-send { align-self: flex-start; margin-top: 8px; }
.nm-preview { position: sticky; top: 8px; }
.nm-phone { border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 18px; overflow: hidden; background: var(--chat-bg, rgba(127,127,127,.08)); }
.nm-phone-head { padding: 12px 14px; background: #0a1730; color: #fff; display: flex; flex-direction: column; }
.nm-phone-head small { color: #f3c969; }
.nm-phone-body { padding: 16px 12px; min-height: 160px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.nm-bubble { max-width: 88%; padding: 9px 12px; border-radius: 12px 12px 2px 12px; background: #d9f2e0; color: #17321f; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.nm-bubble.empty { opacity: .55; background: rgba(127,127,127,.15); color: inherit; }
.nm-attach { max-width: 88%; padding: 8px 12px; border-radius: 10px; background: rgba(127,127,127,.18); font-size: 12.5px; word-break: break-all; }
.nm-info { list-style: none; padding: 0; margin: 12px 2px 0; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.nm-info li { padding-left: 10px; border-left: 3px solid rgba(127,127,127,.35); }
.nm-info li.ok { border-color: #1d9b5e; } .nm-info li.warn { border-color: #d99b2b; } .nm-info li.bad { border-color: #c9382f; color: #c9382f; font-weight: 600; }
@media (max-width: 980px) { .nm-layout { grid-template-columns: 1fr; } .nm-preview { position: static; } .nm-row { grid-template-columns: 1fr; } }

/* ===== Cargos e permissões por página ===== */
.page-perm-grid { display: flex !important; flex-direction: column; gap: 10px; }
.perm-page { border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 12px; padding: 10px 14px; }
.perm-page-head { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.perm-page-head small { margin-left: auto; font-size: 11.5px; }
.perm-page-hint, .perm-page-none { display: block; margin: 4px 0 0 26px; font-size: 12px; }
.perm-page-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; margin: 8px 0 2px 26px; }
.perm-page.page-off { background: rgba(127,127,127,.07); }
.perm-page.page-off .perm-page-list, .perm-page.page-off .perm-page-hint { opacity: .5; }
.perm-page.page-off .perm-page-head strong { text-decoration: line-through; opacity: .7; }

.media-expired { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px dashed var(--border, rgba(127,127,127,.4)); border-radius: 10px; font-size: 13px; opacity: .85; }
.media-expired small { font-size: 11.5px; opacity: .75; }

/* ===== v2.11: painel do gestor e relatórios de gestão ===== */
.mg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
.mg > *, .mg-section, .mg-grid > *, #mgBody > * { min-width: 0; }
.mg-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mg-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.mg-field { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.mg-field label { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.mg-presets { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.mg-presets button { border: 0; background: transparent; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border); }
.mg-presets button:last-child { border-right: 0; }
.mg-presets button:hover { background: var(--surface-2); }
.mg-presets button.active { background: var(--primary); color: #fff; }
.dark-mode .mg-presets button.active { background: var(--gold-500); color: #0a1730; }
.mg-section { display: grid; gap: 14px; }
.mg-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mg-section-head h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.mg-live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(30, 158, 106, .6); animation: mgPulse 2s infinite; }
@keyframes mgPulse { 70% { box-shadow: 0 0 0 8px rgba(30, 158, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(30, 158, 106, 0); } }
.mg-tiles, .mg-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.mg-kpi { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border: 1px solid var(--border); border-left: 4px solid var(--navy-600); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); min-width: 0; }
.mg-kpi.bad { border-left-color: var(--danger); } .mg-kpi.warn { border-left-color: var(--warn); }
.mg-kpi-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.mg-kpi-value { font-size: 26px; line-height: 1.1; font-weight: 750; letter-spacing: -.02em; }
.mg-kpi small { color: var(--muted); font-size: 12px; }
.mg-of { font-size: 14px; font-weight: 600; color: var(--muted); }
.mg-delta { font-style: normal; font-size: 11.5px; font-weight: 700; margin-top: 2px; color: var(--muted); }
.mg-delta.good { color: var(--ok); } .mg-delta.bad { color: var(--danger); }
.mg-alerts { display: grid; gap: 6px; }
.mg-alert { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 10px; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--border); }
.mg-alert span { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.mg-alert.red { background: var(--danger-soft); border-color: rgba(214, 69, 80, .35); } .mg-alert.red span { background: var(--danger); }
.mg-alert.yellow { background: var(--warn-soft); border-color: rgba(217, 145, 26, .4); } .mg-alert.yellow span { background: var(--warn); }
.mg-alert.ok { background: var(--ok-soft); border-color: rgba(30, 158, 106, .35); } .mg-alert.ok span { background: var(--ok); }
.mg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.mg-grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mg-grid .manager-card.span-2 { grid-column: span 2; }
.mg-table-wrap { overflow: auto; }
.mg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mg-table th { text-align: right; padding: 8px 10px; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .03em; white-space: nowrap; border-bottom: 1px solid var(--border-strong); }
.mg-table td { padding: 9px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mg-table th:first-child, .mg-table td:first-child { text-align: left; }
.mg-table td:first-child { white-space: normal; min-width: 170px; }
.mg-table td small { display: block; font-size: 11.5px; }
.mg-table tfoot td { font-weight: 750; border-top: 2px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.mg-table tr.mg-click { cursor: pointer; }
.mg-table tr.mg-click:hover td { background: var(--surface-2); }
.mg-table td.mg-good { color: var(--ok); font-weight: 700; } .mg-table td.mg-bad { color: var(--danger); font-weight: 700; }
.mg-warn-text { color: var(--danger); }
.mg-avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 8px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 800; vertical-align: middle; }
.mg-avatar.big { width: 48px; height: 48px; font-size: 16px; margin: 0; }
.dark-mode .mg-avatar { background: var(--accent-soft); color: var(--gold-400); }
.mg-table td:first-child b { vertical-align: middle; }
.mg-table td:first-child small { margin-left: 36px; }
.mg-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.mg-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.mg-pill.green { background: var(--ok-soft); color: var(--ok); } .mg-pill.green i { background: var(--ok); }
.mg-pill.yellow { background: var(--warn-soft); color: var(--warn); } .mg-pill.yellow i { background: var(--warn); }
.mg-pill.red { background: var(--danger-soft); color: var(--danger); } .mg-pill.red i { background: var(--danger); }
.mg-chip { display: inline-block; padding: 2px 9px; border-radius: 8px; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.mg-chip.green { background: var(--ok-soft); color: var(--ok); } .mg-chip.yellow { background: var(--warn-soft); color: var(--warn); } .mg-chip.red { background: var(--danger-soft); color: var(--danger); }
.mg-list { display: grid; gap: 6px; max-height: 380px; overflow: auto; }
.mg-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; }
.mg-item > div:first-child { min-width: 0; } .mg-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-item-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.mg-empty { padding: 12px 4px; }
.mg-bars-plot { display: flex; align-items: stretch; gap: 3px; height: 170px; padding-top: 6px; }
.mg-bcol { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.mg-bpair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--border-strong); }
.mg-b { display: block; flex: 1 1 0; max-width: 18px; min-height: 0; border-radius: 3px 3px 0 0; background: var(--navy-600); }
.mg-b.c2 { background: var(--gold-500); } .mg-b.c3 { background: #5aa6a0; }
.dark-mode .mg-b { background: #6d8fd6; } .dark-mode .mg-b.c2 { background: var(--gold-400); }
.mg-blabel { font-size: 10px; color: var(--muted); text-align: center; height: 16px; white-space: nowrap; overflow: visible; }
.mg-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.mg-legend span { display: inline-flex; align-items: center; gap: 6px; } .mg-legend .mg-b { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 2px; }
.mg-hbars { display: grid; gap: 11px; }
.mg-hlabel { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.mg-hlabel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-htrack { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 4px 0 2px; }
.mg-htrack i { display: block; height: 100%; border-radius: 999px; background: var(--navy-600); } .dark-mode .mg-htrack i { background: var(--gold-500); }
.mg-inbar { height: 4px; border-radius: 4px; background: var(--surface-3); margin-bottom: 3px; min-width: 60px; } .mg-inbar i { display: block; height: 100%; border-radius: 4px; background: var(--navy-600); }
.mg-team-card { overflow: hidden; }
.mg-note { margin: 10px 0 0; }
.mg-good-dot, .mg-bad-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; background: var(--ok); } .mg-bad-dot { background: var(--danger); }
.mg-agent-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.mg-agent-head b { font-size: 18px; display: block; } .mg-agent-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
#mgBody { display: grid; gap: 16px; } #mgBody.mg-loading { opacity: .55; transition: opacity .15s; }
.mg-audit h3 { justify-content: flex-start; } .mg-audit h3 .btn { margin-left: auto; }
/* relatórios */
.mg-rep-types { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.mg-rep-types button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-weight: 650; font-size: 13px; cursor: pointer; }
.mg-rep-types button:hover { background: var(--surface-2); }
.mg-rep-types button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.dark-mode .mg-rep-types button.active { background: var(--gold-500); border-color: var(--gold-500); color: #0a1730; }
.mg-rep-quick { flex-direction: row !important; gap: 6px !important; align-items: center; }
.mg-rep-title { margin: 14px 0 10px; font-size: 17px; } .mg-rep-title small { font-size: 12.5px; font-weight: 500; margin-left: 8px; }
.mg-rep-out h4 { margin: 18px 0 8px; }
.mg-rep-table th { cursor: pointer; user-select: none; } .mg-rep-table th.txt, .mg-rep-table td.txt { text-align: left; }
.mg-rep-table td.txt { white-space: normal; min-width: 90px; }
.mg-vs { display: block; font-size: 11px; margin-top: 2px; } .mg-vs.good { color: var(--ok); } .mg-vs.bad { color: var(--danger); }
@media (max-width: 1100px) { .mg-grid, .mg-grid3 { grid-template-columns: 1fr; } .mg-grid .manager-card.span-2 { grid-column: auto; } }
