:root {
    --navy: #1a3054;
    --navy-light: #243d64;
    --red: #e02030;
    --red-hover: #c91a28;
    --bg: #f0f2f6;
    --white: #ffffff;
    --gray-100: #f7f8fa;
    --gray-200: #e8ebf0;
    --gray-300: #d0d5dd;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --text: #1f2937;
    --green: #059669;
    --yellow: #d97706;
    --blue: #2563eb;
    --sidebar-w: 220px;
    --sidebar-w-collapsed: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ── LOGIN ── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(26,48,84,0.08);
    padding: 48px 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-card h1 { font-size: 22px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.login-card .subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 32px; }
.login-card .logo { height: 40px; margin-bottom: 20px; }

.login-card input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
    margin-bottom: 16px;
}

.login-card input:focus { border-color: var(--navy); }

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── BUTTONS ── */
.btn {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-red { background: var(--red); color: var(--white); }
.btn-red:hover { background: var(--red-hover); }
.btn-navy { background: var(--navy); color: var(--white); }
.btn-navy:hover { opacity: 0.9; }
.btn-outline { background: var(--white); color: var(--navy); border: 1.5px solid var(--gray-300); }
.btn-outline:hover { border-color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger-outline { background: var(--white); color: #b91c1c; border: 1.5px solid #fecaca; }
.btn-danger-outline:hover { background: #fef2f2; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }
.btn-green { background: var(--green); color: var(--white); }
.btn-green:hover { opacity: 0.9; }

/* ── LAYOUT: SIDEBAR + MAIN ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: width 0.2s ease;
}

/* Botao de collapse/expand — vive no sidebar-header (topo direita) */
.sidebar-collapse-btn {
    position: absolute;
    top: 20px;
    right: 10px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.15s, color 0.15s, transform 0.2s;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.18); color: var(--white); }
/* Chevron aponta pra direita quando colapsado (indica "expandir") */
.app-layout.sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 { font-size: 16px; font-weight: 700; }
.sidebar-header .subtitle { font-size: 11px; opacity: 0.6; margin-top: 4px; }

/* Botao de busca no topo do menu — porta de entrada visivel do Ctrl/Cmd+K.
   O atalho ja' existia, mas so' quem viu a dica do dashboard descobria: sem
   affordance na tela, a busca era invisivel pra maioria. */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 9px;
    width: calc(100% - 24px);
    margin: 12px 12px 2px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    color: rgba(255,255,255,0.62);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.sidebar-search:hover {
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.20);
    color: var(--white);
}
.sidebar-search:focus-visible { outline: 2px solid rgba(255,255,255,0.45); outline-offset: 2px; }
.sidebar-search-icon { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-search-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-search-kbd {
    font: 600 10px/1 ui-monospace, monospace;
    color: rgba(255,255,255,0.55);
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 4px;
    padding: 3px 5px;
    flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

/* Barra de rolagem do menu (13/08): sem estilo, o Chrome/Windows desenha a
   barra nativa — larga, clara e com setinhas — que berra sobre o navy. Aqui ela
   fica fina, arredondada e translucida: quase invisivel parada, mais visivel
   quando o mouse esta na sidebar, e destacada so' ao passar sobre ela.
   `scrollbar-color` cobre Firefox; o resto e' WebKit/Blink. */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.16) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.10);
    border-radius: 99px;
    transition: background 0.2s ease;
}
.sidebar:hover .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.26); }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.42); }
/* mata as setas de rolagem do Chrome no Windows (nao existem no Mac) */
.sidebar-nav::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.sidebar-nav::-webkit-scrollbar-corner { background: transparent; }

/* No menu recolhido (so' icones) a barra fica ainda mais discreta pra nao
   competir com os 24px de icone. */
.app-layout.sidebar-collapsed .sidebar-nav::-webkit-scrollbar { width: 4px; }
.app-layout.sidebar-collapsed .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }
.app-layout.sidebar-collapsed .sidebar:hover .sidebar-nav::-webkit-scrollbar-thumb,
.app-layout.sidebar-collapsed .sidebar-nav:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.22); }

.nav-group-label {
    padding: 16px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.15s;
}

