:root {
    --color-bg: #f7f8ff;
    --color-surface: #ffffff;
    --color-primary: #6337cb;
    --color-primary-dark: #060912;
    --color-primary-light: #f2f4ff;
    --color-accent: #2f83ff;
    --color-accent-soft: #849dff;
    --color-magenta: #b535bc;
    --color-text: #15224a;
    --color-text-muted: #667085;
    --color-border: #e4e7f1;
    --color-danger: #dc2626;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(6, 9, 18, 0.06), 0 2px 5px rgba(45, 42, 133, 0.08);
    --shadow-md: 0 8px 22px rgba(45, 42, 133, 0.14);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar customizada (Chromium/Edge/Firefox) */
* { scrollbar-width: thin; scrollbar-color: #c7cdd6 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background-color: #c7cdd6; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background-color: #a7b0bd; }

/* Páginas com layout de app (ex.: atendimento) travam a altura em 100vh e
   deixam a rolagem apenas dentro dos painéis internos, sem scrollbar na página. */
body.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
body.app-shell > main { flex: 1 1 auto; min-height: 0; }

/* ---------- Avatares ---------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    user-select: none;
}
.avatar-sm { width: 36px; height: 36px; font-size: 13px; }
.avatar-md { width: 44px; height: 44px; font-size: 15px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }

/* ---------- Login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background:
        radial-gradient(900px 520px at 15% -5%, rgba(132,157,255,0.35), transparent),
        radial-gradient(700px 500px at 100% 100%, rgba(181,53,188,0.22), transparent),
        linear-gradient(135deg, #060912 0%, #15224a 58%, #2d2a85 100%);
}

.login-container { width: 100%; max-width: 380px; padding: 16px; }

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 36px 30px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.login-title { margin: 0 0 4px; font-size: 24px; text-align: center; color: var(--color-primary); font-weight: 700; }
.login-subtitle { margin: 0 0 28px; text-align: center; color: var(--color-text-muted); font-size: 14px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 55, 203, 0.15);
}
.form-group.inline { display: flex; gap: 12px; align-items: center; }
.form-group.inline input { width: auto; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--color-text); }
.checkbox-group input { width: auto; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(90deg, #2f83ff 0%, #a426ff 100%); color: #fff; box-shadow: 0 5px 14px rgba(99,55,203,.20); }
.btn-primary:hover { background: linear-gradient(90deg, #2563eb 0%, #7f4ae1 100%); box-shadow: 0 7px 18px rgba(99,55,203,.28); }
.btn-secondary { background: #eef0f3; color: var(--color-text); }
.btn-secondary:hover { background: #e2e5ea; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-link { background: none; color: #fff; text-decoration: underline; padding: 4px; }
.btn-block { width: 100%; }

.header-select {
    width: 100%;
    max-width: 190px;
    min-height: 38px;
    padding: 8px 10px 8px 35px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--color-text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.header-select:focus { outline: none; border-color: #8061dc; box-shadow: 0 0 0 3px rgba(99, 55, 203, .10); }
.transfer-select-wrap { position: relative; display: inline-flex; }
.transfer-select-wrap > svg {
    position: absolute;
    z-index: 1;
    left: 11px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    fill: none;
    stroke: #6337cb;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}
.badge-sector { background: #e0f2fe; color: #075985; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.error-message { background: #fee2e2; color: var(--color-danger); padding: 10px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }

/* ---------- Navbar ---------- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, #060912 0%, #12184f 58%, #2d2a85 100%);
    color: #fff;
    padding: 12px 24px;
    flex: 0 0 auto;
    box-shadow: 0 3px 14px rgba(6, 9, 18, 0.24);
    border-bottom: 1px solid rgba(132, 157, 255, 0.35);
    position: relative;
    z-index: 5;
}
.navbar-brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.navbar-brand::before { content: "💬"; font-size: 18px; }
.navbar-links { display: flex; gap: 4px; }
.nav-link {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 999px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.10); }
.nav-link.active { color: #fff; background: linear-gradient(90deg, rgba(47,131,255,.55), rgba(164,38,255,.48)); }
.navbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.navbar-user span { display: flex; align-items: center; gap: 8px; }

/* ---------- Page content ---------- */
.page-content { padding: 28px 32px; max-width: 1200px; margin: 0 auto; }
.page-title { margin-top: 0; margin-bottom: 20px; color: var(--color-primary-dark); font-size: 22px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--color-border);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--color-text-muted); font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--color-text); }
.stat-helper { font-size: 12px; color: var(--color-text-muted); }
.stat-card-accent { border-top: 3px solid transparent; border-image: linear-gradient(90deg, #2f83ff, #a426ff) 1; }

.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; position: relative; }
.status-online { background: var(--color-success); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }
.status-offline { background: var(--color-danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15); }
.status-unknown { background: #9ca3af; }

.ws-status { margin-top: 20px; font-size: 13px; padding: 8px 14px; border-radius: 999px; display: inline-block; font-weight: 600; }
.ws-connected { background: #dcfce7; color: var(--color-success); }
.ws-disconnected { background: #fef3c7; color: var(--color-warning); }

/* ---------- Dashboard de atendimento ---------- */
.dashboard-page { max-width: 1440px; }
.dashboard-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.dashboard-heading .page-title { margin: 3px 0 6px; font-size: 28px; }
.dashboard-heading p { margin: 0; color: var(--color-text-muted); font-size: 14px; }
.dashboard-eyebrow { color: var(--color-primary); font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.dashboard-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.chat-kpis { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.chat-kpi { position: relative; min-width: 0; min-height: 132px; padding: 17px; display: flex; align-items: flex-start; gap: 12px; overflow: hidden; background: #fff; border: 1px solid var(--color-border); border-radius: 15px; box-shadow: var(--shadow-sm); }
.chat-kpi::after { content: ""; position: absolute; right: -28px; bottom: -34px; width: 88px; height: 88px; border-radius: 50%; background: rgba(99,55,203,.05); }
.chat-kpi-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 10px; background: #f2f4ff; color: #6337cb; font-size: 18px; font-weight: 700; }
.chat-kpi > div { min-width: 0; display: flex; flex-direction: column; }
.chat-kpi > div > span { color: var(--color-text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .35px; }
.chat-kpi strong { margin: 6px 0 3px; color: #060912; font-size: 28px; line-height: 1; }
.chat-kpi small { color: var(--color-text-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-kpi-primary .chat-kpi-icon { color: #2563eb; background: #eaf2ff; }
.chat-kpi-warning .chat-kpi-icon { color: #b45309; background: #fff5d9; }
.chat-kpi-danger .chat-kpi-icon { color: #dc2626; background: #feecec; }
.chat-kpi-accent .chat-kpi-icon { color: #a426ff; background: #f5eaff; }
.chat-kpi-success .chat-kpi-icon { color: #15803d; background: #e6f8ec; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); gap: 16px; align-items: start; }
.dashboard-panel { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 20px; min-width: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-heading h2 { margin: 0 0 4px; color: #060912; font-size: 16px; }
.panel-heading p { margin: 0; color: var(--color-text-muted); font-size: 12px; }
.panel-heading a { color: #6337cb; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.panel-heading a:hover { text-decoration: underline; }

.flow-bars { display: flex; flex-direction: column; gap: 19px; }
.flow-row > div:first-child { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 13px; }
.flow-row strong { color: #060912; }
.flow-track, .meter-track { height: 9px; overflow: hidden; border-radius: 999px; background: #eef0fa; }
.flow-track span, .meter-track span { display: block; height: 100%; min-width: 3px; border-radius: inherit; transition: width .35s ease; }

.message-volume { display: flex; align-items: center; gap: 28px; }
.message-donut { width: 142px; height: 142px; flex: 0 0 142px; display: grid; place-items: center; border-radius: 50%; background: #eef0fa; position: relative; }
.message-donut::after { content: ""; position: absolute; width: 96px; height: 96px; border-radius: 50%; background: #fff; }
.message-donut > span { z-index: 1; display: flex; flex-direction: column; align-items: center; }
.message-donut strong { color: #060912; font-size: 27px; }
.message-donut small { color: var(--color-text-muted); font-size: 10px; }
.message-legend { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.message-legend > div { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
.message-legend i { width: 9px; height: 9px; border-radius: 50%; }
.message-legend span { overflow: hidden; color: var(--color-text-muted); text-overflow: ellipsis; white-space: nowrap; }
.legend-incoming { background: #2f83ff; }
.legend-bot { background: #a426ff; }
.legend-human { background: #7f4ae1; }
.automation-meter { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.automation-meter > div:first-child { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; }
.automation-meter strong { color: #6337cb; }
.automation-meter .meter-track span { background: linear-gradient(90deg, #2f83ff, #a426ff); }

.queue-panel { grid-row: span 2; }
.priority-queue { display: flex; flex-direction: column; margin: 0 -8px -8px; }
.queue-item { display: flex; align-items: center; gap: 11px; padding: 11px 8px; border-bottom: 1px solid #eef0f5; color: inherit; text-decoration: none; border-radius: 10px; transition: background .12s ease; }
.queue-item:last-child { border-bottom: 0; }
.queue-item:hover { background: #f7f8ff; }
.queue-item-body { flex: 1; min-width: 0; }
.queue-item-body > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.queue-item-body strong { min-width: 0; overflow: hidden; color: #060912; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.queue-item-body time { flex: 0 0 auto; color: var(--color-text-muted); font-size: 10px; }
.queue-item-body p { margin: 3px 0 6px; overflow: hidden; color: var(--color-text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.queue-item-body .status-badge { padding: 2px 7px; font-size: 9px; }
.queue-arrow { color: #849dff; font-size: 25px; }
.queue-empty { min-height: 185px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--color-text-muted); text-align: center; }
.queue-empty::before { content: "✓"; width: 42px; height: 42px; margin-bottom: 5px; display: grid; place-items: center; border-radius: 50%; color: #15803d; background: #e6f8ec; font-size: 20px; }
.queue-empty strong { color: #15224a; font-size: 14px; }
.queue-empty span { font-size: 12px; }

.integration-panel { padding-bottom: 14px; }
.integration-status-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px; border-radius: 11px; background: #f7f8ff; font-size: 12px; font-weight: 700; }
.integration-status-row > span:last-child { color: var(--color-text-muted); font-weight: 500; }
.integration-details { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; }
.integration-details > div { padding: 0 12px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--color-border); }
.integration-details > div:first-child { padding-left: 0; }
.integration-details > div:last-child { padding-right: 0; border-right: 0; }
.integration-details span { color: var(--color-text-muted); font-size: 10px; }
.integration-details strong { color: #15224a; font-size: 13px; }
.integration-panel .ws-status { margin-top: 14px; padding: 5px 10px; font-size: 10px; }

@media (max-width: 1180px) {
    .chat-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .queue-panel { grid-row: auto; }
}
@media (max-width: 600px) {
    .dashboard-page { padding: 20px 14px; }
    .chat-kpis { grid-template-columns: repeat(2, 1fr); }
    .chat-kpi { min-height: 122px; padding: 14px; }
    .chat-kpi-icon { display: none; }
    .message-volume { align-items: flex-start; flex-direction: column; }
    .integration-details { grid-template-columns: 1fr; gap: 10px; }
    .integration-details > div { padding: 0; border-right: 0; }
}

/* ---------- Chat layout ---------- */
.chat-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 300px;
    gap: 16px;
    max-width: 1440px;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    padding: 16px;
}

@media (max-width: 900px) {
    body.app-shell { height: auto; overflow: visible; }
    .chat-layout { grid-template-columns: 1fr; height: auto; padding: 8px; }
}

.chat-list-panel,
.chat-center-panel,
.contact-info-panel {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.chat-list-panel { display: flex; flex-direction: column; min-height: 0; }
.chat-list-header {
    position: relative;
    z-index: 4;
    display: grid;
    gap: 12px;
    padding: 18px 14px 16px;
    border-bottom: 1px solid #e8e9f4;
    background:
        radial-gradient(circle at 100% 0, rgba(164, 38, 255, .09), transparent 42%),
        linear-gradient(155deg, #fff 0%, #f8f8ff 100%);
}
.chat-list-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, #2f83ff, #6b45e8 55%, #a426ff);
}
.filter-heading { display: flex; align-items: center; justify-content: space-between; min-width: 0; }
.filter-heading > div { display: grid; gap: 3px; }
.filter-heading strong { display: flex; align-items: center; gap: 7px; font-size: 15px; letter-spacing: -.15px; }
.filter-eyebrow { color: #7c6fa4; font-size: 9px; font-weight: 800; letter-spacing: 1.2px; }
.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border: 1px solid #dfd9ff;
    border-radius: 999px;
    background: #f0edff;
    color: #6337cb;
    font-size: 10px;
}
.clear-filters {
    padding: 5px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #6337cb;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.clear-filters:hover { background: #eeeaff; }
.premium-search {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 42px;
    padding: 0 10px 0 12px;
    border: 1px solid #dfe2ed;
    border-radius: 12px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 2px 8px rgba(45, 42, 133, .05);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.premium-search:focus-within, .premium-search.is-active {
    border-color: #8a6ce4;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 55, 203, .10), 0 5px 14px rgba(45, 42, 133, .08);
}
.premium-search svg { width: 17px; height: 17px; fill: none; stroke: #887ca9; stroke-width: 1.8; stroke-linecap: round; }
.premium-search input {
    min-width: 0;
    flex: 1;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--color-text);
    font-family: inherit;
    font-size: 13px;
}
.premium-search input::placeholder { color: #9298aa; }
.premium-search input::-webkit-search-cancel-button { cursor: pointer; }
.premium-search kbd {
    display: grid;
    place-items: center;
    width: 24px;
    height: 23px;
    border: 1px solid #e1e3ec;
    border-bottom-color: #cfd3df;
    border-radius: 6px;
    background: #f8f9fc;
    color: #8c93a5;
    font-family: inherit;
    font-size: 12px;
    box-shadow: 0 1px 0 #e2e4ec;
}
.premium-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.premium-filter {
    position: relative;
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid #e2e4ed;
    border-radius: 11px;
    background: rgba(255, 255, 255, .86);
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.premium-filter:hover { border-color: #c8bee9; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(45, 42, 133, .07); }
.premium-filter:focus-within, .premium-filter.is-active { border-color: #8a6ce4; box-shadow: 0 0 0 3px rgba(99, 55, 203, .08); }
.premium-filter.is-active { background: #f5f2ff; }
.premium-filter > span { color: #8b91a3; font-size: 9px; font-weight: 800; letter-spacing: .65px; text-transform: uppercase; }
.premium-filter select {
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    outline: 0;
    appearance: none;
    background: transparent;
    color: #253257;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-overflow: ellipsis;
}
.custom-filter-select { position: relative; min-width: 0; }
.custom-filter-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #253257;
    font-family: inherit;
    font-size: 12px;
    font-weight: 750;
    cursor: pointer;
}
.custom-filter-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-filter-trigger > svg {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    fill: none;
    stroke: #858ba0;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .18s ease, stroke .18s ease;
}
.custom-filter-select.is-open .custom-filter-trigger > svg { transform: rotate(180deg); stroke: #6337cb; }
.custom-filter-menu {
    position: absolute;
    z-index: 40;
    top: calc(100% + 11px);
    left: -11px;
    display: grid;
    width: max-content;
    min-width: 190px;
    max-width: 240px;
    padding: 6px;
    border: 1px solid #e1ddf1;
    border-radius: 13px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 14px 34px rgba(32, 24, 77, .18), 0 3px 10px rgba(45, 42, 133, .08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(.98);
    transform-origin: top left;
    transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
.premium-filter:last-child .custom-filter-menu { right: -11px; left: auto; transform-origin: top right; }
.custom-filter-select.is-open .custom-filter-menu { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.custom-filter-option {
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #3d4869;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: color .12s ease, background .12s ease;
}
.custom-filter-option:hover, .custom-filter-option:focus-visible { outline: 0; background: #f3f0ff; color: #4c2faf; }
.custom-filter-option[aria-selected="true"] { background: #eee9ff; color: #4c2faf; font-weight: 750; }
.custom-filter-dot { width: 7px; height: 7px; border-radius: 50%; background: #8a6ce4; box-shadow: 0 0 0 3px rgba(138,108,228,.10); }
.custom-filter-option > svg { width: 15px; height: 15px; fill: none; stroke: #6337cb; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.custom-filter-option[aria-selected="true"] > svg { opacity: 1; }
.is-status-select .custom-filter-option[data-value=""] .custom-filter-dot { background: #94a3b8; }
.is-status-select .custom-filter-option[data-value="bot"] .custom-filter-dot { background: #3b82f6; }
.is-status-select .custom-filter-option[data-value="waiting"] .custom-filter-dot { background: #f59e0b; }
.is-status-select .custom-filter-option[data-value="human"] .custom-filter-dot { background: #7c3aed; }
.is-status-select .custom-filter-option[data-value="follow_up"] .custom-filter-dot { background: #ea580c; }
.is-status-select .custom-filter-option[data-value="sale_closed"] .custom-filter-dot { background: #16a34a; }
.is-status-select .custom-filter-option[data-value="closed"] .custom-filter-dot { background: #64748b; }

.conversation-list { overflow-y: auto; flex: 1; min-height: 0; }
.conversation-item {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f3f5;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    position: relative;
    transition: background-color 0.1s ease;
}
.conversation-item:hover { background: #f8fafc; }
.conversation-item.active { background: var(--color-primary-light); }
.conversation-item.active::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--color-primary);
}
.conversation-item-body { flex: 1; min-width: 0; }
.conversation-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conversation-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conversation-item-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; gap: 8px; }
.conversation-phone { font-size: 12px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conversation-sector { margin-top: 5px; color: #075985; font-size: 11px; font-weight: 700; }
.unread-badge { background: var(--color-primary); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.status-badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; }
.badge-bot { background: #dbeafe; color: #1d4ed8; }
.badge-waiting { background: #fef3c7; color: #b45309; }
.badge-human { background: #dcfce7; color: #15803d; }
.badge-follow-up { background: #ffedd5; color: #c2410c; }
.badge-sale-closed { background: #dcfce7; color: #166534; }
.badge-closed { background: #e5e7eb; color: #4b5563; }

.chat-center-panel { display: flex; flex-direction: column; min-height: 0; background: #f4f6f9; }
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--color-text-muted);
    text-align: center;
    padding: 24px;
}
.chat-empty-state::before {
    content: "💬";
    font-size: 40px;
    opacity: 0.5;
}
.chat-active { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 10px;
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-header-text { display: flex; flex-direction: column; gap: 3px; }
.chat-header-text strong { font-size: 15px; line-height: 1.1; }
.chat-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-header-actions .btn { min-height: 38px; padding: 9px 14px; }
.chat-header-actions .chat-icon-button {
    position: relative;
    width: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 11px;
    overflow: visible;
}
.chat-icon-button::after {
    content: attr(data-tooltip);
    position: absolute;
    z-index: 20;
    top: calc(100% + 9px);
    left: 50%;
    width: max-content;
    max-width: 190px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 8px;
    background: #11162f;
    color: #fff;
    box-shadow: 0 8px 22px rgba(6, 9, 18, .22);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -4px);
    transition: opacity .15s ease, transform .15s ease;
}
.chat-icon-button::before {
    content: "";
    position: absolute;
    z-index: 21;
    top: calc(100% + 4px);
    left: 50%;
    border: 5px solid transparent;
    border-bottom-color: #11162f;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity .15s ease;
}
.chat-header-actions .chat-icon-button:nth-last-child(-n + 2)::after {
    right: 0;
    left: auto;
    transform: translateY(-4px);
}
.chat-header-actions .chat-icon-button:nth-last-child(-n + 2):hover::after,
.chat-header-actions .chat-icon-button:nth-last-child(-n + 2):focus-visible::after {
    transform: translateY(0);
}
.chat-icon-button:hover::after,
.chat-icon-button:hover::before,
.chat-icon-button:focus-visible::after,
.chat-icon-button:focus-visible::before { opacity: 1; }
.chat-icon-button:hover::after,
.chat-icon-button:focus-visible::after { transform: translate(-50%, 0); }
.chat-action-icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.chat-header-actions .btn-secondary .chat-action-icon { color: #6337cb; }

.messages-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background-color: #f7f8ff;
    background-image: radial-gradient(circle, rgba(99,55,203,0.07) 1px, transparent 1px);
    background-size: 18px 18px;
}
.bubble {
    max-width: 68%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
    margin: 4px 0;
}
.bubble-in { align-self: flex-start; background: #fff; border: 1px solid var(--color-border); border-bottom-left-radius: 4px; }
.bubble-out { align-self: flex-end; background: linear-gradient(135deg, #2f83ff, #6337cb); color: #fff; border-bottom-right-radius: 4px; }
.bubble-bot { align-self: flex-end; background: #e8ebff; color: #2d2a85; border: 1px solid #cbd5ff; border-bottom-right-radius: 4px; }
.bubble-text { white-space: pre-wrap; word-break: break-word; }
.message-source-badge { width: max-content; margin: -3px 0 6px; padding: 2px 7px; border-radius: 999px; font-size: 9px; font-weight: 800; letter-spacing: .55px; text-transform: uppercase; }
.message-source-ai { color: #6337cb; background: rgba(255,255,255,.72); border: 1px solid rgba(99,55,203,.18); }
.message-source-ai span { color: #a426ff; }
.bubble-meta { display: flex; gap: 6px; align-items: center; justify-content: flex-end; font-size: 10.5px; opacity: 0.75; margin-top: 4px; }
.bubble-status { letter-spacing: -2px; font-size: 12px; }
.bubble-status[data-status="read"],
.bubble-status[data-status="played"] { color: #53bdeb; opacity: 1; letter-spacing: -2px; }
.bubble-status[data-status="failed"] { letter-spacing: 0; color: #ffb020; }
.attachment-image {
    max-width: 260px;
    max-height: 260px;
    border-radius: 10px;
    margin-top: 6px;
    display: block;
    cursor: pointer;
    object-fit: cover;
}
.attachment-audio { margin-top: 6px; width: 240px; }
.attachment-file {
    margin-top: 6px;
    font-size: 12px;
    background: rgba(0,0,0,0.05);
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.send-form { display: flex; flex-direction: column; gap: 10px; padding: 12px 18px 14px; background: var(--color-surface); border-top: 1px solid var(--color-border); flex: 0 0 auto; }
.send-compose { display: flex; align-items: center; gap: 10px; width: 100%; }
.send-compose > input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 14px;
    background: #f4f6f9;
}
.send-compose > input[type="text"]:focus { outline: none; border-color: var(--color-primary); background: #fff; }
.send-form .btn { border-radius: 999px; padding: 10px 22px; }
.photo-btn { width: 42px; height: 42px; flex: 0 0 42px; border: 0; border-radius: 50%; background: transparent; color: var(--color-primary); display: grid; place-items: center; cursor: pointer; }
.photo-btn:hover { background: var(--color-primary-light); }
.photo-btn:disabled { cursor: wait; opacity: 0.5; }
.photo-btn svg { width: 24px; height: 24px; fill: currentColor; }
.photo-preview { align-self: flex-start; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 100%; padding: 8px 10px; border: 1px solid var(--color-border); background: #f4f6f9; border-radius: 12px; }
.photo-preview[hidden] { display: none; }
.photo-preview img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }
.photo-preview-info { min-width: 0; display: flex; flex-direction: column; font-size: 12px; color: var(--color-text-muted); }
.photo-preview-info strong { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text); }
.remove-photo-btn { margin-left: auto; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--color-text-muted); font-size: 24px; line-height: 1; cursor: pointer; }
.remove-photo-btn:hover { background: #e3e7ec; color: var(--color-danger); }
#audio-preview audio { height: 36px; }
.mic-btn, #mic-btn.recording-active { color: var(--color-primary); }
#mic-btn.recording-active { background: #ffe4e4; color: var(--color-danger); animation: mic-pulse 1.4s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,0.35); } 50% { box-shadow: 0 0 0 6px rgba(220,53,69,0); } }
.recording-indicator { align-self: flex-start; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px; background: #ffe4e4; color: var(--color-danger); font-size: 13px; font-weight: 600; }
.recording-indicator[hidden] { display: none; }
.recording-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-danger); animation: mic-pulse-dot 1s ease-in-out infinite; }
@keyframes mic-pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.send-form .recording-indicator .btn-sm { padding: 4px 12px; font-size: 12px; border-radius: 999px; }

.contact-info-panel { padding: 22px; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }
.contact-info-panel h3 { margin: 0 0 18px; font-size: 15px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.contact-info-header { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.contact-info-header .avatar { margin-bottom: 2px; }
.contact-info-header .contact-info-name { font-weight: 700; font-size: 16px; text-align: center; word-break: break-word; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    margin-bottom: 20px;
}
.settings-card h2 { margin-top: 0; font-size: 16px; color: var(--color-primary-dark); }
.page-subtitle { margin-top: -12px; margin-bottom: 24px; color: var(--color-text-muted); }
.management-grid { display: grid; gap: 24px; }
.management-form { display: grid; gap: 12px; margin: 16px 0 24px; }
.management-form input:not([type="checkbox"]), .management-form select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--color-border);
    border-radius: var(--radius); background: #fff;
}
.management-form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.management-actions { display: flex; gap: 8px; }
.table-scroll { overflow-x: auto; }

@media (max-width: 800px) {
    .management-form-row { grid-template-columns: 1fr; }
    .header-select { max-width: 150px; }
}
.ai-settings-card { grid-column: 1 / -1; }
.ai-card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.ai-card-heading h2 { margin-bottom: 5px; }
.ai-card-heading p { margin: 0; }
.ai-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 650px) {
    .ai-card-heading { flex-direction: column; }
    .ai-form-grid { grid-template-columns: 1fr; gap: 0; }
}
.hint { font-size: 12px; color: var(--color-text-muted); }
.ai-advanced-rules { margin: 16px 0; padding: 12px 14px; border: 1px solid var(--color-border); border-radius: var(--radius); background: #fafafd; }
.ai-advanced-rules summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--color-text); }
.ai-advanced-rules[open] summary { margin-bottom: 10px; }
.ai-advanced-rules textarea { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.ai-advanced-warning { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; padding: 8px 10px; border-radius: 8px; margin-top: 0; }
.page-description { margin: -8px 0 22px; color: var(--color-text-muted); font-size: 14px; }
.controlwhats-grid { align-items: stretch; }
.controlwhats-grid .settings-card { margin-bottom: 0; }
.credential-status { display: block; margin-top: 7px; color: var(--color-text-muted); font-size: 12px; }
.credential-status.configured { color: var(--color-success); font-weight: 600; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { min-width: 0; flex: 1; }
.copy-field .btn { flex: 0 0 auto; }
.controlwhats-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.controlwhats-result { min-height: 22px; margin-top: 14px; font-size: 13px; }
.test-ok { color: var(--color-success); margin-left: 10px; font-weight: 600; }
.test-fail { color: var(--color-danger); margin-left: 10px; font-weight: 600; }
.controlwhats-result.test-ok, .controlwhats-result.test-fail { margin-left: 0; }
.session-manager { margin-top: 20px; }
.session-manager-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.session-manager-heading label { margin-bottom: 3px; }
.session-list { display: flex; flex-direction: column; gap: 8px; }
.session-row { display: grid; grid-template-columns: auto minmax(110px, .7fr) minmax(180px, 1.3fr) auto; align-items: center; gap: 8px; padding: 9px; border: 1px solid var(--color-border); border-radius: var(--radius); background: #fafafd; }
.session-row > input { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--color-border); border-radius: var(--radius); background: #fff; }
.session-default { display: flex !important; align-items: center; gap: 5px; margin: 0 !important; white-space: nowrap; cursor: pointer; }
.session-default input { margin: 0; }
.session-default span { font-size: 11px; color: var(--color-text-muted); }
@media (max-width: 700px) {
    .session-row { grid-template-columns: auto 1fr auto; }
    .session-row [data-session-id] { grid-column: 1 / -1; grid-row: 2; }
}

.rules-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.rules-table th {
    padding: 10px 8px;
    text-align: left;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.4px;
    border-bottom: 2px solid var(--color-border);
}
.rules-table td { padding: 10px 8px; border-bottom: 1px solid var(--color-border); text-align: left; }
.rules-table tbody tr:hover { background: #fafbfc; }
.rules-table .subrule-row { background: #fbfdfc; }
.rule-name-depth { display: inline-block; padding-left: calc(var(--rule-depth) * 18px); font-weight: 600; white-space: nowrap; }
.rule-parent-badge, .rule-root-badge { display: inline-block; padding: 3px 7px; border-radius: 999px; font-size: 11px; white-space: nowrap; }
.rule-parent-badge { color: #4c2faf; background: #ece8ff; }
.rule-root-badge { color: var(--color-text-muted); background: #eef1f5; }
.rule-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.new-rule-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.new-rule-form input, .new-rule-form select { padding: 9px 10px; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 13px; }
.rule-form-active { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 13px; white-space: nowrap; }
.rule-response-editor { flex: 1 0 100%; display: flex; flex-direction: column; gap: 7px; margin: 6px 0; }
.rule-response-editor > label { font-size: 13px; font-weight: 600; color: var(--color-text); }
.rule-response-editor textarea { width: 100%; min-height: 110px; resize: vertical; padding: 11px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); font: inherit; line-height: 1.45; }
.rule-response-editor textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(99,55,203,0.10); }
.response-toolbar { display: flex; flex-wrap: wrap; gap: 5px; }
.response-toolbar button { min-height: 30px; padding: 4px 9px; border: 1px solid var(--color-border); border-radius: 7px; background: #f4f6f9; color: var(--color-text); cursor: pointer; font-size: 12px; }
.response-toolbar button:hover { border-color: var(--color-primary); background: var(--color-primary-light); color: #4c2faf; }
.response-preview-wrap { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: start; gap: 8px; margin-top: 3px; font-size: 11px; color: var(--color-text-muted); }
.response-preview { max-width: 520px; padding: 9px 12px; border-radius: 12px 12px 12px 3px; background: #eef1f5; color: var(--color-text); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.rules-table td:nth-child(5) { max-width: 300px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Kanban operacional ---------- */
.page-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 290px;
    height: 44px;
    padding: 0 9px 0 13px;
    border: 1px solid #dfe2ed;
    border-radius: 13px;
    background:
        radial-gradient(circle at 100% 0, rgba(164, 38, 255, .07), transparent 45%),
        #fff;
    box-shadow: 0 3px 10px rgba(45, 42, 133, .07);
    cursor: text;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.page-search:hover { border-color: #c8bee9; }
.page-search:focus-within, .page-search.is-active {
    border-color: #8061dc;
    box-shadow: 0 0 0 3px rgba(99, 55, 203, .10), 0 7px 18px rgba(45, 42, 133, .10);
    transform: translateY(-1px);
}
.page-search-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: none;
    stroke: #7864bd;
    stroke-width: 1.8;
    stroke-linecap: round;
}
.page-search input {
    min-width: 0;
    flex: 1;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--color-text);
    font-family: inherit;
    font-size: 13px;
}
.page-search input::placeholder { color: #969caf; }
.page-search input::-webkit-search-cancel-button { display: none; }
.page-search-clear {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #f0edff;
    color: #6337cb;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.page-search-clear:hover { background: #e4ddff; transform: scale(1.04); }
.page-search-clear svg, .premium-refresh svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.premium-refresh {
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid #ddd7f4;
    border-radius: 12px;
    background: linear-gradient(145deg, #fff, #f1effa);
    color: #32235f;
    box-shadow: 0 3px 9px rgba(45, 42, 133, .07);
}
.premium-refresh:hover {
    border-color: #b8a9e8;
    background: #f4f0ff;
    color: #6337cb;
    box-shadow: 0 6px 14px rgba(45, 42, 133, .11);
    transform: translateY(-1px);
}
.kanban-layout { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 22px 24px 16px; overflow: hidden; }
.kanban-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.kanban-toolbar .page-title { margin-bottom: 5px; }
.kanban-toolbar p { margin: 0; color: var(--color-text-muted); font-size: 14px; }
.kanban-filters { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.kanban-filters .search-input { width: 260px; flex: none; background: #fff; }
.kanban-drag-help { padding: 9px 12px; border: 1px solid #e7e2fa; border-radius: 11px; background: var(--color-primary-light); color: #433176; font-size: 12px; font-weight: 600; white-space: nowrap; }
.kanban-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--color-text-muted);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.kanban-checkbox:hover { border-color: #e1dcf4; background: #fff; color: var(--color-text); }
.kanban-checkbox:has(input:checked) { border-color: #cfc3f5; background: #f4f1ff; color: #4c2faf; }
.kanban-checkbox input {
    appearance: none;
    display: grid;
    place-items: center;
    width: 17px;
    height: 17px;
    margin: 0;
    border: 1.5px solid #aab0c1;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
}
.kanban-checkbox input::after { content: ""; width: 7px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; opacity: 0; transform: rotate(-45deg) translateY(-1px); }
.kanban-checkbox input:checked { border-color: #6337cb; background: linear-gradient(135deg, #2f83ff, #8b2ee8); }
.kanban-checkbox input:checked::after { opacity: 1; }
.kanban-checkbox input:focus-visible { outline: 3px solid rgba(99, 55, 203, .15); outline-offset: 2px; }
.kanban-summary { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.kanban-summary span { padding: 6px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--color-border); font-size: 12px; color: var(--color-text-muted); }
.kanban-summary strong { color: var(--color-text); }
.kanban-summary .summary-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.kanban-summary .summary-follow-up { background: #fff7ed; border-color: #fdba74; color: #c2410c; }
.kanban-summary .summary-sale { background: #f0fdf4; border-color: #86efac; color: #166534; }
.kanban-summary .summary-overdue { background: #fee2e2; border-color: #fca5a5; color: var(--color-danger); }
.kanban-board { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(6, minmax(230px, 1fr)); gap: 14px; overflow-x: auto; transition: opacity .15s ease; }
.kanban-board.is-loading { opacity: .6; }
.kanban-column { min-width: 230px; min-height: 0; display: flex; flex-direction: column; background: #eef0fa; border-radius: var(--radius-lg); overflow: hidden; border-top: 4px solid #2f83ff; }
.kanban-column-waiting { border-top-color: #f59e0b; }
.kanban-column-human { border-top-color: #7f4ae1; }
.kanban-column-follow_up { border-top-color: #ea580c; background: #fff8f1; }
.kanban-column-sale_closed { border-top-color: #16a34a; background: #eef9f1; }
.kanban-column-closed { border-top-color: #94a3b8; }
.kanban-column > header { display: flex; align-items: flex-start; justify-content: space-between; padding: 14px; }
.kanban-column > header h2 { margin: 0; font-size: 14px; }
.kanban-column > header p { margin: 3px 0 0; font-size: 11px; color: var(--color-text-muted); }
.kanban-column > header > span { display: grid; place-items: center; min-width: 25px; height: 25px; padding: 0 7px; border-radius: 999px; background: rgba(255,255,255,.8); font-size: 12px; font-weight: 700; }
.kanban-column-body { min-height: 0; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 9px; border-radius: 10px; transition: background .15s ease, box-shadow .15s ease; }
.kanban-board.is-dragging .kanban-column-body { box-shadow: inset 0 0 0 1px rgba(99,55,203,.13); }
.kanban-column-body.is-drag-over { background: rgba(99,55,203,.10); box-shadow: inset 0 0 0 2px var(--color-primary); }
.kanban-card { padding: 12px; border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); cursor: grab; user-select: none; border: 1px solid transparent; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, opacity .12s ease; }
.kanban-card:active { cursor: grabbing; }
.kanban-card:hover, .kanban-card:focus { outline: none; transform: translateY(-1px); border-color: #849dff; box-shadow: var(--shadow-md); }
.kanban-card.is-dragging { opacity: .35; transform: rotate(1deg) scale(.98); }
.kanban-card.is-moving { opacity: .55; pointer-events: none; }
.kanban-card.is-stalled { border-color: #fca5a5; box-shadow: 0 0 0 1px #fca5a5, var(--shadow-sm); }
.kanban-stalled { display: inline-block; padding: 3px 7px; border-radius: 999px; background: #fee2e2; color: var(--color-danger); font-size: 10px; font-weight: 700; white-space: nowrap; }
.kanban-card-header { display: flex; align-items: center; gap: 9px; }
.kanban-card-header > div:not(.avatar) { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.kanban-card-header strong, .kanban-card-header span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-header strong { font-size: 13px; }
.kanban-card-header span { margin-top: 2px; color: var(--color-text-muted); font-size: 11px; }
.kanban-preview { margin: 10px 0 8px; font-size: 12px; line-height: 1.4; color: #4b5563; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kanban-tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; }
.kanban-tag { display: inline-block; max-width: 105px; padding: 3px 7px; border-radius: 999px; background: var(--color-primary-light); color: var(--color-primary-dark); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-ai-sale { display: inline-block; padding: 3px 7px; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 10px; font-weight: 700; white-space: nowrap; }
.kanban-ai-follow-up { display: inline-block; padding: 3px 7px; border-radius: 999px; background: #ffedd5; color: #c2410c; font-size: 10px; font-weight: 700; white-space: nowrap; }
.kanban-contact-cta { display: block; margin-top: 7px; color: #c2410c; font-size: 11px; font-weight: 700; }
.follow-up-badge { display: inline-block; padding: 3px 7px; border-radius: 999px; background: #e0f2fe; color: #0369a1; font-size: 10px; font-weight: 700; white-space: nowrap; }
.follow-up-badge.is-sale { background: #dcfce7; color: #166534; }
.follow-up-badge.is-overdue { background: #fee2e2; color: var(--color-danger); }
.kanban-card footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; padding-top: 8px; border-top: 1px solid #eef0f3; color: var(--color-text-muted); font-size: 10px; }
.kanban-empty { padding: 24px 10px; border: 1px dashed #cbd5e1; border-radius: 10px; color: var(--color-text-muted); text-align: center; font-size: 12px; }
.kanban-error { grid-column: 1 / -1; padding: 18px; border-radius: var(--radius); background: #fee2e2; color: var(--color-danger); }
.kanban-layout > .ws-status { flex: 0 0 auto; align-self: flex-start; margin-top: 10px; }
.kanban-toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: min(380px, calc(100vw - 32px)); padding: 11px 15px; border-radius: 10px; background: #166534; color: #fff; box-shadow: var(--shadow-md); font-size: 13px; font-weight: 600; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.kanban-toast.is-visible { opacity: 1; transform: translateY(0); }
.kanban-toast.is-error { background: var(--color-danger); }

@media (max-width: 900px) {
    body.kanban-page { height: 100vh; overflow: hidden; }
    .kanban-layout { padding: 14px 12px; }
    .kanban-toolbar { align-items: stretch; flex-direction: column; }
    .kanban-filters { justify-content: flex-start; }
    .kanban-filters .page-search { width: min(100%, 340px); }
    .kanban-board { grid-template-columns: repeat(6, minmax(270px, 78vw)); }
}

.app-modal { border: none; border-radius: var(--radius-lg); padding: 0; box-shadow: var(--shadow-md); max-width: min(360px, calc(100vw - 32px)); }
.app-modal::backdrop { background: rgba(15, 18, 33, 0.45); }
.app-modal-form { display: flex; flex-direction: column; gap: 10px; padding: 22px; }
.app-modal-form h3 { margin: 0; font-size: 16px; color: var(--color-text); }
.app-modal-form p { margin: 0; font-size: 13px; color: var(--color-text-muted); }
.app-modal-form input[type="datetime-local"] { padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 8px; font-size: 14px; }
.app-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Agenda */
.agenda-layout { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 22px 24px 16px; overflow-y: auto; }
.agenda-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; flex-wrap: wrap; }
.agenda-toolbar .page-title { margin-bottom: 5px; }
.agenda-toolbar p { margin: 0; color: var(--color-text-muted); font-size: 14px; }
.agenda-filters { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.agenda-filters .page-search { width: 290px; flex: none; }

.agenda-content { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }

.agenda-calendar-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); }
.calendar-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.calendar-nav strong { flex: 1; font-size: 16px; color: var(--color-text); text-transform: capitalize; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.calendar-weekdays span { text-align: center; font-size: 11px; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .4px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(84px, auto); gap: 6px; transition: opacity .15s ease; }
.calendar-grid.is-loading { opacity: .6; }
.calendar-cell { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px; border: 1px solid var(--color-border); border-radius: 10px; background: #fff; cursor: pointer; text-align: left; font-family: inherit; transition: border-color .12s ease, background .12s ease; }
.calendar-cell:hover { border-color: var(--color-accent-soft); }
.calendar-cell.is-outside { background: #f7f8fb; color: var(--color-text-muted); }
.calendar-cell.is-outside .calendar-cell-day { opacity: .5; }
.calendar-cell.is-today { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); }
.calendar-cell.is-selected { background: var(--color-primary-light); border-color: var(--color-primary); }
.calendar-cell.has-overdue .calendar-cell-day { color: var(--color-danger); }
.calendar-cell-day { font-size: 12px; font-weight: 700; }
.calendar-cell-chips { display: flex; flex-direction: column; gap: 2px; }
.calendar-chip { font-size: 10px; padding: 2px 5px; border-radius: 5px; background: #e0f2fe; color: #0369a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-chip.is-sale { background: #dcfce7; color: #166534; }
.calendar-chip.is-overdue { background: #fee2e2; color: var(--color-danger); }
.calendar-chip-more { font-size: 10px; color: var(--color-text-muted); padding: 0 5px; }

.agenda-nodate { margin-top: 18px; }
.agenda-nodate h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 14px; color: var(--color-text); }
.agenda-nodate h2 span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--color-primary-light); color: var(--color-primary-dark); font-size: 11px; font-weight: 700; }

.agenda-day-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); position: sticky; top: 12px; max-height: calc(100vh - 220px); overflow-y: auto; }
.agenda-day-panel h2 { margin: 0 0 12px; font-size: 14px; color: var(--color-text); }
.agenda-day-cards { display: flex; flex-direction: column; gap: 10px; }

.agenda-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.agenda-card { background: var(--color-surface); border: 1px solid var(--color-border); border-left: 4px solid var(--color-border); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px; }
.agenda-card.is-follow-up { border-left-color: #0369a1; }
.agenda-card.is-sale { border-left-color: #166534; }
.agenda-card-main { display: flex; align-items: flex-start; gap: 10px; }
.agenda-card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.agenda-card-body strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-card-phone { color: var(--color-text-muted); font-size: 11px; margin-top: 1px; }
.agenda-card-preview { margin: 6px 0 0; font-size: 12px; line-height: 1.4; color: #4b5563; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agenda-card-type { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.agenda-card-type.is-follow-up { color: #0369a1; }
.agenda-card-type.is-sale { color: #166534; }
.agenda-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid #eef0f3; }
.agenda-card-actions { display: flex; gap: 6px; }
.agenda-card-actions .btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 999px; }

@media (max-width: 1100px) {
    .agenda-content { grid-template-columns: 1fr; }
    .agenda-day-panel { position: static; max-height: none; }
}

@media (max-width: 900px) {
    .agenda-layout { padding: 14px 12px; }
    .agenda-toolbar { align-items: stretch; flex-direction: column; }
    .agenda-filters { justify-content: flex-start; }
    .agenda-filters .page-search { width: min(100%, 340px); }
    .agenda-cards { grid-template-columns: 1fr; }
    .calendar-grid { grid-auto-rows: minmax(64px, auto); }
    .calendar-cell-chips { display: none; }
}
