@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

:root {
    --bg: #05060a;
    --bg-elevated: #0a0c14;
    --surface: #0d1020;
    --surface-2: #151a2e;
    --surface-3: #1a2038;
    --border: rgba(255,255,255,0.05);
    --border-hover: rgba(255,255,255,0.1);
    --border-active: rgba(99,102,241,0.3);
    --primary: #6366F1;
    --primary-light: #818CF8;
    --primary-dark: #4F46E5;
    --primary-glow: rgba(99,102,241,0.12);
    --primary-glow-strong: rgba(99,102,241,0.25);
    --text-1: #F1F5F9;
    --text-2: #94A3B8;
    --text-3: #64748B;
    --text-4: #334155;
    --success: #10B981;
    --success-glow: rgba(16,185,129,0.12);
    --warning: #F59E0B;
    --warning-glow: rgba(245,158,11,0.12);
    --error: #EF4444;
    --error-glow: rgba(239,68,68,0.12);
    --danger: #EF4444;
    /* Preenchimentos sutis — substituem os rgba(255,255,255,0.0x) inline */
    --fill-1: rgba(255,255,255,0.01);
    --fill-2: rgba(255,255,255,0.02);
    --fill-3: rgba(255,255,255,0.03);
    --fill-4: rgba(255,255,255,0.05);
    --fill-5: rgba(255,255,255,0.08);
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 24px rgba(99,102,241,0.15);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Tema claro ── */
[data-theme="light"] {
    --bg: #F1F5F9;
    --bg-elevated: #FFFFFF;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --surface-3: #E2E8F0;
    --border: rgba(15,23,42,0.10);
    --border-hover: rgba(15,23,42,0.18);
    --text-1: #0F172A;
    --text-2: #475569;
    --text-3: #64748B;
    --text-4: #94A3B8;
    --fill-1: rgba(15,23,42,0.015);
    --fill-2: rgba(15,23,42,0.03);
    --fill-3: rgba(15,23,42,0.045);
    --fill-4: rgba(15,23,42,0.07);
    --fill-5: rgba(15,23,42,0.10);
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
    --shadow-md: 0 4px 16px rgba(15,23,42,0.08);
    --shadow-lg: 0 8px 32px rgba(15,23,42,0.12);
    --shadow-glow: 0 0 24px rgba(99,102,241,0.18);
}

body { background: var(--bg); color: var(--text-1); min-height: 100vh; -webkit-font-smoothing: antialiased; }

/* ── Custom Checkbox ── */
input[type="checkbox"] {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 4px; cursor: pointer;
    border: 2px solid var(--border-hover); background: transparent;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.15s; flex-shrink: 0; position: relative;
}
input[type="checkbox"]:hover { border-color: var(--primary); }
input[type="checkbox"]:checked {
    background: var(--primary); border-color: var(--primary);
}
input[type="checkbox"]:checked::after {
    content: ''; width: 10px; height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: contain; background-repeat: no-repeat;
}
input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }
.app.login-mode .sidebar { display: none; }
.app.login-mode .main { margin-left: 0; max-width: 100vw; padding: 0; }

.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 0; position: fixed; top: 0; left: 0; bottom: 0;
    overflow-y: auto; z-index: 100;
    display: flex; flex-direction: column;
}

.main {
    margin-left: var(--sidebar-w); flex: 1;
    padding: 28px 36px; min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-w));
    background: var(--bg);
}

/* ── Barra superior ── */
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app.login-mode .topbar { display: none; }
.topbar {
    margin-left: var(--sidebar-w);
    height: 56px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 0 36px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 90;
}
.topbar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 5px 10px 5px 6px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--fill-2);
    color: var(--text-2); font-size: 13px; cursor: pointer;
    transition: all var(--transition);
}
.topbar-user:hover { background: var(--fill-3); border-color: var(--border-hover); color: var(--text-1); }
.topbar-avatar {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary-glow-strong); color: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; letter-spacing: .5px;
}
.topbar-caret { width: 14px; height: 14px; opacity: .6; }
.topbar-notif {
    position: relative; width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--fill-2);
    color: var(--text-2); cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: all var(--transition);
}
.topbar-notif:hover { background: var(--fill-3); border-color: var(--border-hover); color: var(--text-1); }
.notif-badge {
    position: absolute; top: -2px; right: -2px;
    min-width: 17px; height: 17px; border-radius: 9px;
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px; line-height: 1;
}
.notif-dropdown {
    position: absolute; top: 46px; right: 0; width: 340px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    z-index: 200; overflow: hidden;
}
.notif-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-size: 14px; font-weight: 600; color: var(--text-1);
}
.notif-dropdown-list {
    max-height: 320px; overflow-y: auto;
}
.notif-item {
    display: flex; gap: 10px; padding: 12px 16px;
    border-bottom: 1px solid var(--border); cursor: default;
    transition: background 0.1s;
}
.notif-item:hover { background: var(--fill-2); }
.notif-item.unread { background: rgba(99,102,241,0.04); }
.notif-item-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.notif-item-msg { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.notif-item-time { font-size: 10px; color: var(--text-3); margin-top: 4px; }
.notif-empty {
    padding: 32px 16px; text-align: center; color: var(--text-3); font-size: 13px;
}

/* ── Menu suspenso ── */
.umenu {
    position: absolute; top: 50px; right: 36px; z-index: 200;
    min-width: 232px; padding: 6px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.umenu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.umenu-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.umenu-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.umenu-item {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border: none; border-radius: 8px;
    background: transparent; color: var(--text-2);
    font-size: 13px; text-align: left; cursor: pointer;
    transition: all .12s;
}
.umenu-item:hover { background: var(--fill-3); color: var(--text-1); }
.umenu-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.umenu-item.danger { color: var(--error); }
.umenu-item.danger:hover { background: var(--error-glow); }
.umenu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.umenu-label {
    font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-4); padding: 4px 12px 6px;
}
.umenu-check { width: 16px; flex-shrink: 0; display: inline-flex; color: var(--primary-light); }
.umenu-check svg { width: 13px; height: 13px; opacity: 1; }
.umenu-overlay { position: fixed; inset: 0; z-index: 199; }

/* ── Seletor de tema ── */
.theme-opts { display: flex; gap: 10px; }
.theme-opt {
    flex: 1; padding: 14px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--fill-2);
    cursor: pointer; text-align: center; transition: all var(--transition);
}
.theme-opt:hover { border-color: var(--border-hover); }
.theme-opt.selected { border-color: var(--primary); background: var(--primary-glow); }
.theme-opt-prev {
    height: 54px; border-radius: 8px; margin-bottom: 10px;
    border: 1px solid var(--border); overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between; padding: 6px;
}
.theme-opt-bar { height: 6px; border-radius: 3px; }
.theme-opt-name { font-size: 12px; font-weight: 600; color: var(--text-2); }
.theme-opt.selected .theme-opt-name { color: var(--primary-light); }

@media (min-width: 1200px) { .main { padding: 36px 52px; } }
@media (min-width: 1600px) { .main { padding: 40px 72px; } }
@media (min-width: 1920px) { .main { padding: 44px 96px; } }

/* ── Sidebar ── */
.brand { display: flex; flex-direction: column; align-items: center; padding: 24px 0 4px; gap: 8px; }
.brand-row { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; filter: drop-shadow(0 2px 8px rgba(99,102,241,0.3)); }
.brand-name { font-size: 16px; font-weight: 800; color: var(--text-1); letter-spacing: -0.3px; line-height: 1.2; }
.brand-tag { font-size: 9px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: 1.4px; }

.sep { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

.nav-label {
    font-size: 10px; font-weight: 700; color: var(--text-4);
    text-transform: uppercase; letter-spacing: 1.4px;
    padding: 16px 20px 8px; margin: 0;
}

.nav-btn {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    background: transparent; color: var(--text-3); border: none;
    border-left: 2px solid transparent;
    padding: 10px 20px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
}
.nav-btn svg { flex-shrink: 0; opacity: 0.6; }
.nav-btn:hover { background: var(--fill-3); color: var(--text-2); }
.nav-btn:hover svg { opacity: 1; }
.nav-btn.active {
    background: var(--primary-glow); color: var(--primary-light);
    font-weight: 600; border-left-color: var(--primary);
}
.nav-btn.active svg { opacity: 1; }

.nav-btn-cta {
    display: flex; align-items: center; gap: 10px; width: calc(100% - 32px);
    margin: 4px 16px 12px; padding: 12px 16px;
    background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius);
    font-size: 13px; font-weight: 700; cursor: pointer;
    transition: all var(--transition);
}
.nav-btn-cta:hover { background: var(--primary-hover); }
.nav-btn-cta svg { flex-shrink: 0; }

.sidebar-select-muted {
    width: calc(100% - 36px); margin: 0 18px; padding: 9px 12px;
    background: var(--fill-2); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-2); font-size: 12px;
    cursor: pointer; outline: none;
}
.sidebar-select-muted option { background: var(--surface); color: var(--text-2); }

.conn-grid { padding: 4px 20px 8px; }
.conn-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.conn-label { font-size: 11px; font-weight: 500; color: var(--text-4); }
.conn-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.conn-dot.on { background: var(--success); box-shadow: 0 0 8px rgba(16,185,129,0.5); }
.conn-dot.off { background: var(--text-4); }
.conn-val { font-size: 11px; font-weight: 600; }
.conn-val.on { color: var(--success); }
.conn-val.off { color: var(--text-4); }

/* ── Page header ── */
.sh { margin-bottom: 24px; }
.sh-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin: 0 0 4px; color: var(--text-1); }
.sh-desc { font-size: 13px; color: var(--text-3); margin: 0; font-weight: 400; }
@media (min-width: 1400px) {
    .sh-title { font-size: 26px; }
    .sh { margin-bottom: 28px; }
}

/* ── Tabs ── */
.tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.tab-btn {
    padding: 10px 20px; font-size: 13px; font-weight: 600;
    color: var(--text-3); background: none; border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer; transition: all var(--transition);
    position: relative;
}
.tab-btn:hover { color: var(--text-2); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary); }
.tab-badge { display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--primary);color:#fff;font-size:11px;font-weight:700;margin-left:4px;vertical-align:middle; }