.nav-group-label:hover { color: rgba(255,255,255,0.55); }
.nav-group-label:first-child { padding-top: 8px; }

.nav-group-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.nav-group-label.collapsed .nav-group-arrow { transform: rotate(-90deg); }

.nav-group-items {
    overflow: hidden;
    /* SEM teto fixo (fix 13/08): era `max-height: 500px`, e o grupo TI — com 14
       itens, ~616px — ficava CORTADO. Sumiam Usuários, Roles & Permissões e
       Audit Log, e o rótulo do grupo seguinte encostava no item cortado, o que
       parecia um "divisor sobrepondo". A animação de recolher continua: o JS
       (toggleNavGroup) escreve a altura em px na hora do toggle. */
    max-height: none;
    transition: max-height 0.25s ease;
}

.nav-group-items.collapsed { max-height: 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.sidebar-nav a.active { background: rgba(255,255,255,0.12); color: var(--white); border-right: 3px solid var(--red); }

.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 12px 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
}

/* ── Bloco do usuário no rodapé (16/10/2026, card 5ec414aa) ──────────
   Perfil (só informação) + sininho + Sair num lugar só. */
.sb-user { display: flex; align-items: center; gap: 6px; }
.sb-user-info {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
    color: var(--white); padding: 6px; cursor: default;
}
.sb-avatar {
    flex: none; width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--red); color: #fff; font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.12);
}
.sb-user-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sb-user-nome { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-email { font-size: 11px; opacity: 0.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Ícone do WhatsApp ao lado do sino: mesmo formato discreto, número pequeno */
.sb-ico {
    position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%;
    align-items: center; justify-content: center; text-decoration: none;
    color: rgba(255,255,255,0.85); border: 1px solid rgba(255,255,255,0.18);
}
.sb-ico:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sb-ico svg { width: 18px; height: 18px; }
.sb-ico-count {
    position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #16a34a; color: #fff; border: 2px solid var(--navy); border-radius: 99px;
    font-size: 10px; font-weight: 700; line-height: 1;
}

.sb-sair {
    display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
    margin-top: 8px; padding: 6px 10px; background: transparent; color: rgba(255,255,255,0.75);
    border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
    font-family: inherit; font-size: 12px; cursor: pointer;
}
.sb-sair:hover { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.3); }
.sb-sair-ico { font-size: 13px; line-height: 1; }


.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0; /* permite que filhos com overflow-x funcionem dentro do flex parent */
    padding: 0;
    transition: margin-left 0.2s ease;
}

/* ── Sidebar COLAPSADA (so' icones) ─────────────────────────
   Ativado por classe .sidebar-collapsed no .app-layout (pai). Assim atinge
   .sidebar (largura) e .main-content (margin) numa unica troca de classe.
   Preserva TUDO original quando a classe nao esta' presente. */
.app-layout.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.app-layout.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-collapsed); }

/* Header vira apenas o botao — esconde titulo/subtitulo */
.app-layout.sidebar-collapsed .sidebar-header h1,
.app-layout.sidebar-collapsed .sidebar-header .subtitle { display: none; }
.app-layout.sidebar-collapsed .sidebar-header {
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 52px;
}
.app-layout.sidebar-collapsed .sidebar-collapse-btn { position: static; }

/* Busca vira so' a lupa, alinhada com os icones do menu */
.app-layout.sidebar-collapsed .sidebar-search {
    width: calc(100% - 16px);
    margin: 10px 8px 2px;
    padding: 9px 0;
    justify-content: center;
    background: none;
    border-color: transparent;
}
.app-layout.sidebar-collapsed .sidebar-search:hover { background: rgba(255,255,255,0.08); }
.app-layout.sidebar-collapsed .sidebar-search-text,
.app-layout.sidebar-collapsed .sidebar-search-kbd { display: none; }
.app-layout.sidebar-collapsed .sidebar-search-icon { width: 19px; height: 19px; }

/* Labels dos grupos somem — no modo icone o header do grupo vira ruido */
.app-layout.sidebar-collapsed .nav-group-label { display: none; }
/* E os items do grupo ficam sempre visiveis (ignora o collapsed por grupo) */
.app-layout.sidebar-collapsed .nav-group-items { max-height: none; }