/* ── KPI ── */
.kpi-grid { display: grid; gap: 14px; margin: 16px 0; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
@media (min-width: 900px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px 24px; position: relative; overflow: hidden;
    transition: all var(--transition); min-height: 96px;
}
.kpi:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-accent { position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.kpi-accent.indigo { background: linear-gradient(90deg, var(--primary-dark), var(--primary-light)); }
.kpi-accent.emerald { background: linear-gradient(90deg, #059669, var(--success)); }
.kpi-accent.amber { background: linear-gradient(90deg, #D97706, var(--warning)); }
.kpi-accent.rose { background: linear-gradient(90deg, #DC2626, var(--error)); }
.kpi-label { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 800; letter-spacing: -1.5px; line-height: 1; }
@media (min-width: 1400px) { .kpi-value { font-size: 36px; } .kpi { padding: 24px 28px; } }
.kpi-value.emerald { color: var(--success); }
.kpi-value.amber { color: var(--warning); }
.kpi-value.rose { color: var(--error); }

/* ── Filters bar ── */
.filters { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }

/* Barra de filtros com rotulo em cima de cada campo (aba Campanhas) */
.filtros-topo {
    display: flex; gap: 14px; margin-bottom: 16px; flex-wrap: wrap;
    align-items: flex-end;
    padding: 14px 16px; border-radius: var(--radius);
    background: var(--fill-1); border: 1px solid var(--border);
}
.filtro-campo { display: flex; flex-direction: column; gap: 6px; flex: 1 1 170px; min-width: 0; }
.filtro-rotulo { font-size: 12px; color: var(--text-3); font-weight: 500; }
.filtro-campo .filter-select, .filtro-campo .filter-input { width: 100%; }
.filtro-acoes { display: flex; align-items: center; gap: 12px; margin-left: auto; padding-bottom: 2px; }
.filtro-atualizado { font-size: 12px; color: var(--text-4); white-space: nowrap; }
@media (max-width: 700px) {
    .filtro-acoes { margin-left: 0; width: 100%; justify-content: space-between; }
}
.filter-select, .filter-input {
    padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-1); font-size: 13px; outline: none;
    transition: all var(--transition); min-height: 38px;
}
.filter-select:focus, .filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.filter-select:hover, .filter-input:hover { border-color: var(--border-hover); }
.filter-select { cursor: pointer; min-width: 150px; }
.filter-input { flex: 1; min-width: 180px; }
.filter-input::placeholder { color: var(--text-4); }
@media (min-width: 1400px) {
    .filters { gap: 14px; }
    .filter-select { min-width: 180px; }
    .filter-input { min-width: 240px; }
}

/* Calendario do periodo personalizado: um mes, clique abre e clique fecha o
   caminho. Abre embaixo do proprio seletor de periodo. */
.cal-ancora { position: relative; }
.cal-caixa {
    position: absolute; z-index: 60; top: 100%; left: 0; margin-top: 6px;
    width: 252px; max-width: calc(100vw - 32px); padding: 10px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.cal-caixa[hidden] { display: none; }
/* No celular o seletor fica na metade direita da tela: ancorado pela esquerda,
   o calendario saia pela borda. */
@media (max-width: 700px) {
    .cal-caixa { left: auto; right: 0; }
}
.cal-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-mes { font-size: 13px; font-weight: 600; color: var(--text-1); }
.cal-nav {
    width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 15px;
    background: var(--fill-3); border: 1px solid var(--border); color: var(--text-2);
}
.cal-nav:hover:not(:disabled) { background: var(--fill-5); color: var(--text-1); }
.cal-nav:disabled { opacity: 0.3; cursor: default; }
.cal-grade { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-sem { font-size: 11px; color: var(--text-3); text-align: center; padding: 4px 0; }
.cal-vazio { height: 28px; }
.cal-dia {
    height: 28px; border: 0; border-radius: 8px; cursor: pointer;
    background: transparent; color: var(--text-1); font-size: 12px; font-family: inherit;
}
.cal-dia:hover { background: var(--fill-4); }
.cal-dia:disabled { color: var(--text-4); cursor: default; background: transparent; }
.cal-dia.hoje { box-shadow: inset 0 0 0 1px var(--border-active); }
.cal-dia.entre { background: var(--primary-glow); color: var(--primary-light); }
.cal-dia.sel { background: var(--primary); color: #fff; font-weight: 600; }
.cal-rodape {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 8px; font-size: 12px; color: var(--text-3);
}
.cal-limpar {
    background: none; border: 0; padding: 4px; cursor: pointer;
    font-size: 12px; font-family: inherit; color: var(--text-2);
}
.cal-limpar:hover { color: var(--text-1); }

/* ── Buttons ── */
.btn {
    padding: 8px 20px; border: none; border-radius: var(--radius);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all var(--transition); display: inline-flex; align-items: center; gap: 6px;
    min-height: 38px; white-space: nowrap;
}
@media (min-width: 1400px) { .btn { padding: 10px 24px; } }
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white; box-shadow: 0 2px 12px var(--primary-glow-strong);
}
.btn-primary:hover { box-shadow: 0 4px 20px var(--primary-glow-strong); transform: translateY(-1px); }
.btn-secondary { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-1); background: var(--surface-3); }
.btn-danger { background: var(--error-glow); color: var(--error); border: 1px solid rgba(239,68,68,0.15); }
.btn-danger:hover { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.3); }
.btn-sm { padding: 5px 12px; font-size: 12px; min-height: 30px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Table ── */
.tbl-wrapper {
    width: 100%; overflow-x: auto; border-radius: var(--radius-lg);
    border: 1px solid var(--border); background: var(--surface); margin: 12px 0;
    box-shadow: var(--shadow-sm);
}
.tbl { width: 100%; border-collapse: collapse; min-width: 500px; }

/* Tabela larga (Campanhas tem 20 colunas): barra de rolagem visivel, coluna
   separada da vizinha e nada quebrando em duas linhas. */
.tbl-wrapper, .rolagem-x { padding-bottom: 2px; scrollbar-color: var(--fill-5) var(--fill-2); }
.tbl-wrapper::-webkit-scrollbar, .rolagem-x::-webkit-scrollbar { height: 12px; }
.tbl-wrapper::-webkit-scrollbar-track, .rolagem-x::-webkit-scrollbar-track {
    background: var(--fill-2); border-radius: 6px; margin: 0 8px;
}
.tbl-wrapper::-webkit-scrollbar-thumb, .rolagem-x::-webkit-scrollbar-thumb {
    background: var(--fill-5); border-radius: 6px; border: 3px solid var(--fill-2);
}
.tbl-wrapper::-webkit-scrollbar-thumb:hover,
.rolagem-x::-webkit-scrollbar-thumb:hover { background: var(--text-4); }
.tbl th, .tbl td { white-space: nowrap; }
.tbl th + th, .tbl td + td { border-left: 1px solid var(--fill-2); }
.tbl th { padding-left: 12px; padding-right: 12px; }
.tbl td { padding-left: 12px; padding-right: 12px; }
.tbl .cell-name {
    max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.tbl th {
    background: var(--fill-1); color: var(--text-3);
    padding: 12px 18px; text-align: left; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border);
    white-space: nowrap; user-select: none; position: sticky; top: 0; z-index: 1;
}
.tbl td {
    color: var(--text-2); padding: 10px 18px; font-size: 13px; font-weight: 500;
    border-bottom: 1px solid var(--fill-2);
}
@media (min-width: 1400px) {
    .tbl th { padding: 14px 22px; }
    .tbl td { padding: 12px 22px; }
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr { transition: background var(--transition); }
.tbl tr:hover td { background: var(--fill-2); }
.tbl tr.selected td { background: var(--primary-glow); }
.tbl .cell-name { color: var(--text-1); font-weight: 600; }
.tbl .cell-mono { font-family: 'SF Mono', 'Fira Code', monospace; color: var(--text-3); font-size: 12px; }

.tbl input[type="checkbox"] {
    width: 16px; height: 16px;
}
.tbl th input[type="checkbox"] { margin: 0; }

.sort-th, .sort-th-adset, .sort-th-ad { transition: color var(--transition); cursor: pointer; }
.sort-th:hover, .sort-th-adset:hover, .sort-th-ad:hover { color: var(--text-1); }
.sort-th.active, .sort-th-adset.active, .sort-th-ad.active { color: var(--primary-light); }

/* ── Pills ── */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 6px; font-size: 11px; font-weight: 600;
    letter-spacing: 0.2px; white-space: nowrap;
}
.pill-dot { width: 5px; height: 5px; border-radius: 50%; }
.pill-green { background: var(--success-glow); color: var(--success); border: 1px solid rgba(16,185,129,0.15); }
.pill-green .pill-dot { background: var(--success); box-shadow: 0 0 4px rgba(16,185,129,0.5); }
.pill-red { background: var(--error-glow); color: var(--error); border: 1px solid rgba(239,68,68,0.15); }
.pill-red .pill-dot { background: var(--error); }
.pill-yellow { background: var(--warning-glow); color: var(--warning); border: 1px solid rgba(245,158,11,0.15); }
.pill-yellow .pill-dot { background: var(--warning); }
.pill-blue { background: var(--primary-glow); color: var(--primary-light); border: 1px solid rgba(99,102,241,0.15); }
.pill-blue .pill-dot { background: var(--primary-light); }
.pill-gray { background: rgba(148,163,184,0.06); color: var(--text-2); border: 1px solid rgba(148,163,184,0.08); }
.pill-gray .pill-dot { background: var(--text-3); }

/* ── Config blocks ── */
.cfg-block {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px; margin: 14px 0; max-width: 860px;
    transition: border-color var(--transition);
}
.cfg-block:hover { border-color: var(--border-hover); }
.cfg-block h4 { font-size: 14px; font-weight: 700; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; color: var(--text-1); }
.cfg-block .cfg-desc { color: var(--text-3); font-size: 12px; margin: 0 0 18px; line-height: 1.5; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.6px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 9px 13px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-1); font-size: 13px; outline: none;
    transition: all var(--transition); min-height: 38px;
}
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--border-hover); }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-input::placeholder { color: var(--text-4); }
.form-textarea { resize: vertical; min-height: 80px; }
/* Calendario e relogio nativos: sem color-scheme o seletor do navegador abre
   branco em cima do tema escuro, e o texto da data fica ilegivel. */
input[type="date"], input[type="time"] { color-scheme: dark; cursor: pointer; }
[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="time"] { color-scheme: light; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Empty state ── */
.empty {
    text-align: center; padding: 56px 32px;
    background: var(--surface); border: 1px dashed var(--fill-4);
    border-radius: var(--radius-lg); margin: 16px 0; max-width: 560px;
}
.empty h3 { color: var(--text-2); font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.empty p { color: var(--text-4); font-size: 13px; margin: 0; }

/* ── Profile card (Perfis Facebook) ── */
.perfil-card {
    background: var(--surface); border: 1.5px dashed rgba(56,189,248,0.2);
    border-radius: var(--radius-lg); padding: 28px 32px; margin: 0 0 20px;
    max-width: 680px; transition: border-color var(--transition);
}
.perfil-card:hover { border-color: rgba(56,189,248,0.35); }
.perfil-card-header { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 24px; }
.perfil-avatar {
    width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    border: 2px solid var(--fill-5); overflow: hidden;
}
.perfil-avatar svg { width: 28px; height: 28px; color: var(--text-3); }
.perfil-name { font-size: 17px; font-weight: 700; color: var(--text-1); margin: 0 0 2px; }
.perfil-subname { font-size: 13px; color: var(--text-3); margin: 0; display: flex; align-items: center; gap: 6px; }
.perfil-subname svg { width: 14px; height: 14px; opacity: 0.7; }
.perfil-name-badges { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.perfil-badges { display: flex; gap: 8px; flex-shrink: 0; }
.badge-perfil {
    font-size: 11px; font-weight: 600; padding: 4px 12px; border-radius: 6px;
    background: rgba(6,182,212,0.12); color: #22D3EE; border: 1px solid rgba(6,182,212,0.2);
    display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.badge-perfil svg { width: 12px; height: 12px; }
.badge-emuso {
    font-size: 11px; font-weight: 600; padding: 4px 12px; border-radius: 6px;
    background: rgba(245,158,11,0.12); color: #FBBF24; border: 1px solid rgba(245,158,11,0.2);
    display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.badge-emuso svg { width: 12px; height: 12px; }
.perfil-stats { display: flex; gap: 24px; flex-wrap: wrap; }
.perfil-stat { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.perfil-stat svg { width: 14px; height: 14px; }
.perfil-stat-icon-red { color: #F87171; display: flex; }
.perfil-stat-icon-red svg { width: 14px; height: 14px; }
.perfil-stat-icon-blue { color: #60A5FA; display: flex; }
.perfil-stat-icon-blue svg { width: 14px; height: 14px; }
.perfil-stat-icon-pink { color: #F472B6; display: flex; }
.perfil-stat-icon-pink svg { width: 14px; height: 14px; }
.perfil-sync { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.perfil-sync svg { width: 13px; height: 13px; opacity: 0.7; }
.perfil-perms-label { font-size: 13px; color: var(--success); font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.perfil-perms-label svg { width: 14px; height: 14px; }
.perfil-perms { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.perm-tag {
    font-size: 11px; font-weight: 500; padding: 5px 14px; border-radius: 20px;
    background: rgba(16,185,129,0.1); color: #34D399; border: 1px solid rgba(16,185,129,0.15);
    display: inline-flex; align-items: center; gap: 5px;
}
.perm-tag svg { width: 11px; height: 11px; }
.perfil-proxy { display: flex; gap: 32px; margin-bottom: 24px; font-size: 13px; color: var(--text-3); }
.perfil-proxy-item { display: flex; align-items: center; gap: 8px; }
.perfil-proxy-item svg { width: 15px; height: 15px; opacity: 0.7; }
.perfil-actions { display: flex; gap: 10px; align-items: center; }
.perfil-actions .btn { min-width: 0; }
.perfil-actions .btn svg { width: 14px; height: 14px; }
.btn-icon-danger {
    width: 40px; height: 40px; border-radius: var(--radius); background: transparent;
    border: 1px solid var(--border); color: var(--error); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all var(--transition);
}
.btn-icon-danger:hover { background: var(--error-glow); border-color: rgba(239,68,68,0.3); }
.btn-icon-danger svg { width: 16px; height: 16px; }

/* ── View toggle (Cards/Lista) ── */
.view-toggle {
    display: inline-flex; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface);
}
.view-toggle-btn {
    padding: 7px 16px; font-size: 12px; font-weight: 600; cursor: pointer;
    background: transparent; border: none; color: var(--text-3);
    display: inline-flex; align-items: center; gap: 6px; transition: all var(--transition);
}
.view-toggle-btn:hover { color: var(--text-2); background: var(--surface-2); }
.view-toggle-btn.active { background: var(--surface-2); color: var(--text-1); }
.view-toggle-btn svg { width: 14px; height: 14px; }

/* ── File card ── */
.fcard {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px; margin: 8px 0;
    display: flex; justify-content: space-between; align-items: center;
    transition: all var(--transition);
}
.fcard:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
.fcard-name { color: var(--text-1); font-weight: 600; font-size: 14px; margin: 0 0 3px; }
.fcard-meta { color: var(--text-3); font-size: 12px; margin: 0; }

/* ── Dashboard ── */
.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.dash-stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; transition: all var(--transition);
}
.dash-stat:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
.dash-stat-label { font-size: 11px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.dash-stat-value { font-size: 28px; font-weight: 800; color: var(--text-1); line-height: 1.2; }
.dash-stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.dash-stat-warn { color: var(--warning); font-size: 12px; margin-top: 4px; }

.dash-row { display: grid; grid-template-columns: 1fr 380px; gap: 20px; margin-bottom: 24px; }
/* Item de grid nasce com min-width:auto e nao encolhe abaixo do proprio
   conteudo. Sem isto, uma linha de texto com nowrap (motivo da recusa no painel
   de Atencao Necessaria) esticava a coluna e a pagina inteira rolava na
   horizontal em tela menor. */
.dash-row > * { min-width: 0; }
.dash-grid > * { min-width: 0; }
.dash-panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px;
}
/* flex-wrap: o painel da direita tem 380px e o titulo com filtros nao cabia
   numa linha so — os botoes saiam da caixa em tela menor. */
.dash-panel-title { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* Altura propria, nao a do painel vizinho: com flex:1 o grafico esticava ate
   o fim da coluna de Atencao Necessaria e virava um paredao em tela grande. */
.dash-chart {
    display: flex; align-items: flex-end; gap: 2px; padding-top: 8px;
    flex: none; height: clamp(130px, 20vh, 210px);
}
.dash-chart-wrap { display: flex; flex-direction: column; flex: none; }
/* Coluna da esquerda: grafico em cima, Fila embaixo. Com o grafico sozinho, o
   card esticava ate a altura da coluna da direita e sobrava meia tela vazia. */
.dash-coluna-esq { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dash-panel-grafico { flex: none; }
.dash-chart-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-4); margin-top: 6px; padding: 0 2px; }
.dash-chart-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.dash-chart-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
/* ── VSL: retenção geral ──
   A curva é um SVG esticado pela largura do painel; os rótulos ficam em HTML
   por fora, senão o preserveAspectRatio="none" deformaria o texto junto. */
/* A calha da esquerda e a altura sao variaveis: o rotulo do Pitch e posicionado
   com elas no inline style, entao mexer no celular num lugar so mantem tudo
   alinhado. */
.vsl-graf { position: relative; padding-bottom: 26px; --vsl-calha: 48px; --vsl-altura: clamp(220px, 34vh, 340px); }
.vsl-graf-y {
    position: absolute; left: 0; top: 0; width: calc(var(--vsl-calha) - 4px);
    height: var(--vsl-altura);
    display: flex; flex-direction: column; justify-content: space-between;
    font-size: 11px; color: var(--text-4); text-align: right; padding-right: 8px;
}
.vsl-graf-plot {
    position: relative; margin-left: var(--vsl-calha);
    height: var(--vsl-altura);
    background: #05060a; border-radius: 8px; overflow: hidden;
}
.vsl-graf-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.vsl-graf-linha { position: absolute; left: 0; right: 0; height: 1px; background: rgba(255,255,255,0.10); }
.vsl-graf-pitch {
    position: absolute; top: 0; bottom: 0; width: 0;
    border-left: 1px dashed rgba(255,255,255,0.6);
}
.vsl-graf-x {
    margin-left: var(--vsl-calha); margin-top: 6px; display: flex; justify-content: space-between;
    font-size: 11px; color: var(--text-4);
}
.vsl-graf-pitch-rotulo {
    position: absolute; bottom: 0; transform: translateX(-50%);
    font-size: 11px; font-weight: 700; color: var(--text-2); white-space: nowrap;
}

/* Seletor de moeda: dropdown proprio porque <option> nao aceita imagem, e o
   emoji de bandeira nao e desenhado no Windows. */
.vsl-moeda { position: relative; }
.vsl-moeda-btn, .vsl-moeda-item {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-1); font-size: 13px; font-weight: 600; padding: 7px 12px;
    cursor: pointer; width: 100%; transition: border-color var(--transition);
}
.vsl-moeda-btn:hover, .vsl-moeda-item:hover { border-color: var(--border-hover); }
.vsl-moeda-btn svg:last-child { margin-left: auto; color: var(--text-4); }
.vsl-moeda-lista {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
    min-width: 120px; display: flex; flex-direction: column; gap: 4px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow-md);
}
/* O display: flex da classe vencia o [hidden] do navegador: a lista ficava
   sempre aberta, com as tres moedas a mostra. */
.vsl-moeda-lista[hidden] { display: none; }
.vsl-moeda-item { background: transparent; border-color: transparent; }
.vsl-moeda-item.ativa { background: var(--primary-glow); color: var(--primary-light); }

.vsl-metricas { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.vsl-metrica {
    background: var(--fill-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; min-width: 0;
}
.vsl-metrica-valor {
    font-size: 20px; font-weight: 700; color: var(--text-1);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vsl-metrica-rotulo { font-size: 12px; color: var(--text-3); margin-top: 4px; }
@media (max-width: 1200px) { .vsl-metricas { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px) { .vsl-metricas { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) {
    .vsl-metricas { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .vsl-metrica { padding: 10px; }
    .vsl-metrica-valor { font-size: 17px; }
    /* Calha menor e gráfico mais baixo: no celular a curva ainda se lê, e
       sobra tela para os cartões logo abaixo. */
    .vsl-graf { --vsl-calha: 32px; --vsl-altura: clamp(170px, 28vh, 240px); padding-bottom: 22px; }
    .vsl-graf-y, .vsl-graf-x, .vsl-graf-pitch-rotulo { font-size: 10px; }
    .vsl-graf-y { padding-right: 5px; }
    /* Nome de VSL é longo: no celular o seletor ocupa a linha inteira. */
    .filtro-largo { flex: 1 1 100% !important; }
}

/* ── VSL: Teste A/B ── */
.vsl-tabs { display: flex; gap: 0; margin-bottom: 16px; }
.vsl-tab {
    padding: 8px 20px; font-size: 13px; font-weight: 600;
    border: 1px solid var(--border); cursor: pointer;
    color: var(--text-3); background: transparent;
    transition: all var(--transition);
}
.vsl-tab:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.vsl-tab:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.vsl-tab:not(:first-child) { border-left: none; }
.vsl-tab-ativa { background: var(--fill-2); color: var(--text-1); border-color: var(--primary); }

.vsl-ab-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.vsl-ab-card {
    background: var(--fill-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; cursor: pointer;
    transition: border-color var(--transition);
}
.vsl-ab-card:hover { border-color: var(--primary); }
.vsl-ab-card-nome { font-size: 15px; font-weight: 700; color: var(--text-1); }
.vsl-ab-card-info { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.vsl-ab-card-status {
    display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 10px; margin-top: 8px;
}
.vsl-ab-card-status.running { background: rgba(34,197,94,0.15); color: #22C55E; }
.vsl-ab-card-status.paused { background: rgba(250,204,21,0.15); color: #FACC15; }

.vsl-ab-tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
.vsl-ab-tabela th {
    text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.vsl-ab-tabela td {
    padding: 12px 10px; border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    color: var(--text-1); white-space: nowrap;
}
.vsl-ab-tabela tr:hover td { background: var(--fill-2); }
.vsl-ab-cor {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    vertical-align: middle; margin-right: 8px;
}
.vsl-ab-nome { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.vsl-ab-voltar {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-3);
    background: none; border: none; cursor: pointer; padding: 0; margin-bottom: 12px;
}
.vsl-ab-voltar:hover { color: var(--text-1); }

@media (max-width: 700px) {
    .vsl-ab-tabela { font-size: 12px; }
    .vsl-ab-tabela th, .vsl-ab-tabela td { padding: 8px 6px; }
    .vsl-ab-nome { max-width: 160px; }
    .vsl-ab-cards { grid-template-columns: 1fr; }
}

/* Funil de conversao: o desenho e um SVG esticado pela largura do painel e as
   cinco colunas sao uma grade por cima dele, para o texto nao distorcer junto.
   No celular o funil rola de lado em vez de espremer cinco etapas. */
.funil-h { overflow-x: auto; }
.funil-v { display: none; }
.funil { min-width: 520px; }
.funil-linha { display: grid; grid-template-columns: repeat(5, 1fr); }
.funil-col { text-align: center; }
.funil-topo .funil-col { font-size: 13px; font-weight: 700; color: var(--text-2); padding-bottom: 10px; }
.funil-base .funil-col { font-size: 14px; font-weight: 700; color: var(--text-2); padding-top: 10px; }
.funil-corpo { position: relative; height: clamp(170px, 26vh, 260px); }
.funil-svg { display: block; width: 100%; height: 100%; }
.funil-pct {
    position: absolute; inset: 0; align-items: center; pointer-events: none;
}
.funil-pct .funil-col {
    font-size: 17px; font-weight: 800; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}
/* Divisoria entre as etapas, do topo ao rodape do desenho. */
.funil-corpo .funil-col + .funil-col { box-shadow: inset 1px 0 0 var(--border-hover); }
.funil-corpo .funil-col { height: 100%; display: flex; align-items: center; justify-content: center; }

/* Funil deitado, so no celular: uma faixa por etapa, nome a esquerda, % no
   meio do desenho e quantidade a direita. */
.funil-v { position: relative; height: 420px; }
.funil-svg-v { display: block; width: 100%; height: 100%; }
.funil-v-linhas { position: absolute; inset: 0; display: grid; grid-template-rows: repeat(5, 1fr); }
.funil-v-faixa {
    position: relative;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 10px; gap: 8px;
}
.funil-v-faixa + .funil-v-faixa { box-shadow: inset 0 1px 0 var(--border-hover); }
.funil-v-nome, .funil-v-qtd { font-size: 12px; font-weight: 700; color: var(--text-2); }
/* A porcentagem fica no eixo do desenho, que e o meio do SVG. Com o flex de
   space-between ela seguia a largura do nome e saia do centro. */
.funil-v-pct {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    font-size: 16px; font-weight: 800; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
@media (max-width: 700px) {
    .funil-h { display: none; }
    .funil-v { display: block; }
}

/* Resumo: produto e fonte lado a lado no desktop, empilhados no celular. */
.resumo-duplo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) {
    .resumo-duplo { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
}

/* Comissao: a tira no alto do Resumo e o popup do mes dia a dia. */
.com-tira {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer;
    margin-bottom: 12px; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--fill-2); font-size: 13px;
    transition: border-color var(--transition);
}
.com-tira:hover { border-color: var(--border-hover); }
.com-tira-nome { font-weight: 600; }
.com-tira-mes { color: var(--text-4); }
.com-tira-num { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.com-tira-fim { margin-left: auto; color: var(--text-4); font-size: 12px; }
/* Dentro do popup o painel ja esta numa caixa: a margem de baixo e do modal. */
.com-painel { margin-bottom: 0; }
.com-kpis { margin-bottom: 12px; }

@media (max-width: 700px) {
    /* Duas linhas: identificacao em cima, numeros embaixo. O "ver detalhe"
       sai — no toque a tira inteira ja e o botao. */
    .com-tira { gap: 4px 8px; padding: 10px 12px; font-size: 12px; }
    .com-tira-fim { display: none; }
    .com-tira-num { flex-basis: 100%; }
    /* Seis cartoes de largura inteira empurravam a tabela para fora da tela.
       Seletor duplo: mais abaixo .dash-grid vira uma coluna no celular. */
    .dash-grid.com-kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
    .com-kpis .dash-stat { padding: 10px; }
    .com-kpis .dash-stat-label { margin-bottom: 4px; font-size: 10px; }
    .com-kpis .dash-stat-value { font-size: 17px; }
    .com-kpis .dash-stat-sub { font-size: 10px; }
    /* Caixa dentro de caixa come a largura util; a tabela rola sozinha.
       Dois seletores para ganhar do .modal { padding: 20px } mais abaixo. */
    .modal.com-modal-box { padding: 14px; }
    .com-modal-box .com-painel { padding: 0; border: none; background: transparent; }
    /* 340px e o que sobra da largura util num celular de 390: assim Gasto,
       Recebido e Lucro aparecem sem rolar, e so o ROAS fica para o lado. */
    .com-modal-box .tbl { min-width: 340px; }
    /* Estorno quase sempre e "---" e empurrava Lucro e ROAS para fora da
       rolagem; no celular eles valem mais que ele. O total fica nos cartoes. */
    .com-col-estorno { display: none; }
    .com-modal-box .tbl th, .com-modal-box .tbl td {
        padding-left: 6px; padding-right: 6px; font-size: 12px;
    }
}
.dash-bar { background: var(--primary); border-radius: 3px 3px 0 0; min-width: 4px; flex: 1; transition: height 0.3s; cursor: pointer; position: relative; }
.dash-bar:hover { background: var(--primary-light); }
.dash-bar-tip {
    display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
    font-size: 11px; white-space: nowrap; z-index: 10; color: var(--text-2); margin-bottom: 4px;
}
.dash-bar:hover .dash-bar-tip { display: block; }

.dash-filter { display: flex; gap: 4px; flex-wrap: wrap; }
.dash-filter-btn {
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    padding: 4px 12px; font-size: 11px; color: var(--text-3); cursor: pointer; transition: all var(--transition);
}
.dash-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.dash-filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.dash-alert {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 8px;
    background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.15); border-radius: var(--radius);
}
.dash-alert-icon { width: 32px; height: 32px; border-radius: 8px; background: rgba(239,68,68,0.1); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.dash-activity {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 8px;
    background: var(--fill-2); border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all var(--transition);
}
.dash-activity:hover { border-color: var(--border-hover); }
.dash-activity-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dash-activity-icon.success { background: rgba(16,185,129,0.15); color: var(--success); }
.dash-activity-icon.error { background: rgba(239,68,68,0.15); color: var(--error); }

.dash-queue-card {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px;
    margin-bottom: 12px; background: var(--surface); transition: all var(--transition);
}
.dash-queue-card:hover { border-color: var(--border-hover); }

.dash-q-action {
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    color: var(--text-4); cursor: pointer; transition: all var(--transition); padding: 0;
}
.dash-q-action:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }
.dash-q-action-danger:hover { border-color: var(--error); color: var(--error); background: rgba(239,68,68,0.06); }
.dash-q-expand { transition: transform 0.2s, border-color 0.15s, color 0.15s; }
.dash-queue-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.dash-queue-progress { height: 8px; background: var(--fill-4); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.dash-queue-progress-fill { height: 100%; border-radius: 4px; transition: width 0.4s; }

.dash-pages { display: flex; align-items: center; gap: 4px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.dash-page-btn {
    width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; color: var(--text-3); font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all var(--transition);
}
.dash-page-btn:hover { border-color: var(--primary); color: var(--primary); }
.dash-page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-row { grid-template-columns: 1fr; }
}

/* Abaixo disso duas colunas de estatistica ja espremem o numero, e o padrao de
   20px de padding come a largura util do painel. */
@media (max-width: 700px) {
    .dash-grid { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
    .dash-row { gap: 12px; margin-bottom: 16px; }
    .dash-panel { padding: 14px; }
    .dash-stat { padding: 16px; }
    .dash-stat-value { font-size: 24px; }
    .dash-alert { padding: 10px 12px; gap: 8px; }
    .dash-alert-icon { width: 28px; height: 28px; }
    .dash-activity { padding: 10px 12px; gap: 8px; }
    .dash-queue-card { padding: 12px 14px; }
    .dash-page-btn { width: 28px; height: 28px; }
}

/* ── Queue Detail Panel ── */
.q-panel-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 900;
    opacity: 0; transition: opacity 0.25s;
}
.q-panel-overlay.visible { opacity: 1; }

.q-panel {
    position: fixed; top: 0; right: -520px; bottom: 0; width: 500px;
    background: var(--bg); border-left: 1px solid var(--border);
    z-index: 901; overflow-y: auto; transition: right 0.3s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,0.3);
}
.q-panel.visible { right: 0; }

.q-panel-close {
    position: absolute; top: 16px; right: 16px;
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    color: var(--text-3); cursor: pointer; transition: all var(--transition); z-index: 2;
}
.q-panel-close:hover { border-color: var(--error); color: var(--error); }

.q-panel-header { padding: 24px 24px 16px; border-bottom: 1px solid var(--border); }
.q-panel-title { font-size: 16px; font-weight: 700; color: var(--text-1); margin-bottom: 8px; padding-right: 40px; line-height: 1.4; }
.q-panel-id { font-size: 11px; font-family: monospace; color: var(--text-4); margin-bottom: 12px; }
.q-panel-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; margin-bottom: 8px; }
.q-panel-badge { padding: 3px 12px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.q-panel-badge.success { background: rgba(16,185,129,0.15); color: var(--success); }
.q-panel-badge.error { background: rgba(239,68,68,0.15); color: var(--error); }
.q-panel-info { font-size: 12px; color: var(--text-3); line-height: 1.6; margin-top: 8px; }
.q-panel-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.q-panel-tag { padding: 2px 10px; border-radius: 8px; font-size: 11px; font-weight: 500; background: rgba(99,102,241,0.1); color: var(--primary-light); }

.q-panel-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 24px; }
.q-panel-tab {
    padding: 12px 16px; font-size: 13px; font-weight: 500; color: var(--text-4);
    cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--transition);
    background: transparent; border-top: none; border-left: none; border-right: none;
}
.q-panel-tab:hover { color: var(--text-2); }
.q-panel-tab.active { color: var(--primary-light); border-bottom-color: var(--primary); font-weight: 600; }

.q-panel-body { padding: 20px 24px; }

.q-panel-section { margin-bottom: 20px; }
.q-panel-section-title { font-size: 11px; font-weight: 700; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

.q-panel-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--fill-3); font-size: 13px; }
.q-panel-row-label { color: var(--text-4); }
.q-panel-row-value { color: var(--text-1); font-weight: 500; }

.q-panel-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.q-panel-stat { background: var(--fill-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.q-panel-stat-val { font-size: 18px; font-weight: 800; color: var(--text-1); }
.q-panel-stat-label { font-size: 11px; color: var(--text-4); margin-top: 2px; }

.q-panel-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.q-panel-table th { text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 600; color: var(--text-4); border-bottom: 1px solid var(--border); }
.q-panel-table td { padding: 8px 10px; color: var(--text-2); border-bottom: 1px solid var(--fill-3); }

.q-panel-item {
    padding: 10px 12px; margin-bottom: 6px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--fill-2);
    font-size: 12px;
}
.q-panel-item-type { font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; margin-right: 6px; }
.q-panel-item-type.ad { background: rgba(99,102,241,0.15); color: var(--primary-light); }
.q-panel-item-type.adset { background: rgba(245,158,11,0.15); color: var(--warning); }
.q-panel-item-type.campaign { background: rgba(16,185,129,0.15); color: var(--success); }

.q-panel-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ── Stepper ── */
.stepper-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stepper-header-left { font-size: 13px; color: var(--text-3); }
.stepper-header-right { display: flex; align-items: center; gap: 10px; }
.stepper-pct { font-size: 13px; font-weight: 700; color: var(--primary-light); }

.stepper { display: flex; align-items: center; justify-content: center; padding: 16px 0 24px; gap: 0; }
.stepper-step { display: flex; flex-direction: column; align-items: center; position: relative; z-index: 1; cursor: pointer; }
.stepper-step.future { cursor: default; }
.stepper-circle {
    width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; transition: all 0.25s;
    border: 2px solid var(--border);
    background: transparent; color: var(--text-4);
}
.stepper-step.completed .stepper-circle { background: var(--success); border-color: var(--success); color: #fff; }
.stepper-step.active .stepper-circle { background: var(--primary); border-color: var(--primary); color: #fff; }
.stepper-label { font-size: 11px; font-weight: 500; color: var(--text-4); margin-top: 6px; transition: color 0.2s; }
.stepper-step.active .stepper-label { color: var(--primary-light); font-weight: 600; }
.stepper-step.completed .stepper-label { color: var(--success); }

.stepper-line { flex: 1; height: 3px; background: var(--border); transition: background 0.3s; margin: 0 -2px; margin-bottom: 18px; }
.stepper-line.done { background: var(--success); }

.stepper-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; }
.stepper-main { min-width: 0; }
.stepper-sidebar {
    position: sticky; top: 20px; align-self: start;
}
.stepper-sidebar-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; margin-bottom: 16px;
}
.stepper-sidebar-title { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 12px; }
.stepper-sidebar-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 12px; border-bottom: 1px solid var(--fill-3); }
.stepper-sidebar-row-label { color: var(--text-4); }
.stepper-sidebar-row-value { color: var(--text-1); font-weight: 600; }
.stepper-sidebar-row-value.highlight { color: var(--primary-light); }
.stepper-sidebar-row-value.warn { color: var(--error); }

.stepper-creative-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px;
    font-size: 12px;
}
.stepper-creative-thumb { width: 40px; height: 40px; border-radius: 6px; background: var(--fill-4); object-fit: cover; }
.stepper-creative-name { color: var(--text-2); font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper-creative-meta { font-size: 10px; color: var(--text-4); }

.stepper-nav { display: flex; align-items: center; gap: 10px; padding: 16px 0; }
.stepper-nav-spacer { flex: 1; }

@media (max-width: 1000px) {
    .stepper-layout { grid-template-columns: 1fr; }
    .stepper-sidebar { position: static; }
}

/* ── Campaign Step 2 ── */
.camp-section-title { font-size: 11px; font-weight: 700; color: var(--text-4); text-transform: uppercase; letter-spacing: 1px; margin: 24px 0 12px; }
.camp-accounts-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); min-height: 44px; cursor: pointer; }
.camp-chip { display: flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 16px; font-size: 12px; font-weight: 500; background: var(--primary-glow); color: var(--primary-light); border: 1px solid rgba(99,102,241,0.2); }
.camp-chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.camp-chip-remove { cursor: pointer; opacity: 0.6; transition: opacity 0.15s; }
.camp-chip-remove:hover { opacity: 1; }

.camp-alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); margin: 10px 0; font-size: 12px; }
.camp-alert-warn { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2); color: var(--warning); }
.camp-alert-info { background: rgba(99,102,241,0.06); border: 1px solid rgba(99,102,241,0.15); color: var(--primary-light); }

.camp-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.camp-type-card {
    padding: 16px; border: 2px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all 0.2s; text-align: center;
}
.camp-type-card:hover { border-color: rgba(99,102,241,0.3); }
.camp-type-card.active { border-color: var(--primary); background: var(--primary-glow); }
.camp-type-card-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.camp-type-card-desc { font-size: 11px; color: var(--text-4); margin-top: 2px; }
.camp-type-card-badge { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 9px; font-weight: 600; background: rgba(16,185,129,0.15); color: var(--success); margin-top: 4px; }

.camp-bid-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.camp-bid-card {
    padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all 0.2s; font-size: 13px; color: var(--text-2);
}
.camp-bid-card:hover { border-color: rgba(99,102,241,0.3); }
.camp-bid-card.active { border-color: var(--primary); background: var(--primary-glow); color: var(--primary-light); }

.camp-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-radius: var(--radius); margin: 10px 0;
    transition: all 0.2s;
}
.camp-toggle-row.paused { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2); }
.camp-toggle-row.active-pub { background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.2); }
.camp-toggle-label { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.camp-toggle {
    position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer;
}
.camp-toggle input { display: none; }
.camp-toggle-track {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 12px; transition: 0.3s;
}
.camp-toggle-thumb {
    position: absolute; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: 0.3s;
}

.camp-catalog-tabs { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 10px 0; }
.camp-catalog-tab {
    flex: 1; padding: 10px; text-align: center; font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.2s; color: var(--text-3); border-right: 1px solid var(--border);
}
.camp-catalog-tab:last-child { border-right: none; }
.camp-catalog-tab.active { background: var(--primary-glow); color: var(--primary-light); }

.camp-tooltip { position: relative; display: inline-flex; align-items: center; cursor: help; }
.camp-tooltip-text {
    display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; font-size: 11px; color: var(--text-2); line-height: 1.5;
    width: 280px; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,0.3); margin-bottom: 6px;
}
.camp-tooltip:hover .camp-tooltip-text { display: block; }

/* ── Confirm Modal ── */
.confirm-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.confirm-overlay.visible { opacity: 1; }
.confirm-modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 28px; max-width: 420px; width: 90%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}
.confirm-title { font-size: 16px; font-weight: 700; color: var(--text-1); margin-bottom: 12px; }
.confirm-msg { font-size: 13px; color: var(--text-3); line-height: 1.6; margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Toast ── */
.toast {
    position: fixed; top: 20px; right: 20px; z-index: 10000;
    padding: 12px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
    animation: slideIn 0.3s ease; max-width: 400px;
    backdrop-filter: blur(12px); box-shadow: var(--shadow-lg);
}
.toast-success { background: rgba(16,185,129,0.12); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.toast-error { background: rgba(239,68,68,0.12); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.toast-info { background: rgba(99,102,241,0.12); color: var(--primary-light); border: 1px solid rgba(99,102,241,0.2); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Selection bar ── */
.selection-bar {
    background: var(--primary-glow); border: 1px solid rgba(99,102,241,0.15);
    border-radius: var(--radius); padding: 12px 18px; margin: 12px 0;
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
}
.selection-info { font-size: 13px; color: var(--primary-light); font-weight: 600; }

/* ── Loading ── */
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid var(--fill-5); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
    display: flex; align-items: center; justify-content: center;
    padding: 40px; color: var(--text-3); gap: 10px; font-size: 13px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fill-4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--fill-5); }

/* ── Desktop large ── */
@media (min-width: 1200px) {
    .sep { margin: 14px 0; }
    .cfg-block { padding: 28px; }
    .tabs { gap: 4px; }
    .tab-btn { padding: 12px 22px; font-size: 13px; }
    .selection-bar { padding: 14px 20px; }
}

@media (min-width: 1600px) {
    .tbl { min-width: 700px; }
    .empty { padding: 72px 48px; }
}

/* ── Menu de gaveta (telas estreitas) ── */
.btn-menu {
    display: none; align-items: center; justify-content: center;
    width: 36px; height: 36px; margin-right: auto;
    background: none; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-2); cursor: pointer; flex-shrink: 0;
}
.sidebar-fundo {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, .5); z-index: 99;
}
.sidebar-fundo.aberto { display: block; }

/* ── Responsive small ── */
@media (max-width: 900px) {
    .btn-menu { display: flex; }
    /* A barra vira gaveta: sai da tela e volta pelo botao de menu. Antes era
       display:none e nao havia como chegar na navegacao. */
    .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
    .sidebar.aberta { transform: none; }
    .topbar { margin-left: 0; padding: 0 16px; }
    .main { margin-left: 0; padding: 16px; max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .filters { flex-direction: column; }
    .filter-select, .filter-input { width: 100%; min-width: unset; }
    .modal--tutorial { padding: 20px; }
    .dropdown-add-perfil-menu { min-width: 200px; }
}

/* ── Wizard Tabs ── */
.wizard-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; gap: 0; }
.wizard-tab {
    padding: 10px 20px; font-size: 13px; font-weight: 500; color: var(--text-3);
    cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: all var(--transition); background: none; border-top: none; border-left: none; border-right: none;
}
.wizard-tab:hover { color: var(--text-2); }
.wizard-tab.active { color: var(--primary-light); border-bottom-color: var(--primary); font-weight: 600; }
.wizard-tab .badge {
    background: var(--surface-2); color: var(--text-3); font-size: 10px;
    padding: 1px 7px; border-radius: 10px; margin-left: 6px;
}
.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

/* ── Collapsible Cards ── */
.adset-card, .ad-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; transition: border-color var(--transition); }
.adset-card:hover, .ad-card:hover { border-color: var(--border-hover); }
.adset-card-header, .ad-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: var(--surface); cursor: pointer;
    transition: background var(--transition);
}
.adset-card-header:hover, .ad-card-header:hover { background: var(--surface-2); }
.adset-card-body, .ad-card-body { padding: 14px; display: none; background: var(--bg); }
.adset-card.open .adset-card-body, .ad-card.open .ad-card-body { display: block; }
.card-actions { display: flex; gap: 6px; }
.card-actions button { padding: 4px 8px; font-size: 11px; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
    padding: 28px; width: 480px; max-width: 92vw; max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(0,0,0,0.5);
    animation: modalIn 0.2s ease;
}
.modal h3 { margin: 0 0 16px; color: var(--text-1); font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Cabecalho, rodape e o botao de fechar: as classes eram usadas no JS mas
   nunca tiveram estilo — o "x" saia cru, colado no titulo. */
.modal-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; margin-bottom: 16px;
}
.modal-header h3 { margin: 0; }
.modal-close {
    width: 32px; height: 32px; flex-shrink: 0; margin-left: auto;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent; border-radius: 8px;
    color: var(--text-4); font-size: 20px; line-height: 1; cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.modal-close:hover { background: var(--fill-3); color: var(--text-1); border-color: var(--border); }
.modal-close:active { transform: scale(0.94); }
.modal-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.modal-footer {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* -- Dropdown Adicionar Perfil -- */
.dropdown-add-perfil {
    position: relative; display: inline-block;
}
.dropdown-add-perfil-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--surface-2); border: 1px solid var(--border-hover);
    border-radius: var(--radius); min-width: 220px; z-index: 100;
    box-shadow: var(--shadow-lg); animation: modalIn 0.15s ease;
    overflow: hidden;
}
.dropdown-add-perfil-menu.open { display: block; }
.dropdown-add-perfil-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; font-size: 13px; color: var(--text-2);
    cursor: pointer; transition: background var(--transition), color var(--transition);
    border: none; background: none; width: 100%; text-align: left;
}
.dropdown-add-perfil-item:hover {
    background: var(--primary-glow); color: var(--text-1);
}
.dropdown-add-perfil-item + .dropdown-add-perfil-item {
    border-top: 1px solid var(--border);
}

/* -- Modal Tutorial Onboarding -- */
.modal--tutorial { width: 720px; }
.onboarding-subtitle {
    font-size: 14px; color: var(--text-3); margin-bottom: 28px; line-height: 1.5;
}
.onboarding-step {
    display: flex; gap: 16px; padding: 24px 0;
    border-bottom: 1px solid var(--border);
}
.onboarding-step:last-child { border-bottom: none; }
.onboarding-step-number {
    width: 32px; height: 32px; flex-shrink: 0;
    background: var(--primary); color: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; margin-top: 2px;
}
.onboarding-step-title {
    font-size: 15px; font-weight: 700; color: var(--text-1); margin-bottom: 8px;
}
.onboarding-step-body {
    font-size: 13px; color: var(--text-2); line-height: 1.7;
}
.onboarding-step-body a {
    color: var(--primary-light); text-decoration: none;
}
.onboarding-step-body a:hover { text-decoration: underline; }
.onboarding-step-body code {
    background: var(--surface-3); padding: 2px 8px; border-radius: 6px;
    font-size: 12px; font-family: monospace; color: var(--text-1);
    user-select: all;
}
.onboarding-step-body ul {
    margin: 8px 0 0 0; padding-left: 18px;
}
.onboarding-step-body li {
    margin-bottom: 4px;
}

@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Profile Wizard Modal ── */
.pf-modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
    width: 860px; max-width: 94vw; max-height: 88vh; overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(0,0,0,0.5);
    animation: modalIn 0.2s ease; display: flex;
}
.pf-sidebar {
    width: 240px; min-width: 240px; padding: 28px 24px;
    border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px;
}
.pf-sidebar-title { font-size: 16px; font-weight: 700; color: var(--text-1); margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.pf-sidebar-title svg { width: 20px; height: 20px; flex-shrink: 0; }
.pf-sidebar-desc { font-size: 12px; color: var(--text-3); margin: 0 0 20px; }
.pf-step {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    border-radius: var(--radius); font-size: 13px; font-weight: 500;
    color: var(--text-3); cursor: pointer; transition: all var(--transition); position: relative;
}
.pf-step::after {
    content: ''; position: absolute; left: 23px; top: 100%; width: 2px; height: 8px;
    background: var(--border);
}
.pf-step:last-child::after { display: none; }
.pf-step.active { background: rgba(56,189,248,0.08); color: var(--primary); }
.pf-step.done { color: var(--success); }
.pf-step-icon {
    width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--border); font-size: 12px; font-weight: 700; flex-shrink: 0;
    transition: all var(--transition);
}
.pf-step-icon svg { width: 14px; height: 14px; max-width: 14px; max-height: 14px; }
.pf-step.active .pf-step-icon { border-color: var(--primary); background: rgba(56,189,248,0.1); color: var(--primary); }
.pf-step.done .pf-step-icon { border-color: var(--success); background: rgba(16,185,129,0.1); color: var(--success); }
.pf-step-label { line-height: 1.2; }
.pf-step-sublabel { font-size: 11px; color: var(--text-4); font-weight: 400; }
.pf-modal svg { flex-shrink: 0; }
.pf-content {
    flex: 1; min-width: 0; padding: 28px 32px; overflow-y: auto;
    display: flex; flex-direction: column;
}
.pf-content svg { max-width: 20px; max-height: 20px; }
.pf-content-title { font-size: 17px; font-weight: 700; color: var(--text-1); margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.pf-content-title svg { width: 20px; height: 20px; flex-shrink: 0; }
.pf-content-desc { font-size: 13px; color: var(--text-3); margin: 0 0 24px; }
.pf-close {
    position: absolute; right: 16px; top: 16px; width: 32px; height: 32px;
    border-radius: 50%; border: 1px solid var(--border); background: transparent;
    color: var(--text-3); cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition); z-index: 2; font-size: 16px;
}
.pf-close:hover { background: var(--surface-2); color: var(--text-1); }
.pf-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 20px; margin-top: auto; border-top: 1px solid var(--border);
}
.pf-footer svg { width: 14px; height: 14px; max-width: 14px; max-height: 14px; }
.pf-sidebar svg { max-width: 20px; max-height: 20px; }
.pf-option-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.pf-option-card {
    flex: 1; min-width: 160px; padding: 18px; border-radius: var(--radius-lg);
    border: 2px solid var(--border); background: transparent; cursor: pointer;
    transition: all var(--transition); text-align: left;
}
.pf-option-card:hover { border-color: var(--border-hover); background: var(--surface-2); }
.pf-option-card.selected { border-color: var(--primary); background: rgba(56,189,248,0.06); }
.pf-option-card.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.pf-option-card-title { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.pf-option-card-badge {
    font-size: 9px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.pf-option-card-badge.rec { background: rgba(56,189,248,0.15); color: var(--primary); }
.pf-option-card-badge.adv { background: rgba(245,158,11,0.15); color: #FBBF24; }
.pf-option-card-badge.soon { background: var(--fill-4); color: var(--text-4); }
.pf-option-card-desc { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.4; }
.pf-option-card-icon { width: 32px; height: 32px; color: var(--text-3); margin-bottom: 8px; }
.pf-option-card-icon svg { width: 32px; height: 32px; max-width: 32px; max-height: 32px; }
.pf-option-card.selected .pf-option-card-icon { color: var(--primary); }

/* App card dentro do wizard editar */
.pf-app-card {
    padding: 16px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--fill-2); transition: all var(--transition); overflow: hidden;
}
.pf-app-card svg { flex-shrink: 0; }
.pf-app-card:hover { border-color: var(--border-hover); }
.pf-app-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pf-app-header svg { max-width: 14px; max-height: 14px; }
.pf-app-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
.pf-app-badges { display: flex; gap: 6px; align-items: center; }
.pf-app-badge {
    font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
    display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
}
.pf-app-badge svg { width: 10px; height: 10px; max-width: 10px; max-height: 10px; }
.pf-app-badge.app { background: rgba(56,189,248,0.12); color: #38BDF8; }
.pf-app-badge.default { background: rgba(245,158,11,0.12); color: #FBBF24; }
.pf-app-badge.ok { background: rgba(16,185,129,0.12); color: #34D399; }
.pf-app-badge.expired { background: rgba(239,68,68,0.12); color: #F87171; }
.pf-app-actions { display: flex; gap: 6px; align-items: center; }
.pf-app-btn {
    width: 30px; height: 30px; border-radius: var(--radius); border: 1px solid var(--border);
    background: transparent; color: var(--text-3); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all var(--transition);
}
.pf-app-btn:hover { background: var(--surface-2); color: var(--text-1); }
.pf-app-btn.danger:hover { background: var(--error-glow); color: var(--error); border-color: rgba(239,68,68,0.3); }
.pf-app-btn svg { width: 14px; height: 14px; }
.pf-app-meta { font-size: 12px; color: var(--text-4); margin-top: 4px; }

/* Permissions multi-select */
.pf-perms-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.pf-perm-tag {
    font-size: 11px; padding: 4px 10px; border-radius: 14px; cursor: pointer;
    border: 1px solid var(--border); background: transparent; color: var(--text-3);
    display: inline-flex; align-items: center; gap: 4px; transition: all var(--transition);
}
.pf-perm-tag.active {
    background: rgba(56,189,248,0.1); color: var(--primary); border-color: rgba(56,189,248,0.3);
}
.pf-perm-tag svg { width: 11px; height: 11px; }

/* Tutorial box */
.pf-tutorial {
    padding: 16px; border-radius: var(--radius); background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.15); margin-top: 12px;
}
.pf-tutorial-title { font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 8px; }
.pf-tutorial ol { margin: 0; padding-left: 20px; font-size: 12px; color: var(--text-2); line-height: 1.8; }

/* App edit form inline */
.pf-app-form {
    margin-top: 12px; padding: 16px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--fill-1);
}

/* Token update modal inside wizard */
.pf-token-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1100;
    display: flex; align-items: center; justify-content: center;
}
.pf-token-modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; width: 480px; max-width: 90vw;
}

@media (max-width: 700px) {
    .pf-modal { flex-direction: column; }
    .pf-sidebar { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); padding: 16px; flex-direction: row; overflow-x: auto; }
    .pf-step::after { display: none; }
    .pf-content { padding: 20px; }
    .pf-option-cards { flex-direction: column; }
}

/* ── Relogio mundial (botao flutuante) ── */
/* z-index abaixo do painel de detalhes (900) e dos modais, acima do conteudo. */
.clock-fab {
    position: fixed; right: 24px; bottom: 24px; z-index: 890;
    width: 52px; height: 52px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff; cursor: pointer; display: none;
    align-items: center; justify-content: center;
    box-shadow: 0 4px 16px var(--primary-glow-strong);
    transition: transform var(--transition), box-shadow var(--transition);
}
.clock-fab.visivel { display: flex; }
.clock-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 22px var(--primary-glow-strong); }
.clock-fab:active { transform: scale(0.95); }

.clock-card {
    position: fixed; right: 24px; bottom: 88px; z-index: 890;
    width: 290px; max-width: calc(100vw - 48px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(0,0,0,0.35);
    padding: 14px 16px; display: none;
}
.clock-card.aberto { display: block; }
.clock-card-title {
    font-size: 11px; font-weight: 700; color: var(--text-4);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
.clock-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 7px 0; border-bottom: 1px solid var(--border);
}
.clock-row:last-child { border-bottom: none; }
.clock-local { min-width: 0; }
.clock-pais { font-size: 12px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock-cidade { font-size: 10px; color: var(--text-4); }
.clock-hora { font-size: 15px; font-weight: 700; color: var(--text-1); font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock-dia { font-size: 10px; color: var(--warning); text-align: right; }

@media (max-width: 700px) {
    .clock-fab { right: 16px; bottom: 16px; width: 46px; height: 46px; }
    .clock-card { right: 16px; bottom: 74px; max-width: calc(100vw - 32px); }
}

/* ── Budget input ── */
.budget-input {
    transition: all var(--transition);
}
.budget-input:focus {
    border-color: var(--primary) !important;
    background: var(--surface) !important;
    box-shadow: 0 0 0 2px var(--primary-glow);
}
/* So edita depois de clicar na caneta: numero e campo de digitar tem a mesma
   cara, e passar o mouse e ja estar editando o orcamento assusta. */
.budget-input[readonly] { cursor: default; }
/* ── Gateways do perfil ── */
.perfil-gw { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.perfil-gw-corpo { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.gw-item { display: flex; align-items: center; gap: 8px; }
.gw-nome { font-size: 12px; font-weight: 600; color: var(--text-2); min-width: 80px; }
/* A URL e longa e so serve para copiar: campo somente leitura, com reticencias
   em vez de quebrar o card. */
.gw-url {
    flex: 1; min-width: 0; font-size: 11px; font-family: ui-monospace, monospace;
    padding: 6px 8px; border-radius: var(--radius); color: var(--text-4);
    background: var(--bg); border: 1px solid var(--border); outline: none;
    text-overflow: ellipsis;
}
.gw-add-linha { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.gw-add-linha .gw-escolha { min-width: 0; flex: 0 1 180px; }
@media (max-width: 700px) {
    .gw-item, .gw-add-linha { flex-wrap: wrap; }
    .gw-url { flex: 1 1 100%; order: 3; }
}

.btn-editar-orc {
    opacity: 0; visibility: hidden;
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; padding: 0; flex-shrink: 0;
    background: transparent; border: none; border-radius: 5px;
    color: var(--text-4); cursor: pointer;
    transition: opacity var(--transition), color var(--transition), background var(--transition);
}
.tbl tr:hover .btn-editar-orc { opacity: 1; visibility: visible; }
.btn-editar-orc:hover { color: var(--primary); background: var(--fill-3); }
.btn-editar-orc:focus-visible { opacity: 1; visibility: visible; outline: 2px solid var(--primary); }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 32px; height: 18px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 9px; transition: 0.2s; }
.toggle-slider::before { content: ''; position: absolute; height: 14px; width: 14px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .toggle-slider { background: var(--success, #10B981); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }
.toggle.loading .toggle-slider { opacity: 0.5; pointer-events: none; }

/* -- Chat Assistente IA ----------------------------------------------------- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--text-3);
}
.chat-empty p { font-size: 16px; font-weight: 600; margin: 8px 0 0; color: var(--text-2); }
.chat-empty span { font-size: 13px; text-align: center; max-width: 340px; }
.chat-msg { display: flex; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; }
.chat-msg-error { justify-content: flex-start; }
.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}
.chat-bubble-user {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble-assistant {
    background: var(--bg-sidebar);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-bubble-error {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-bottom-left-radius: 4px;
    font-size: 13px;
}
.chat-code {
    display: block;
    background: #0d1020;
    color: #e2e8f0;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 13px;
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
    overflow-x: auto;
    white-space: pre;
}
.chat-code-inline {
    background: rgba(99,102,241,0.15);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
}
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-main);
    color: var(--text-1);
    outline: none;
    max-height: 150px;
    line-height: 1.45;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input:disabled { opacity: 0.5; }
.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.chat-send-btn:hover { opacity: 0.85; }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-status { display:flex;align-items:center;gap:10px;padding:8px 14px;background:var(--bg-2);border-radius:10px;margin:0 0 6px 0; }
.chat-status-spinner { width:16px;height:16px;border:2px solid var(--border);border-top-color:var(--primary);border-radius:50%;animation:spin 0.8s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
.chat-status-text { font-size:13px;color:var(--text-2);flex:1; }
.chat-stop-btn { padding:4px 12px;border-radius:6px;border:1px solid var(--error);background:transparent;color:var(--error);font-size:12px;font-weight:600;cursor:pointer;transition:all 0.15s; }
.chat-stop-btn:hover { background:var(--error);color:#fff; }
.chat-mic-btn { width:40px;height:40px;border-radius:10px;border:none;background:var(--bg-3);color:var(--text-2);cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:all 0.15s; }
.chat-mic-btn:hover { background:var(--bg-hover); }
.chat-mic-btn.recording { background:var(--error);color:#fff;animation:mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }
.chat-thinking {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.chat-thinking span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-3);
    animation: chatDot 1.2s infinite;
}
.chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Motivo da desativacao da conta, no card Atencao Necessaria: a Meta devolve so
   um numero, entao o texto abre no clique do icone em vez de poluir a linha. */
.dash-motivo-btn {
    width: 26px; height: 26px; flex-shrink: 0; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--border); border-radius: 7px;
    color: var(--text-4); cursor: pointer;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.dash-motivo-btn:hover { color: var(--error); border-color: var(--error); background: rgba(239,68,68,0.08); }
.dash-motivo-btn.aberto { color: var(--error); border-color: var(--error); background: rgba(239,68,68,0.12); }
.dash-motivo {
    margin-top: 8px; padding: 8px 10px; border-radius: 6px;
    background: rgba(239, 68, 68, 0.07); border-left: 2px solid var(--error);
    font-size: 11px; line-height: 1.5; color: var(--text-2); white-space: normal;
}

/* ── Celular ─────────────────────────────────────────────────────────────────
   A base de 900px ja vira a barra lateral em gaveta e empilha os filtros. Aqui
   entra o que ainda estourava a tela: largura fixa escrita no HTML, painel
   lateral de 500px, modal com max-width proprio e a Biblioteca em duas colunas.
   Vem por ultimo de proposito: precisa ganhar das regras acima. */
@media (max-width: 700px) {
    /* Nada mais largo que a tela. O !important e porque essas larguras estao
       no atributo style de cada campo, espalhadas pelas telas. */
    .form-input, .form-select, .filter-input, .filter-select {
        width: 100% !important; min-width: 0 !important;
    }
    /* Filtros: com cada campo em 100% eram cinco linhas empilhadas antes da
       tabela aparecer. Os seletores passam a dois por linha; a busca por nome
       fica inteira, por ser o campo mais usado. O rotulo nao quebra linha,
       senao as duas colunas saem com alturas diferentes e o wrap desalinha. */
    .filtro-campo { flex: 1 1 calc(50% - 5px) !important; gap: 4px; }
    .filtro-campo:first-child { flex: 1 1 100% !important; }
    .filtro-rotulo {
        font-size: 11px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .filter-input, .filter-select { min-height: 36px; padding: 6px 10px; }

    /* O Safari do iPhone aproxima a tela quando o campo que recebe foco tem
       fonte abaixo de 16px, e nao desfaz o zoom ao sair do campo — era o que
       acontecia no login e em toda busca. 16px e o minimo que ele aceita sem
       aproximar. O !important e porque varios campos de busca trazem
       font-size 11px ou 12px no atributo style. */
    input, select, textarea,
    .form-input, .form-select, .form-textarea,
    .filter-input, .filter-select {
        font-size: 16px !important;
    }

    /* Orcamento: no celular o campo da tabela so mostra o valor, quem edita e
       a folha que abre no toque (ver _abrirOrcamentoMobile). Sem o
       pointer-events o Safari focava o campo e aproximava a tela. Campo
       readonly aceita foco e nao abre teclado, que era o segundo sintoma. */
    .budget-input {
        pointer-events: none;
        width: 92px !important;
    }

    /* KPI: com minmax(160px) so cabia uma coluna no celular, entao cada card
       pegava a largura inteira e a tela virava uma pilha. Baixando o minimo
       para 92px os tres (Total/Ativas/Pausadas) ficam lado a lado, e a Fila,
       que tem dois cards, ocupa duas colunas em vez de deixar buraco. O card
       encolhe junto: o conteudo e so um rotulo curto e um numero, o
       min-height de 96px e que o deixava alto a toa. */
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
        gap: 8px; margin: 12px 0;
    }
    .kpi { padding: 12px 10px; min-height: 0; }
    .kpi-label { font-size: 9px; letter-spacing: 0.5px; margin-bottom: 4px; }
    .kpi-value { font-size: 22px; letter-spacing: -1px; }
    /* A caneta so aparecia em .tbl tr:hover, e celular nao tem hover: o
       primeiro toque gastava no hover simulado do Safari e o segundo e que
       abria. Alem disso 22px e alvo pequeno demais para o dedo. */
    .btn-editar-orc {
        opacity: 1; visibility: visible;
        width: 34px; height: 34px;
    }
    /* O container todo abre a folha, nao so a caneta. */
    .budget-input + .btn-editar-orc, .budget-input { cursor: pointer; }
    .page-header, .sh, .selection-bar, .modal-footer, .dash-panel-title { flex-wrap: wrap; }
    .selection-bar { align-items: stretch; gap: 10px; }

    /* Painel de detalhes da Fila ocupava 500px fixos */
    .q-panel { width: 100vw; right: -100vw; }

    /* Modal: varios tem max-width proprio no HTML (o de adicionar conjunto tem
       760px), que ganhava do max-width da classe. */
    .modal { max-width: 94vw !important; padding: 20px; }

    /* Biblioteca de Midia: pastas em cima, arquivos embaixo */
    .ml-layout { flex-direction: column !important; height: auto !important; }
    .ml-pastas {
        width: 100% !important; border-right: none !important;
        border-bottom: 1px solid var(--border);
    }

    /* Tabela rola na horizontal em vez de espremer 23 colunas */
    .tbl { min-width: 640px; }
    .tbl th, .tbl td { padding-left: 10px; padding-right: 10px; font-size: 12px; }
    .tbl th { font-size: 9px; letter-spacing: 0.5px; }
    .tbl .cell-name { max-width: 160px; }

    /* Abas e passos do wizard nao quebram linha: deslizam */
    .tabs, .wizard-tabs, .stepper { overflow-x: auto; flex-wrap: nowrap; }
    .stepper { justify-content: flex-start; }
    .stepper-label { font-size: 10px; }

    /* O .kpi-grid de uma coluna saiu daqui: ele ficava depois do bloco que
       define as colunas la em cima e ganhava por ordem, deixando os cards
       empilhados em tela cheia. Quem manda agora e aquele. Nao redeclarar
       grid-template-columns aqui. */
    .filtros-topo { padding: 12px; gap: 10px; }
    .dash-coluna-esq { gap: 12px; }
    .dash-chart { height: clamp(110px, 24vh, 160px); }

    /* Perfis do Facebook: card e badges cabem na tela */
    .perfil-card { padding: 20px 16px; max-width: 100%; box-sizing: border-box; }
    .perfil-card-header { gap: 12px; }
    .perfil-name-badges { flex-direction: column; align-items: flex-start !important; }
    .perfil-badges { flex-wrap: wrap; }
    .perfil-proxy { flex-wrap: wrap; gap: 16px; }
    .perfil-actions { flex-wrap: wrap; }
    .cfg-block { max-width: 100%; box-sizing: border-box; }

    /* Notificações: dropdown ocupa a largura da tela no celular */
    .notif-dropdown {
        position: fixed; top: 52px; left: 8px; right: 8px;
        width: auto; max-width: 100vw;
        max-height: calc(100vh - 64px);
        border-radius: 12px;
    }
    .notif-dropdown-header { padding: 10px 12px; font-size: 13px; }
    .notif-dropdown-list { max-height: calc(100vh - 130px); }
    .notif-item { padding: 10px 12px; }
    .notif-item-title { font-size: 13px; }
    .notif-item-msg { font-size: 13px; }
}

/* ── Gastos do app ───────────────────────────────────────────────────────────
   As larguras ficam aqui, e nao no atributo style, justamente para o celular
   poder mudar: com 130px de nome e 150px de valor fixos a barra sumia numa
   tela de 360px e o valor estourava a largura. */
.gs-topo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.gs-conf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.gs-grafico { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gs-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.gs-bar-nome { width: 130px; flex: none; text-align: right; font-size: 12px; color: var(--text-2); }
.gs-bar-trilha { flex: 1; min-width: 40px; height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.gs-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.gs-bar-valor { width: 150px; flex: none; font-size: 12px; color: var(--text-1); font-weight: 600; }

@media (max-width: 700px) {
    .gs-conf-grid { grid-template-columns: 1fr; }
    /* Nome e valor na primeira linha, barra inteira embaixo. A ordem visual vem
       do `order` porque no HTML a barra vem no meio. */
    .gs-bar-row { flex-wrap: wrap; gap: 4px 8px; margin-bottom: 12px; }
    .gs-bar-nome { width: auto; flex: 1; text-align: left; order: 1; }
    .gs-bar-valor { width: auto; text-align: right; order: 2; }
    .gs-bar-trilha { flex-basis: 100%; order: 3; }
}

/* Os KPIs da tela de Gastos tem grade propria: a .kpi-grid global e calculada
   para a largura da pagina e dentro do modal (325px no celular) ela cabia tres
   por linha, deixando o quarto sozinho. */
.gs-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }

/* ── UTMs ── */
.utms-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
    margin-top: 24px; align-items: start;
}
.utms-col-left { display: flex; flex-direction: column; gap: 24px; }

.utms-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
}
.utms-card-title {
    font-size: 16px; font-weight: 700; color: var(--text-1); margin-bottom: 16px;
}
.utms-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--fill-2);
}
.utms-item-info { display: flex; align-items: center; gap: 12px; }
.utms-item-icon {
    width: 36px; height: 36px; border-radius: 8px; background: var(--fill-4);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.utms-item-label { font-size: 14px; font-weight: 600; color: var(--text-1); }
.utms-item-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.utms-radio-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.utms-radio-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: border-color var(--transition), background var(--transition);
}
.utms-radio-item:hover { border-color: var(--border-hover); background: var(--fill-2); }
.utms-radio-item.selected { border-color: var(--primary); background: var(--primary-glow); }
.utms-radio-item input[type="radio"] {
    appearance: none; width: 18px; height: 18px; border: 2px solid var(--text-4);
    border-radius: 50%; flex-shrink: 0; transition: border-color var(--transition);
}
.utms-radio-item.selected input[type="radio"] {
    border-color: var(--primary); border-width: 5px;
}
.utms-radio-item span { font-size: 14px; font-weight: 500; color: var(--text-1); }

.utms-code-box {
    margin-top: 12px; padding: 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; font-family: monospace; font-size: 12px; color: var(--text-2);
    word-break: break-all; white-space: pre-wrap; max-height: 200px; overflow-y: auto;
    position: relative;
}
.utms-copy-row {
    display: flex; justify-content: flex-end; margin-top: 8px;
}

.utms-form-desc { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }
.utms-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.utms-form-row.full { grid-template-columns: 1fr; }
.utms-form-group label {
    display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px;
}
.utms-form-group label .req { color: var(--error); }
.utms-form-group input {
    width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-1); font-size: 13px;
    transition: border-color var(--transition);
}
.utms-form-group input:focus { outline: none; border-color: var(--primary); }
.utms-form-group input.error { border-color: var(--error); }

.utms-result-row {
    display: flex; gap: 8px; align-items: center; margin-top: 4px;
}
.utms-result-row input {
    flex: 1; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-2); font-size: 12px;
}

@media (max-width: 900px) {
    .utms-grid { grid-template-columns: 1fr; }
}

/* ── Checklist ── */
.checklist-date {
    font-size: 13px; color: var(--text-3); margin-bottom: 20px;
}
.checklist-block {
    padding: 16px; background: var(--fill-2); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 12px;
}
.checklist-block-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.checklist-camp-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
.checklist-camp-detail { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.checklist-items { display: flex; flex-direction: column; gap: 8px; }
.checklist-item {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 8px 10px; border-radius: 8px;
    transition: background var(--transition);
}
.checklist-item:hover { background: var(--fill-3); }
.checklist-item input[type="checkbox"] {
    appearance: none; width: 18px; height: 18px; border: 2px solid var(--text-4);
    border-radius: 4px; flex-shrink: 0; cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    position: relative;
}
.checklist-item input[type="checkbox"]:checked {
    background: var(--primary); border-color: var(--primary);
}
.checklist-item input[type="checkbox"]:checked::after {
    content: ''; position: absolute; left: 5px; top: 2px;
    width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.checklist-item span { font-size: 13px; color: var(--text-2); }
.checklist-item input:checked + span { color: var(--text-1); }
@media (min-width: 900px) { .gs-kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