/* Links: so' icone centralizado; texto e badge somem */
.app-layout.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
}
.app-layout.sidebar-collapsed .sidebar-nav a > span:not(.nav-icon),
.app-layout.sidebar-collapsed .sidebar-nav a .nav-badge { display: none; }
.app-layout.sidebar-collapsed .sidebar-nav a .nav-icon { width: auto; font-size: 20px; }
/* Barra vermelha do ativo passa a ser a esquerda pra caber no bloco estreito */
.app-layout.sidebar-collapsed .sidebar-nav a.active {
    border-right: none;
    border-left: 3px solid var(--red);
}

/* Footer recolhido: avatar, sino e Sair empilhados */
.app-layout.sidebar-collapsed .sidebar-footer { padding: 10px 6px 12px; }
.app-layout.sidebar-collapsed .sb-user { flex-direction: column-reverse; gap: 8px; }
.app-layout.sidebar-collapsed .sb-user-info { flex: none; justify-content: center; padding: 4px; }
.app-layout.sidebar-collapsed .sb-user-txt { display: none; }
.app-layout.sidebar-collapsed .sb-sair { padding: 6px 0; }
.app-layout.sidebar-collapsed .sb-sair-txt { display: none; }

/* ── PAGE HEADER ── */
.page-header {
    padding: 24px 32px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-header h2 { font-size: 20px; font-weight: 700; color: var(--navy); }

/* ── CARDS / STATS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 24px 32px;
}

.stat-card {
    background: var(--white);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stat-card .stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
}

.stat-card .stat-detail { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ── TOOLBAR ── */
.toolbar {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-input {
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
    width: 280px;
    background: var(--white);
}

.search-input:focus { border-color: var(--navy); }
.toolbar-spacer { flex: 1; }

.filter-select {
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
    background: var(--white);
}

/* ── TABLE ── */
.table-container { padding: 0 32px 32px; overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    font-size: 14px;
}

thead { background: var(--navy); color: var(--white); }

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fb; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active { background: #ecfdf5; color: var(--green); }
.badge-draft { background: var(--gray-100); color: var(--gray-500); }
.badge-sending { background: #eff6ff; color: var(--blue); }
.badge-sent { background: #ecfdf5; color: var(--green); }
.badge-scheduled { background: #fef3c7; color: var(--yellow); }
.badge-error { background: #fef2f2; color: #b91c1c; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }

.actions { display: flex; gap: 6px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state h2 { font-size: 18px; margin-bottom: 8px; color: var(--gray-700); }

/* ── MODAL ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--white);
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 24px 28px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 { font-size: 18px; font-weight: 700; color: var(--navy); }

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 24px 28px 28px; }
.modal-body .form-group { margin-bottom: 16px; }

.modal-body label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus { border-color: var(--navy); }

.modal-body textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-footer {
    padding: 0 28px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ── CHART CONTAINER ── */
.chart-container {
    background: var(--white);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    margin: 0 32px 24px;
}

.chart-container h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 16px;
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--navy);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    /* Acima de qualquer overlay de tela cheia (o padrao da casa e' 9999, em 24
       telas). Com z-index 200 o toast ficava ATRAS do editor/modal aberto: a
       acao falhava e a mensagem de erro era pintada por baixo, sem ninguem ver. */
    z-index: 2147482000;
    animation: slideUp 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

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

/* ── CSV DROP ZONE ── */
.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--navy);
    background: var(--gray-100);
}

.drop-zone .icon { font-size: 32px; margin-bottom: 8px; }
.drop-zone .label { font-size: 14px; }
.drop-zone .hint { font-size: 12px; margin-top: 4px; }

/* ── CAMPAIGN EDITOR ── */
.html-editor {
    width: 100%;
    min-height: 300px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    resize: vertical;
}

.html-editor:focus { border-color: var(--navy); outline: none; }

.preview-frame {
    width: 100%;
    min-height: 400px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    background: var(--white);
}

/* ── HAMBURGER MENU ── */
.hamburger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--navy);
    color: var(--white);
    font-size: 22px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    line-height: 1;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 45;
}

.sidebar-overlay.show { display: block; }

/* ── RESPONSIVE ── */

.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-container { overflow-x: auto; }

@media (max-width: 1200px) {
    td, th { padding: 10px 10px; font-size: 13px; }
}

@media (max-width: 768px) {
    .hamburger { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    /* No mobile o collapse-desktop nao se aplica — sidebar volta ao tamanho cheio
       (off-canvas) e o botao de collapse some. Mobile tem seu proprio hamburger. */
    .sidebar-collapse-btn { display: none !important; }
    .app-layout.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
    .app-layout.sidebar-collapsed .main-content { margin-left: 0; }
    .app-layout.sidebar-collapsed .sidebar-search {
        width: calc(100% - 24px); margin: 12px 12px 2px; padding: 8px 10px;
        justify-content: flex-start; background: rgba(255,255,255,0.07);
        border-color: rgba(255,255,255,0.10);
    }
    .app-layout.sidebar-collapsed .sidebar-search-text { display: block; }
    .app-layout.sidebar-collapsed .sidebar-search-icon { width: 15px; height: 15px; }
    .sidebar-search-kbd { display: none; }
    .toolbar, .table-container, .stats-grid, .page-header, .chart-container { padding-left: 16px; padding-right: 16px; }
    .page-header { flex-wrap: wrap; padding-top: 60px; }
    .page-header .actions { width: 100%; }
    .search-input { width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .login-card { padding: 32px 24px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    td, th { padding: 8px 8px; font-size: 12px; }
}

/* ── Command palette (Ctrl/Cmd + K) ──────────────────────────────
   Busca de telas, disponivel em qualquer pagina. Logica em shared/nav.js. */
.cmdk-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
    display: none; justify-content: center; align-items: flex-start;
    padding: 12vh 16px 16px;
}
.cmdk-overlay.show { display: flex; }
.cmdk-panel {
    width: 100%; max-width: 560px;
    background: var(--white); border-radius: 14px;
    border: 1px solid var(--gray-200);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    overflow: hidden;
    animation: cmdk-in 130ms cubic-bezier(.2,.8,.3,1) both;
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-8px) scale(.985); } }

.cmdk-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--gray-200); }
.cmdk-search-icon { width: 17px; height: 17px; color: var(--gray-500); flex-shrink: 0; }
.cmdk-search input {
    flex: 1; border: 0; outline: 0; background: transparent;
    font-size: 15px; font-family: inherit; color: var(--text); min-width: 0;
}
.cmdk-search input::placeholder { color: var(--gray-500); opacity: .75; }
.cmdk-esc {
    font: 600 10px/1 ui-monospace, monospace; color: var(--gray-500);
    background: var(--gray-100); border: 1px solid var(--gray-200);
    border-radius: 5px; padding: 4px 6px; flex-shrink: 0;
}

.cmdk-list { max-height: min(52vh, 400px); overflow-y: auto; padding: 6px; }
.cmdk-section {
    font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: var(--gray-500); padding: 8px 10px 5px;
}
.cmdk-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: 8px; cursor: pointer;
    /* sem transition: com teclado a selecao anda rapido e o fade atrasa a leitura */
}
.cmdk-item.active { background: var(--gray-100); }
.cmdk-item.active .cmdk-group { color: var(--gray-700); }
.cmdk-ico { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.cmdk-label { flex: 1; font-size: 13.5px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-label mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
.cmdk-group { font-size: 11px; color: var(--gray-500); flex-shrink: 0; }
.cmdk-empty { padding: 26px 14px; text-align: center; color: var(--gray-500); font-size: 13px; }

.cmdk-foot {
    display: flex; gap: 16px; align-items: center;
    padding: 9px 14px; border-top: 1px solid var(--gray-200);
    background: var(--gray-100); font-size: 11px; color: var(--gray-500);
}
.cmdk-foot kbd {
    font: 600 10px/1 ui-monospace, monospace; color: var(--gray-700);
    background: var(--white); border: 1px solid var(--gray-300);
    border-radius: 4px; padding: 3px 5px; margin-right: 3px;
}

/* Dica do atalho — discreta, some depois de usado (ver dashboard) */
.cmdk-hint {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12.5px; color: var(--gray-500);
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: 999px; padding: 6px 14px 6px 12px;
    cursor: pointer; transition: border-color 120ms ease, color 120ms ease;
}
.cmdk-hint:hover { border-color: var(--gray-300); color: var(--gray-700); }
.cmdk-hint kbd {
    font: 600 10.5px/1 ui-monospace, monospace; color: var(--gray-700);
    background: var(--gray-100); border: 1px solid var(--gray-200);
    border-radius: 4px; padding: 3px 6px;
}
.cmdk-hint-x { border: 0; background: none; color: var(--gray-300); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 0 0 2px; }
.cmdk-hint-x:hover { color: var(--gray-500); }

@media (max-width: 600px) {
    .cmdk-overlay { padding-top: 8vh; }
    .cmdk-group { display: none; }
    .cmdk-foot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .cmdk-panel { animation: none; }
}

/* ── Anti-flash da tela de login ─────────────────────────────
   Toda pagina do sistema nasce com <div id="loginScreen"> visivel e
   <div id="appScreen" style="display:none">. Sem CSS extra, quem ja' esta
   logado ve o loginScreen por milissegundos entre o primeiro paint e o JS
   rodar. O snippet inline em <head> de cada pagina adiciona `has-session`
   no <html> quando `nau_sistema_session` esta' no localStorage — as regras
   abaixo entao invertem a visibilidade DEFAULT pra quem esta' logado.

   Se o backend rejeitar a sessao (raro, TTL 90d), showLogin() removera' a
   classe e restaura o comportamento normal. !important pra vencer o style
   inline `display:none` do #appScreen. */
html.has-session #loginScreen { display: none !important; }
html.has-session #appScreen { display: block !important; }

/* ── Sininho de notificacoes (nav.js) ──────────────────────────────
   Desde 16/10/2026 (card 5ec414aa) o sino mora no RODAPÉ do menu lateral, ao
   lado do usuário (.notif-bell-sb) — no canto superior direito ele cobria
   botões das telas. No celular o menu fica escondido, então lá continua o sino
   flutuante (.notif-bell-mobile). O painel abre ao lado do menu (nav.js). */
.notif-bell {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid #e5e7eb;
    color: var(--navy);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(15,23,42,0.08);
    z-index: 2147481500;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.notif-bell:hover { box-shadow: 0 4px 16px rgba(15,23,42,0.14); transform: translateY(-1px); }
.notif-bell.has-unread { border-color: var(--red); }

/* No rodapé escuro do menu: sem fundo branco, ícone claro */
.notif-bell-sb {
    width: 36px; height: 36px; background: transparent; color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.18); box-shadow: none;
}
.notif-bell-sb:hover { background: rgba(255,255,255,0.08); box-shadow: none; transform: none; color: #fff; }
.notif-bell-sb.has-unread { border-color: var(--red); background: rgba(220,38,38,0.12); }
.notif-bell-sb.has-unread .notif-bell-icon { color: #fff; }
.notif-bell-sb .notif-bell-count { border-color: var(--navy); }

/* Flutuante: só no celular */
.notif-bell-mobile { display: none; position: fixed; top: 10px; right: 12px; }
@media (max-width: 768px) { .notif-bell-mobile { display: flex; } }

/* Icone SVG no lugar do emoji 🔔: emoji muda de desenho por sistema operacional,
   nao herda `color` e nao acompanha o estado (has-unread). */
.notif-bell-icon { display: block; width: 19px; height: 19px; line-height: 0; }
.notif-bell-icon svg { width: 100%; height: 100%; display: block; }
.notif-bell.has-unread .notif-bell-icon { color: var(--red); }

/* Balanco no hover: o corpo do sino gira em torno do TOPO (a alca), que e' como
   um sino real se move — girar pelo centro faria o desenho deslizar. O badalo
   acompanha com um atraso curto. */
.notif-bell:hover .notif-bell-corpo { animation: notif-bell-balanca .7s ease-in-out; }
.notif-bell:hover .notif-bell-badalo { animation: notif-bell-balanca .7s ease-in-out .05s; }
.notif-bell-corpo, .notif-bell-badalo { transform-origin: 12px 3px; }

@keyframes notif-bell-balanca {
      0% { transform: rotate(0deg); }
     15% { transform: rotate(11deg); }
     30% { transform: rotate(-9deg); }
     45% { transform: rotate(6deg); }
     60% { transform: rotate(-4deg); }
     75% { transform: rotate(2deg); }
    100% { transform: rotate(0deg); }
}

/* Respeita quem pediu menos movimento no sistema. */
@media (prefers-reduced-motion: reduce) {
    .notif-bell:hover .notif-bell-corpo,
    .notif-bell:hover .notif-bell-badalo { animation: none; }
    .notif-bell { transition: box-shadow .15s ease; }
    .notif-bell:hover { transform: none; }
}
.notif-bell-count {
    position: absolute;
    top: -4px;
    right: -4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--red);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.notif-panel {
    display: none;
    position: fixed;
    top: 64px;
    right: 22px;
    width: 368px;
    max-height: 72vh;
    background: #fff;
    border: 1px solid #e9ebef;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15,23,42,0.16);
    z-index: 2147481000;
    overflow: hidden;
    flex-direction: column;
}
.notif-panel.open { display: flex; animation: notifPanelIn 0.15s ease; }
@keyframes notifPanelIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.notif-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid #eef0f3;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--navy);
}
.notif-panel-head button {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}
.notif-panel-head button:hover { background: #f3f4f6; color: var(--navy); }
.notif-panel-list { overflow-y: auto; padding: 6px; }
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    cursor: pointer;
}
.notif-item:hover { background: #f7f8fa; }
.notif-item.unread { background: #f4f7ff; }
.notif-item-icon {
    flex: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #eef1f5;
    font-size: 15px;
}
.notif-item.type-task_assigned .notif-item-icon { background: #eaf1ff; }
.notif-item.type-instagram_published .notif-item-icon { background: #fdeef6; }
.notif-item.type-instagram_failed .notif-item-icon { background: #fdecec; }
.notif-item-body-col { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--navy); }
.notif-item-text { font-size: 12px; color: #6b7280; margin-top: 2px; line-height: 1.4; }
.notif-item-time { font-size: 11px; color: #9ca3af; margin-top: 5px; }
.notif-item-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    margin-top: 6px;
}
.notif-empty { padding: 40px 14px; text-align: center; color: #9ca3af; font-size: 13px; }
.notif-empty-icon { font-size: 26px; display: block; margin-bottom: 8px; opacity: 0.6; }

#notifToasts {
    position: fixed;
    top: 66px;
    right: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2147482100;
}
.notif-toast {
    background: var(--navy);
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    max-width: 320px;
    cursor: pointer;
    animation: slideUp 0.3s ease;
    border-left: 3px solid var(--red);
}
.notif-toast.leaving { opacity: 0; transition: opacity 0.3s ease; }
.notif-toast-title { font-size: 13px; font-weight: 700; }
.notif-toast-body { font-size: 12px; opacity: 0.85; margin-top: 3px; }

@media (max-width: 640px) {
    .notif-bell-mobile { top: 10px; right: 12px; }
    .notif-panel { top: 58px; right: 10px; left: 10px; width: auto; }
    #notifToasts { top: 58px; right: 12px; left: 12px; }
    .notif-toast { max-width: none; }
}

/* Categoria das caixas de WhatsApp (shared/wa-categorias.js) */
.wa-cat-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 12px; background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; white-space: nowrap; }
.wa-cat-badge.vazio { background: var(--gray-100); color: var(--gray-500); border-color: var(--gray-200); }
.wa-cat-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wa-cat-row select { padding: 6px 8px; border: 1px solid var(--gray-300); border-radius: 8px; font-family: inherit; font-size: 13px; background: var(--white); }

/* ── Modo embutido (redesign, 16/10/2026): tela aberta dentro do app novo (/app/) ──
   O app novo desenha menu, topo e sino; aqui some a moldura antiga. */
html.nau-embutido .sidebar,
html.nau-embutido .hamburger,
html.nau-embutido .sidebar-overlay,
html.nau-embutido .notif-bell-mobile,
html.nau-embutido #notifToasts { display: none !important; }
html.nau-embutido .main-content { margin-left: 0 !important; border-left: none !important; }
