:root {
    --border-radius: 18px;
    --warning-color: #fcbf49;
    --whatsapp-color: #25d366;
    --whatsapp-color-dark: #1fa855;
    --whatsapp-surface: rgba(37, 211, 102, 0.12);

    /* --- Design tokens — Redesign Opus127 (tema claro, padrão) --------- */
    --bg: #F2F4F6;
    --panel: #FFFFFF;
    --panel2: #F7F9FA;
    --border: rgba(16, 26, 38, .09);
    --border2: rgba(16, 26, 38, .18);
    --text: #141B24;
    --text2: #5A6675;
    --text3: #96A0AE;
    --accent: #1690C9;
    --accent-soft: rgba(22, 144, 201, .10);
    --accent-line: rgba(22, 144, 201, .35);
    --green: #0FA97E;
    --green-soft: rgba(15, 169, 126, .12);
    --red: #DE3D5E;
    --red-soft: rgba(222, 61, 94, .10);
    --shadow: 0 8px 28px rgba(20, 30, 45, .08);
    --grid: rgba(16, 26, 38, .035);
    --glow1: rgba(22, 144, 201, .084);
    --glow2: rgba(15, 169, 126, .06);

    /* --- Escala de raio/espaçamento ------------------------------------ */
    --radius-card: 16px;
    --radius-control: 10px;
    --radius-pill: 999px;
    --content-padding: 32px;
    --header-height: 72px;
    --sidebar-width-collapsed: 68px;
    --sidebar-width-expanded: 224px;

    /* --- Tokens legados reapontados para os novos valores -------------- */
    --bg-color: var(--bg);
    --card-bg: var(--panel);
    --primary-color: var(--accent);
    --primary-color-dark: var(--accent);
    --text-color: var(--text);
    --muted-text: var(--text2);
    --danger-color: var(--red);
    --success-color: var(--green);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    background: var(--bg-color);
    font-family: 'Space Grotesk', system-ui, sans-serif;
    color: var(--text-color);
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

.mono-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text3);
}

.kpi-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 34px;
    font-weight: 600;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
}

.status-pill .status-dot {
    width: 7px;
    height: 7px;
}

.status-pill .status-dot.status-online {
    animation: pulseDot 2.4s infinite;
}

@media (prefers-reduced-motion: no-preference) {
    body::before {
        content: '';
        position: fixed;
        inset: 0;
        z-index: -1;
        pointer-events: none;
        background-image:
            radial-gradient(1080px 720px at 15% 0%, var(--glow1), transparent 60%),
            radial-gradient(960px 720px at 90% 100%, var(--glow2), transparent 60%),
            repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 56px),
            repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 56px);
        animation: ambientDrift 36s ease-in-out infinite;
    }
}

@keyframes ambientDrift {
    0% {
        background-position: 0% 0%, 100% 100%, 0 0, 0 0;
    }
    50% {
        background-position: 12% 8%, 88% 90%, 0 0, 0 0;
    }
    100% {
        background-position: 0% 0%, 100% 100%, 0 0, 0 0;
    }
}

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

@keyframes pulseDot {
    0% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 1;
    }
    70% {
        box-shadow: 0 0 0 6px transparent;
        opacity: .7;
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
        opacity: 1;
    }
}

@keyframes tdot {

    0%,
    100% {
        transform: translateY(0);
        opacity: .4;
    }

    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ===== Dashboard — Redesign Opus127 (spec 05) ============================= */

.dashboard-page {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    gap: 24px;
}

/* --- Hero card ----------------------------------------------------------- */
.dash-hero {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: stretch;
    min-height: 210px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    padding: 28px 32px;
}

.dash-hero-left {
    display: flex;
    flex-direction: column;
}

.dash-hero-title {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 8px 0 6px;
    color: var(--text);
}

.dash-hero-sub {
    margin: 0;
    color: var(--text2);
    font-size: 14px;
}

.dash-hero-stats {
    display: flex;
    gap: 44px;
    margin-top: auto;
    padding-top: 22px;
}

.dash-hero-stat .dash-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
    margin-bottom: 4px;
}

.dash-hero-stat .dash-stat-value.is-green {
    color: var(--green);
}

.dash-stat-unit {
    font-size: 14px;
    color: var(--text3);
    margin-left: 2px;
}

/* --- Hero orbe ----------------------------------------------------------- */
.dash-hero-orb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 210px;
}

.dash-orb-canvas {
    width: 100%;
    height: 100%;
    max-height: 230px;
    display: block;
}

.dash-orb-hint,
.dash-orb-status {
    position: absolute;
    font-size: 10px;
    color: var(--accent);
    pointer-events: none;
}

.dash-orb-hint {
    top: 0;
    right: 0;
}

.dash-orb-status {
    bottom: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text2);
}

.dash-orb-status .status-dot {
    width: 7px;
    height: 7px;
    color: var(--green);
    background: var(--green);
    animation: pulseDot 2.4s infinite;
}

/* --- KPI row ------------------------------------------------------------- */
.dash-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.kpi-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    transition: transform .18s ease, border-color .18s ease;
}

@media (prefers-reduced-motion: no-preference) {
    .kpi-card {
        opacity: 0;
        animation: fadeUp .5s ease forwards;
        animation-delay: var(--d, 0s);
    }
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-line);
}

.kpi-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
}

.kpi-card-title {
    color: var(--text2);
    font-size: 14px;
    font-weight: 500;
}

.kpi-card-delta {
    margin-top: 8px;
    font-size: 13px;
    color: var(--green);
    font-weight: 500;
}

.kpi-card-delta.is-muted {
    color: var(--text3);
}

/* --- Painéis inferiores -------------------------------------------------- */
.dash-panels {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.dash-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    padding: 22px 24px;
}

.dash-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.dash-panel-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.dash-panel-link {
    font-size: 13px;
    color: var(--accent);
}

.dash-panel-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Item de lista (agendamentos / conectores) */
.dash-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--panel2);
}

.dash-list-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.dash-list-item-sub {
    font-size: 12.5px;
    color: var(--text2);
    margin-top: 2px;
}

.dash-list-item-sub.font-mono {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text3);
}

.dash-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 16px;
    border: 1px dashed var(--border2);
    border-radius: var(--radius-control);
    color: var(--text3);
    text-align: center;
}

.dash-empty-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border2);
    border-radius: 50%;
    font-size: 20px;
    color: var(--text3);
}

/* Pills de status dos conectores */
.status-pill.is-online {
    background: var(--green-soft);
    color: var(--green);
}

.status-pill.is-online .status-dot {
    color: var(--green);
    background: var(--green);
}

/* Pulso do dot reservado para status de conexão (ex.: coluna Integrador em Empresas, Conectores no Dashboard) */
[data-field="status-integracao"] .status-pill.is-online .status-dot,
#dashboard-conectores-list .status-pill.is-online .status-dot {
    animation: pulseDot 2.4s infinite;
}

.status-pill.is-warning {
    background: var(--accent-soft);
    color: var(--accent);
}

.status-pill.is-warning .status-dot {
    color: var(--accent);
    background: var(--accent);
}

.status-pill.is-offline {
    background: var(--red-soft);
    color: var(--red);
}

.status-pill.is-offline .status-dot {
    color: var(--red);
    background: var(--red);
}

.status-pill.is-none {
    background: var(--panel2);
    color: var(--text3);
}

.status-pill.is-none .status-dot {
    color: var(--text3);
    background: var(--text3);
}

/* Execuções SQL — linhas mono */
.dash-exec-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.dash-exec-row:last-of-type {
    border-bottom: 0;
}

.dash-exec-label {
    font-size: 14px;
    color: var(--text2);
}

.dash-exec-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
}

.dash-exec-value.is-green {
    color: var(--green);
}

.dash-exec-value.is-red {
    color: var(--red);
}

.dash-exec-erro {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-control);
    background: var(--red-soft);
    border: 1px solid var(--red-soft);
}

/* --- Responsivo ---------------------------------------------------------- */
@media (max-width: 1100px) {
    .dash-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .dash-hero {
        grid-template-columns: 1fr;
    }
    .dash-hero-orb {
        order: -1;
        min-height: 180px;
    }
    .dash-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .dash-kpi-row {
        grid-template-columns: 1fr;
    }
    .dash-hero-stats {
        gap: 28px;
        flex-wrap: wrap;
    }
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: row;
}

#app:not(.is-authenticated) .sidebar,
#app:not(.is-authenticated) .app-header {
    display: none;
}

.app-main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

[data-page-metadata] {
    display: block;
    height: 100%;
    min-height: 0;
    width: 100%;
}

.page-body {
    padding: var(--content-padding) 48px 48px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-height: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    .page-body {
        animation: fadeUp .45s ease;
    }
}

.page-lead p {
    margin: 0;
    color: var(--text2);
}

[data-page-actions] {
    display: none;
}

/* --- Assistente IA (chat) --------------------------------------------- */
.assistente-shell {
    width: 100%;
    max-width: 920px;
    height: calc(100vh - 88px);
    margin: 0 auto;
}

.assistente-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;      /* permite o scroll interno das mensagens */
    padding: 8px 8px 12px;
    overflow: hidden;   /* respeita o border-radius do card */
}

.assistente-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.assistente-msg {
    display: flex;
    gap: 12px;
    animation: fadeUp .45s ease both;
}

.assistente-msg-user {
    justify-content: flex-end;
}

.assistente-bubble {
    max-width: 78%;
    padding: 12px 16px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    border-radius: 15px 15px 4px 15px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
}

.assistente-code-inline {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: .92em;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 5px;
    white-space: pre-wrap;
}

.assistente-code-block {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: .92em;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 6px 0;
    white-space: pre;
    overflow-x: auto;         /* linhas longas rolam, não estouram a bolha */
}

.assistente-code-block code {
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
}

.assistente-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistente-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.assistente-ai-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 4px;
}

.assistente-ai-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

/* Bloco stats — grid 3 colunas */
.assistente-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.assistente-stat {
    padding: 14px;
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.assistente-stat-value {
    margin: 6px 0 2px;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
}

.assistente-stat-sub {
    font-size: 11.5px;
    color: var(--text2);
}

/* Bloco ranking — barra proporcional ao fundo */
.assistente-ranks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.assistente-rank {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.assistente-rank-bar {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--accent-soft);
    z-index: 0;
}

.assistente-rank-info {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.assistente-rank-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
}

.assistente-rank-meta {
    font-size: 11px;
    color: var(--text3);
    letter-spacing: .04em;
}

.assistente-rank-val {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* Bloco nota / recomendação */
.assistente-note {
    padding: 14px 16px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    border-radius: 12px;
}

.assistente-note-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.assistente-note-icon {
    color: var(--accent);
    font-size: 14px;
    line-height: 1;
}

.assistente-note-text {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text);
}

/* Indicador de digitação */
.assistente-typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 4px;
}

.assistente-tdot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text3);
    animation: tdot 1.2s infinite ease-in-out;
}

.assistente-tdot:nth-child(2) {
    animation-delay: .2s;
}

.assistente-tdot:nth-child(3) {
    animation-delay: .4s;
}

/* Chips de sugestão */
.assistente-chips {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 4px;
}

.assistente-chips.is-empty {
    display: none;
}

.assistente-chip {
    padding: 8px 14px;
    background: var(--panel);
    border: 1px solid var(--border2);
    border-radius: var(--radius-pill);
    font-size: 12.5px;
    color: var(--text2);
    cursor: pointer;
    transition: border-color .18s ease, color .18s ease, transform .18s ease;
}

.assistente-chip:hover {
    border-color: var(--accent-line);
    color: var(--accent);
    transform: translateY(-1px);
}

/* Composer */
.assistente-composer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 16px 12px;
    background: var(--panel2);
    border: 1px solid var(--border2);
    border-radius: 20px;
    box-shadow: 0 2px 14px rgba(16, 26, 38, .06);
    transition: border-color .18s ease, box-shadow .18s ease;
}

.assistente-composer:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.assistente-input {
    width: 100%;
    min-height: 46px;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
    border: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.5;
    padding: 2px 0;
    font-family: inherit;
    color: var(--text);
    outline: none;
}

.assistente-composer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.assistente-input::placeholder {
    color: var(--text3);
}

.assistente-input:disabled {
    opacity: .6;
}

.assistente-send {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #08131B;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.assistente-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--accent-soft);
}

.assistente-send:disabled {
    opacity: .5;
    cursor: default;
}

.assistente-send .material-symbols-outlined {
    font-size: 20px;
}

@media (max-width: 640px) {
    .assistente-stats {
        grid-template-columns: 1fr;
    }
}

/* --- Sidebar: recolhida (68px) → expandida (224px) no hover ------------ */
.sidebar {
    position: sticky;
    top: 0;
    align-self: stretch;
    flex-shrink: 0;
    width: var(--sidebar-width-collapsed);
    min-height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--border);
    z-index: 20;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    transition: width .28s cubic-bezier(.4, 0, .2, 1);
}

.sidebar:hover,
.sidebar:focus-within {
    width: var(--sidebar-width-expanded);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    height: var(--header-height);
    flex-shrink: 0;
    padding: 0 16px;
}

.sidebar-logo a {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.sidebar-logo-img {
    display: block;
    height: 26px;
    width: 36px;
    object-fit: contain;
    object-position: left center;
    flex-shrink: 0;
    transition: width .28s cubic-bezier(.4, 0, .2, 1);
}

.sidebar:hover .sidebar-logo-img,
.sidebar:focus-within .sidebar-logo-img {
    width: 128px;
}

.nav-module {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    padding: 10px;
}

.nav-module a {
    padding: 11px 12px;
    border-radius: var(--radius-control);
    color: var(--text2);
    font-weight: 500;
    font-size: 13.5px;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    border-left: 2px solid transparent;
}

.nav-module .nav-label {
    opacity: 0;
    transition: opacity .22s ease;
}

.sidebar:hover .nav-label,
.sidebar:focus-within .nav-label {
    opacity: 1;
}

.material-symbols-outlined {
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24;
    font-size: 20px;
    line-height: 1;
    color: currentColor;
}

.nav-module a .material-symbols-outlined {
    font-size: 20px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* --- Ícones Lucide (icon set real recomendado no handoff, substitui os
   glifos unicode do protótipo — ver design_handoff_opus127_redesign/README.md) --- */
.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.app-header-theme-toggle .icon-theme-dark,
.app-header-theme-toggle .icon-theme-light {
    width: 17px;
    height: 17px;
    stroke-width: 1.75;
}

.app-header-theme-toggle .icon-theme-light {
    display: none;
}

[data-bs-theme="dark"] .app-header-theme-toggle .icon-theme-dark {
    display: none;
}

[data-bs-theme="dark"] .app-header-theme-toggle .icon-theme-light {
    display: block;
}

.nav-module a.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-left-color: var(--accent-line);
}

.nav-module a:hover,
.nav-module a:focus {
    background: var(--panel2);
    color: var(--text);
}

.nav-module a.active:hover,
.nav-module a.active:focus {
    color: var(--accent);
}

/* --- Header fixo (72px) -------------------------------------------------- */
.app-header {
    height: var(--header-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 32px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.app-header-page {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.app-header-code {
    font-size: 11px;
    color: var(--accent);
    letter-spacing: .14em;
    flex-shrink: 0;
}

.app-header-title {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.app-header-clock {
    font-size: 12.5px;
    color: var(--text3);
    white-space: nowrap;
}

.app-header-theme-toggle {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-control);
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text2);
    transition: color .2s ease, border-color .2s ease;
}

.app-header-theme-toggle:hover,
.app-header-theme-toggle:focus-visible {
    color: var(--accent);
    border-color: var(--accent-line);
    background: transparent;
}

/* --- Bloco de usuário no rodapé da sidebar ------------------------------- */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
    padding: 12px;
    margin: 0 4px 8px;
    border-top: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.sidebar-user-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.2;
    min-width: 0;
    opacity: 0;
    transition: opacity .22s ease;
}

.sidebar:hover .sidebar-user-text,
.sidebar:focus-within .sidebar-user-text {
    opacity: 1;
}

.sidebar-user-name {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.sidebar-user-logout {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text3);
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    text-align: left;
}

.sidebar-user-logout:hover {
    color: var(--red);
}

.whatsapp-reconnect {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.whatsapp-reconnect__qr {
    text-align: center;
}

.whatsapp-reconnect__qr-box {
    min-height: 260px;
    background: #f8f9fa;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    margin-bottom: 12px;
}

.whatsapp-reconnect__qr-box img {
    max-height: 240px;
}

.whatsapp-reconnect__status {
    font-size: 0.85rem;
    color: var(--muted-text);
}

.whatsapp-reconnect__pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f8f9fa;
    border: 1px solid rgba(17, 17, 17, 0.08);
    color: var(--muted-text);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.whatsapp-reconnect__pill .spinner-grow {
    width: 8px;
    height: 8px;
}

.whatsapp-reconnect__steps {
    max-width: 420px;
    margin: 0 auto;
    padding-top: 16px;
    border-top: 1px solid rgba(17, 17, 17, 0.08);
    text-align: left;
}

.whatsapp-reconnect__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-text);
    margin-bottom: 12px;
}

.whatsapp-reconnect__list {
    margin: 0;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #5f5f5f;
    font-size: 0.9rem;
}

.qr-connected-message {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--success-color);
    text-align: center;
    padding: 12px 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    background: rgba(56, 193, 114, 0.12);
    border: 1px solid rgba(56, 193, 114, 0.2);
}

.modal-confirm {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
}

.modal-confirm__icon {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    background: rgba(255, 77, 109, 0.12);
    border: 1px solid rgba(255, 77, 109, 0.2);
    color: var(--danger-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.modal-confirm__icon .material-symbols-outlined {
    font-size: 32px;
}

.modal-confirm__content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-confirm__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-confirm__text {
    margin: 0;
    color: var(--muted-text);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-confirm__meta {
    margin: 0;
    color: var(--muted-text);
    font-size: 0.9rem;
}

.modal-confirm__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
}

.modal-confirm__actions .btn {
    min-width: 140px;
}

.whatsapp-connect {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
}

.whatsapp-connect__icon {
    width: 96px;
    height: 96px;
    border-radius: 16px;
    background: #f8f9fa;
    border: 1px solid rgba(17, 17, 17, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.whatsapp-connect__icon .material-symbols-outlined {
    font-size: 42px;
}

.whatsapp-connect__content {
    max-width: 420px;
}

.whatsapp-connect__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 8px;
}

.whatsapp-connect__text {
    margin: 0;
    color: var(--muted-text);
    line-height: 1.5;
}

.whatsapp-connect__cta {
    width: 100%;
    max-width: 420px;
}

.whatsapp-tab-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.whatsapp-pane {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.whatsapp-pane .whatsapp-scroll {
    flex: 1;
    min-height: 0;
}

.whatsapp-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--whatsapp-surface), rgba(255, 255, 255, 0.6));
    border: 1px solid rgba(37, 211, 102, 0.25);
}

.whatsapp-toolbar__content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.whatsapp-toolbar__icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    color: var(--whatsapp-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 24px rgba(17, 17, 17, 0.1);
    flex-shrink: 0;
}

.whatsapp-toolbar__icon .material-symbols-outlined {
    font-size: 26px;
}

.whatsapp-toolbar__svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.whatsapp-toolbar__eyebrow {
    margin: 0 0 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-text);
}

.whatsapp-toolbar__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
}

.whatsapp-toolbar__subtitle {
    margin: 6px 0 0;
    color: var(--muted-text);
    max-width: 460px;
}

.whatsapp-toolbar__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.whatsapp-toolbar__hint {
    font-size: 0.8rem;
    color: var(--muted-text);
}

.btn.btn-whatsapp {
    background: var(--whatsapp-color);
    color: #fff;
    border: 1px solid transparent;
    padding: 12px 26px;
    min-height: 48px;
    box-shadow: 0 14px 24px rgba(37, 211, 102, 0.25);
}

.btn.btn-whatsapp:hover,
.btn.btn-whatsapp:focus {
    background: var(--whatsapp-color-dark);
    color: #fff;
    border-color: var(--whatsapp-color-dark);
    transform: translateY(-1px);
}

.whatsapp-scroll {
    margin-top: 0;
}

.whatsapp-table-shell {
    background: transparent;
    border-radius: var(--radius-card);
}

.whatsapp-table {
    background: transparent;
}

@media (max-width: 960px) {
    .whatsapp-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .whatsapp-toolbar__content {
        align-items: flex-start;
    }

    .whatsapp-toolbar__actions {
        align-items: stretch;
    }

    .whatsapp-toolbar__hint {
        text-align: left;
    }

    .btn.btn-whatsapp {
        width: 100%;
    }
}



.min-vh-100 {
    min-height: 100vh !important;
}

.py-5 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
}

.shadow-sm {
    box-shadow: 0 10px 24px rgba(17, 17, 17, 0.08) !important;
}



.btn.is-loading {
    pointer-events: none;
}

.btn.is-loading .loading-spinner {
    width: 1.1em;
    height: 1.1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: loading-spin 0.75s linear infinite;
}

.btn.is-loading .loading-text {
    font-weight: 600;
}

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.text-warning {
    color: var(--warning-color) !important;
}

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    min-height: auto;
}

.btn-icon svg {
    pointer-events: none;
}

.dropdown .dropdown-menu {
    min-width: 9rem;
    padding: 0.5rem 0;
    margin: 0;
    border-radius: var(--radius-control);
    border: 1px solid var(--border2);
    background: var(--panel);
    box-shadow: var(--shadow);
    z-index: 20;
}

.card {
    border-radius: var(--radius-card);
    background-color: var(--panel);
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 22px 24px;
}

.form-control,
.form-select,
.btn {
    border-radius: var(--radius-control);
}

.toast {
    border-radius: var(--radius-control);
    background-color: var(--panel);
    border: 1px solid var(--border2);
    box-shadow: var(--shadow);
    color: var(--text);
}

.dropdown .dropdown-item {
    width: 100%;
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: start;
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown .dropdown-item:hover,
.dropdown .dropdown-item:focus {
    background: rgba(17, 17, 17, 0.08);
    outline: none;
}

.dropdown .dropdown-item.disabled,
.dropdown .dropdown-item:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}



.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 14px;
}

.badge-status {
    background: rgba(17, 17, 17, 0.08);
    color: var(--muted-text);
}

.badge-success-soft {
    background: rgba(62, 207, 142, 0.18);
    color: var(--success-color);
}

.badge-warning-soft {
    background: rgba(252, 191, 73, 0.25);
    color: #c97a11;
}

.badge-danger-soft {
    background: rgba(255, 77, 109, 0.2);
    color: var(--danger-color);
}



.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 12px 0 4px;
}

.text-muted {
    color: var(--muted-text) !important;
}

.border-0 {
    border: 0 !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-dark {
    color: var(--text-color) !important;
}

.bg-light {
    background: #f6f7fb !important;
}

.text-end {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

.text-decoration-none {
    text-decoration: none !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.fw-semibold {
    font-weight: 600 !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.25rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.px-0 {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.h5 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.h4 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.small {
    font-size: 0.8rem;
}



.table-responsive {
    width: 100%;
    overflow-x: auto;
}

/* ===== Padrão de tabela — Redesign Opus127 (spec 08) ==================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.data-table thead th {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text3);
    padding: 4px 16px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.data-table thead th.text-end {
    text-align: right;
}

.data-table tbody td {
    padding: 15px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr {
    transition: background .18s ease;
}

.data-table tbody tr:hover {
    background: var(--panel2);
}

.data-table .is-mono {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text2);
    font-size: 13px;
}

/* Célula de identidade com avatar */
.data-cell-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.data-avatar {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    color: var(--accent);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.data-avatar.is-circle {
    border-radius: 50%;
}

.data-avatar.is-square {
    border-radius: 10px;
}

.data-cell-name {
    font-weight: 600;
    color: var(--text);
}

.data-cell-sub {
    font-size: 12.5px;
    color: var(--text2);
    margin-top: 2px;
}

/* Pills de status dentro da tabela (reusa .status-pill.is-*) */
.data-table .status-pill .status-dot {
    border-radius: 50%;
}

.status-pill.is-solid {
    background: var(--green-soft);
    color: var(--green);
}

/* Footer de contagem mono */
.data-table-footer {
    padding: 15px 4px 0;
    border-top: 1px solid var(--border);
    margin-top: -1px;
}

.data-table-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text3);
}

/* Toasts mapeados aos tokens do redesign (spec 09) ====================== */
.toast.toast-token {
    border-radius: var(--radius-control);
    border: 1px solid var(--border2);
    box-shadow: var(--shadow);
    background: var(--panel);
    color: var(--text);
}

.toast.toast-token .toast-body {
    color: inherit;
}

.toast.toast-token.toast-accent {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}

.toast.toast-token.toast-success {
    background: var(--green-soft);
    border-color: var(--green);
    color: var(--green);
}

.toast.toast-token.toast-danger {
    background: var(--red-soft);
    border-color: var(--red);
    color: var(--red);
}



.data-grid-card {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.data-grid-card>* {
    flex-shrink: 0;
}

.data-grid-card .data-grid-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    margin: 0 -24px -24px;
    padding: 0 24px 24px;
}

.data-grid-card .data-grid-scroll .table-responsive {
    overflow-y: auto;
}

.data-grid-card .data-grid-scroll .table {
    margin-bottom: 0;
}

.usuario-detail-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.usuario-detail-card {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    gap: 0;
}

.usuario-detail-meta-item {
    font-size: 0.9rem;
    color: var(--muted-text);
}

.usuario-detail-agendamentos-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.usuario-detail-agendamentos-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.usuario-detail-filtros {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius-card);
    border: 1px solid var(--border);
    background: transparent;
}

.usuario-detail-filtros[hidden] {
    display: none !important;
}

.usuario-detail-filtros-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 40px;
}

.usuario-detail-filtros-toggle-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.1;
}

.usuario-detail-filtros-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0;
}

.usuario-detail-filtros-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--primary-color);
    flex-shrink: 0;
}

.usuario-detail-filtros-icon-glyph {
    display: block;
    font-size: 18px;
    line-height: 1;
    transform: translateY(0);
}

.usuario-detail-filtros-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
}

.usuario-detail-filtro-item {
    min-width: 0;
}

.usuario-detail-filtro-item--empresa {
    grid-column: span 3;
}

.usuario-detail-filtro-item--frequencia {
    grid-column: span 2;
}

.usuario-detail-filtro-item--agente {
    grid-column: span 2;
}

.usuario-detail-filtro-item--status {
    grid-column: span 1;
}

.usuario-detail-filtro-item .form-label {
    margin-bottom: 6px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text2);
    letter-spacing: 0.01em;
}

.usuario-detail-filtro-item--acao {
    grid-column: span 3;
}

.usuario-detail-filtro-item--limpar {
    grid-column: span 1;
    display: flex;
    align-items: flex-end;
}

.usuario-detail-filtro-item--limpar .btn {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
}

.usuario-detail-filtro-item .form-control,
.usuario-detail-filtro-item .form-select {
    min-height: 46px;
    border-color: var(--border2);
    background: var(--panel);
}

.tools-filtros-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.tools-filtros-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.tools-filtros {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius-card);
    border: 1px solid var(--border);
    background: transparent;
}

.tools-filtros[hidden] {
    display: none !important;
}

.tools-filtros-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 40px;
}

.tools-filtros-toggle-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.1;
}

.tools-filtros-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0;
}

.tools-filtros-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--primary-color);
    flex-shrink: 0;
}

.tools-filtros-icon-glyph {
    display: block;
    font-size: 18px;
    line-height: 1;
    transform: translateY(0);
}

.tools-filtros-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
}

.tools-filtro-item {
    min-width: 0;
}

.tools-filtro-item--nome {
    grid-column: span 3;
}

.tools-filtro-item--descricao {
    grid-column: span 3;
}

.tools-filtro-item--erp {
    grid-column: span 2;
}

.tools-filtro-item--agente {
    grid-column: span 2;
}

.tools-filtro-item--status {
    grid-column: span 1;
}

.tools-filtro-item .form-label {
    margin-bottom: 6px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text2);
    letter-spacing: 0.01em;
}

.tools-filtro-item--limpar {
    grid-column: span 1;
    display: flex;
    align-items: flex-end;
}

.tools-filtro-item--limpar .btn {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
}

.tools-filtro-item .form-control,
.tools-filtro-item .form-select {
    min-height: 46px;
    border-color: var(--border2);
    background: var(--panel);
}

@media (max-width: 1260px) {
    .usuario-detail-filtros-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }

    .tools-filtros-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }

    .usuario-detail-filtro-item--empresa,
    .usuario-detail-filtro-item--acao {
        grid-column: span 3;
    }

    .tools-filtro-item--nome,
    .tools-filtro-item--descricao {
        grid-column: span 3;
    }

    .usuario-detail-filtro-item--frequencia,
    .usuario-detail-filtro-item--agente {
        grid-column: span 2;
    }

    .tools-filtro-item--erp,
    .tools-filtro-item--agente {
        grid-column: span 2;
    }

    .usuario-detail-filtro-item--status,
    .usuario-detail-filtro-item--limpar {
        grid-column: span 1;
    }

    .tools-filtro-item--status,
    .tools-filtro-item--limpar {
        grid-column: span 1;
    }
}

@media (max-width: 960px) {
    .usuario-detail-filtros-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tools-filtros-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .usuario-detail-filtro-item--empresa,
    .usuario-detail-filtro-item--frequencia,
    .usuario-detail-filtro-item--agente,
    .usuario-detail-filtro-item--status,
    .usuario-detail-filtro-item--acao,
    .usuario-detail-filtro-item--limpar {
        grid-column: span 1;
    }

    .usuario-detail-filtro-item--limpar .btn {
        min-height: 44px;
    }

    .tools-filtro-item--nome,
    .tools-filtro-item--descricao,
    .tools-filtro-item--erp,
    .tools-filtro-item--agente,
    .tools-filtro-item--status,
    .tools-filtro-item--limpar {
        grid-column: span 1;
    }

    .tools-filtro-item--limpar .btn {
        min-height: 44px;
    }
}

.usuario-detail-table-wrap {
    display: flex;
    flex: 1;
    min-height: 0;
}

.usuario-detail-table-wrap .table-responsive {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--panel);
}

.usuario-detail-card .data-grid-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    margin-top: 0;
}

.usuario-detail-table {
    min-width: 760px;
}

.usuario-detail-table--agendamentos {
    min-width: 1240px;
}

.usuario-detail-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
    padding: 14px 16px;
}

.usuario-detail-form {
    margin-top: 20px !important;
    padding-top: 20px;
    border-top: 1px solid rgba(17, 17, 17, 0.08);
}

.usuario-detail-form .form-check {
    min-height: 44px;
}

.usuario-detail-form--modal {
    margin-top: 0 !important;
    padding-top: 0;
    border-top: 0;
}

.usuario-detail-form--modal .form-control:disabled,
.usuario-detail-form--modal .form-select:disabled {
    background: #f6f7fb;
    color: var(--muted-text);
    cursor: not-allowed;
}

.usuario-agendamento-modal .modal-dialog {
    width: min(920px, var(--modal-viewport-width));
}

.usuario-agendamento-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-x: hidden;
}

.usuario-agendamento-modal .modal-body .alert {
    margin-bottom: 0;
}

/* Seções do formulário de agendamento */
.agendamento-form-sections {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.agendamento-section {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.agendamento-section+.agendamento-section {
    padding-top: 16px;
    border-top: 1px solid rgba(17, 17, 17, 0.06);
}

.agendamento-section-title {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 0.75rem 10px;
    margin: 0;
}

.agendamento-section-title .material-symbols-outlined {
    font-size: 1rem;
}





.sql-editor-hidden-input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    border: 0 !important;
    clip: rect(0, 0, 0, 0) !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

.tool-form .form-group-sql {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-form .form-group-sql textarea[data-sql-editor-mode="scroll"] {
    min-height: clamp(260px, 42vh, 460px);
    max-height: clamp(320px, 65vh, 560px);
    overflow: auto;
    resize: vertical;
}

.tool-form .form-group-sql .sql-editor-view[data-mode="scroll"] {
    min-height: clamp(260px, 48vh, 560px);
    max-height: clamp(320px, 72vh, 560px);
}

.sql-editor-view {
    position: relative;
    width: 100%;
    border: 1px solid #d8d8d8;
    border-radius: 12px;
    overflow: hidden;
    background: #f2f2f2;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.sql-editor-view[data-mode="scroll"] {
    height: auto;
    min-height: clamp(220px, 35vh, 420px);
    max-height: clamp(280px, 62vh, 560px);
}

.sql-editor-view.ace_editor {
    border-radius: 12px;
    background: #f2f2f2;
    color: var(--text-color);
}

.sql-editor-view.ace_editor .ace_scroller,
.sql-editor-view.ace_editor .ace_content {
    border-radius: 12px;
}

.sql-editor-view.ace_editor .ace_scroller {
    padding: 12px 0;
}

.sql-editor-view.ace_editor .ace_content {
    margin-left: 0;
}

.sql-editor-view.ace_editor .ace_print-margin {
    display: none;
}

.sql-editor-view.ace_editor .ace_gutter {
    background: rgba(17, 17, 17, 0.05);
    color: var(--muted-text);
}

.sql-editor-view.ace_editor .ace_gutter-active-line {
    background: rgba(17, 17, 17, 0.12);
}

.sql-editor-view.ace_editor .ace_marker-layer .ace_active-line {
    background: rgba(17, 17, 17, 0.08);
}

.sql-editor-view.ace_editor.ace_focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
}





/* Customizações visuais dos modais (o posicionamento e backdrop são geridos pelo Bootstrap) */

.modal-dialog.modal-tool {
    --modal-tool-max-height: min(var(--modal-viewport-height, 82vh), 82vh);
    width: var(--modal-tool-width, min(860px, 90vw));
}

.modal-lg {
    --bs-modal-width: min(860px, 90vw);
}


.modal-content {
    border-radius: var(--radius-card) !important;
    border: 1px solid var(--border) !important;
    background-color: var(--panel) !important;
    color: var(--text) !important;
    box-shadow: var(--shadow) !important;
    padding: 24px !important;
}

.modal-header {
    border-bottom: none;
    padding: 0 0 12px;
    gap: 12px;
}

.modal-title {
    margin: 0;
}

.modal-footer {
    border-top: none;
    padding: 12px 0 0;
    gap: 12px;
}

.modal-body {
    padding: 12px 0;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

#modalEmpresaForm .modal-body,
#modalSoftwareHouseForm .modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-x: hidden;
    overflow-y: hidden;
}

#form-empresa,
#form-software-house {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

#modalEmpresaForm .modal-dialog,
#modalSoftwareHouseForm .modal-dialog {
    width: min(920px, var(--modal-viewport-width));
}

#modalEmpresaForm .modal-content,
#modalSoftwareHouseForm .modal-content {
    min-height: clamp(560px, 65vh, 640px);
    max-height: min(640px, var(--modal-viewport-height));
    overflow: hidden;
}

#form-empresa .modal-tab-content,
#form-software-house .modal-tab-content {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

#form-empresa .modal-tab-content .tab-pane,
#form-software-house .modal-tab-content .tab-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

#form-empresa .tab-pane>.row {
    margin: 0;
    display: grid;
    gap: 16px 24px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

#form-empresa .tab-pane>.row>[class*="col-"] {
    width: 100%;
    padding: 0;
}

.modal-tabs {
    border-bottom: 1px solid rgba(17, 17, 17, 0.15);
    gap: 0;
}

.modal-tabs .nav-item {
    margin: 0;
}

.modal-tabs .nav-link {
    border-radius: 12px 12px 0 0;
    padding: 10px 24px;
    background: transparent;
    color: var(--muted-text);
    border: 1px solid transparent;
    border-bottom: none;
    font-weight: 600;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.modal-tabs .nav-link:hover,
.modal-tabs .nav-link:focus {
    color: var(--primary-color);
}

.modal-tabs .nav-link.active {
    background: #fff;
    color: var(--primary-color);
    border-color: rgba(17, 17, 17, 0.15);
    border-bottom: 1px solid #fff;
    position: relative;
    bottom: -1px;
}

.modal-tool .modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    max-height: max(320px, calc(var(--modal-tool-max-height, var(--modal-viewport-height)) - 160px));
}

.modal-tool .modal-body form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-tool .modal-body form .form-group-sql,
.modal-tool .modal-body .form-group-sql {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: initial;
}

.modal-tool .modal-body form .form-group-sql label,
.modal-tool .modal-body .form-group-sql label {
    flex-shrink: 0;
}

.modal-tool .modal-body form .form-group-sql textarea[data-sql-editor-mode="scroll"],
.modal-tool .modal-body .form-group-sql textarea[data-sql-editor-mode="scroll"] {
    flex: initial;
    min-height: 200px;
    max-height: none;
    resize: vertical;
}

.modal-tool .modal-body form .form-group-sql .sql-editor-view,
.modal-tool .modal-body .form-group-sql .sql-editor-view {
    flex: initial;
    min-height: 200px;
    max-height: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: none;
    padding-top: 12px;
    flex-shrink: 0;
}



.sql-preview {
    background: #1a1a1a;
    color: #f5f5f5;
    border-radius: 14px;
    padding: 18px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}


.status-online {
    background: var(--success-color);
}

.status-offline {
    background: var(--danger-color);
}



.loading-state {
    padding: 48px;
    text-align: center;
    color: var(--text2);
}

.empty {
    padding: 24px;
    text-align: center;
    color: var(--text2);
}

.noscript-alert {
    margin: 24px;
    padding: 16px;
    background: rgba(255, 77, 109, 0.16);
    color: var(--danger-color);
    border-radius: 12px;
}

.modal-open {
    overflow: hidden;
}



@media (max-width: 1200px) {
    .page-body {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .usuario-detail-agendamentos-actions {
        width: 100%;
        justify-content: stretch;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .tools-filtros-actions {
        width: 100%;
        justify-content: stretch;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .usuario-detail-agendamentos-actions .btn {
        width: 100%;
    }

    .tools-filtros-actions .btn {
        width: 100%;
    }

    .usuario-detail-filtros-body {
        gap: 14px;
    }

    .tools-filtros-body {
        gap: 14px;
    }

    .usuario-detail-filtros-grid {
        grid-template-columns: 1fr;
    }

    .tools-filtros-grid {
        grid-template-columns: 1fr;
    }

    .usuario-detail-filtro-item--empresa,
    .usuario-detail-filtro-item--frequencia,
    .usuario-detail-filtro-item--agente,
    .usuario-detail-filtro-item--status,
    .usuario-detail-filtro-item--acao,
    .usuario-detail-filtro-item--limpar {
        grid-column: span 1;
    }

    .usuario-detail-filtro-item--limpar .btn {
        width: 100%;
    }

    .tools-filtro-item--nome,
    .tools-filtro-item--descricao,
    .tools-filtro-item--erp,
    .tools-filtro-item--agente,
    .tools-filtro-item--status,
    .tools-filtro-item--limpar {
        grid-column: span 1;
    }

    .tools-filtro-item--limpar .btn {
        width: 100%;
    }

    .usuario-detail-table--agendamentos {
        min-width: 1080px;
    }
}

.login-logo {
    width: 250px;
    /* ajuste ao tamanho desejado */
    height: auto;
}

/* ==========================================================================
   Tela de Login / Definição de senha (redesign Opus127 — spec 04)
   ========================================================================== */

/* Na tela de login o shell (sidebar/header) já é ocultado via .is-authenticated.
   Garantimos que o conteúdo ocupe a viewport inteira, sem o padding de página. */
body.login-view .app-content {
    overflow-y: auto;
    overflow-x: hidden;
}

body.login-view [data-page-metadata] {
    animation: none;
}

.login-layout {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    min-height: 100vh;
    width: 100%;
}

.login-layout-single {
    grid-template-columns: 1fr;
}

/* --- Coluna esquerda: painel visual ----------------------------------- */
.login-visual {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 44px 52px;
    border-right: 1px solid var(--border);
    min-width: 0;
}

.login-visual-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.login-visual-logo {
    width: 168px;
    height: auto;
}

.login-visual-tag {
    color: var(--accent);
    white-space: nowrap;
}

.login-orb-wrap {
    position: relative;
    align-self: center;
    width: 100%;
    max-width: 520px;
    aspect-ratio: 520 / 420;
}

.login-orb-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.login-orb-tag {
    position: absolute;
    pointer-events: none;
}

.login-orb-tag-tl {
    top: 6%;
    left: 0;
}

.login-orb-tag-br {
    bottom: 6%;
    right: 0;
}

.login-headline {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.01em;
    color: var(--text);
    margin: 0 0 20px;
}

.login-visual-stats {
    display: flex;
    gap: 40px;
}

.login-visual-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.login-visual-stat-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.login-visual-stat .mono-label {
    font-size: 10px;
}

/* --- Coluna direita: formulário --------------------------------------- */
.login-form-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 44px 32px;
    min-width: 0;
}

.login-form-box {
    width: 100%;
    max-width: 380px;
    animation: fadeUp .6s ease;
}

@media (prefers-reduced-motion: reduce) {
    .login-form-box {
        animation: none;
    }
}

/* Logo exibida apenas quando o painel visual está oculto (mobile / reset). */
.login-form-logo {
    display: none;
    width: 180px;
    height: auto;
    margin-bottom: 28px;
}

.login-form-eyebrow {
    display: block;
    color: var(--accent);
    margin-bottom: 12px;
}

.login-form-title {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--text);
    margin: 0 0 6px;
}

.login-form-sub {
    color: var(--text2);
    font-size: 14px;
    margin: 0 0 28px;
}

.login-form-box .form-label {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 6px;
}

.login-form-box .form-control {
    background: var(--panel);
    border: 1px solid var(--border2);
    border-radius: var(--radius-control);
    color: var(--text);
    padding: 12px 14px;
}

.login-form-box .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--panel);
}

.login-form-box .alert-danger {
    background: var(--red-soft);
    border: 1px solid var(--red);
    color: var(--red);
    border-radius: var(--radius-control);
    font-size: 13px;
}

.login-submit {
    margin-top: 6px;
    padding: 12px 16px;
    font-weight: 600;
}

/* Texto escuro sobre o accent, conforme handoff (spec 04). */
[data-bs-theme="dark"] .login-submit.btn-primary {
    --bs-btn-color: #08131B;
    --bs-btn-hover-color: #08131B;
    --bs-btn-active-color: #08131B;
}

.login-form-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 22px;
}

.login-forgot-link {
    color: var(--accent);
    font-size: 14px;
    text-decoration: none;
}

.login-forgot-link:hover {
    text-decoration: underline;
}

.login-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border2);
    border-radius: var(--radius-pill);
    padding: 6px 12px;
    color: var(--text3);
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}

.login-theme-toggle:hover {
    border-color: var(--accent-line);
    color: var(--accent);
}

.login-theme-toggle .material-symbols-outlined {
    font-size: 16px;
}

/* --- Responsivo: some o painel visual, centraliza o formulário -------- */
@media (max-width: 900px) {
    .login-layout {
        grid-template-columns: 1fr;
    }

    .login-visual {
        display: none;
    }

    .login-form-logo {
        display: block;
    }
}

.font-monospace {
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
}

/* ==========================================================================
   Global Button, Switch & Color Overrides
   ========================================================================== */

/* --- Bootstrap core color variables ------------------------------------ */
:root {
    --bs-primary: var(--accent);
    --bs-primary-rgb: 22, 144, 201;
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 22, 144, 201;
    --bs-link-hover-color: var(--accent);
    --bs-link-hover-color-rgb: 22, 144, 201;
    --bs-focus-ring-color: var(--accent-line);
    --bs-focus-ring-width: 0.25rem;
}

/* --- Primary Buttons (accent background) -------------------------------- */
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-bg: var(--accent);
    --bs-btn-active-border-color: var(--accent);
    --bs-btn-color: #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-active-color: #ffffff;
    --bs-btn-disabled-bg: var(--text3);
    --bs-btn-disabled-border-color: var(--text3);
    --bs-btn-focus-shadow-rgb: 22, 144, 201;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-soft);
}

/* --- Secondary / Cancel Buttons --------------------------------------- */
.btn-outline-secondary {
    --bs-btn-color: var(--text-color);
    --bs-btn-border-color: var(--border2);
    --bs-btn-bg: transparent;
    --bs-btn-hover-bg: var(--accent-soft);
    --bs-btn-hover-color: var(--accent);
    --bs-btn-hover-border-color: var(--accent-line);
    --bs-btn-active-bg: var(--accent-soft);
    --bs-btn-active-color: var(--accent);
    --bs-btn-active-border-color: var(--accent-line);
    --bs-btn-focus-shadow-rgb: 22, 144, 201;
}

/* --- Focus rings: inputs, selects, textareas, buttons ------------------ */
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible,
.btn-primary:focus,
.btn-primary:focus-visible,
.btn-outline-secondary:focus,
.btn-outline-secondary:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.25rem var(--accent-soft);
    outline: none;
}

.form-control,
.form-select {
    background-color: var(--panel);
    border-color: var(--border2);
    color: var(--text-color);
    font-size: 0.875rem;
}

/* --- Checkboxes & radio checked --------------------------------------- */
.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* --- Switches: accent when ON ----------------------------------------- */
.form-switch .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(17, 17, 17, 0.18);
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%2817%2C17%2C17%2C0.35%29'/%3e%3c/svg%3e");
    --bs-form-switch-focus-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%2817%2C17%2C17%2C0.35%29'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked:focus {
    --bs-form-switch-focus-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    box-shadow: 0 0 0 0.25rem var(--accent-soft);
}

/* --- Bootstrap Dropdown: highlighted option --------------------------- */
.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

/* --- Bootstrap Nav / Tabs active -------------------------------------- */
.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    color: var(--primary-color);
    border-color: rgba(17, 17, 17, 0.15) rgba(17, 17, 17, 0.15) #fff;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
    color: var(--primary-color);
}

.nav-pills .nav-link.active,
.nav-pills .show>.nav-link {
    background-color: var(--primary-color);
    color: #fff;
}

/* --- Pagination ------------------------------------------------------- */
.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.page-link {
    color: var(--primary-color);
}

.page-link:hover {
    color: var(--primary-color-dark);
}

.page-link:focus {
    box-shadow: 0 0 0 0.25rem rgba(17, 17, 17, 0.18);
}

/* --- Progress bar / spinner ------------------------------------------ */
.progress-bar {
    background-color: var(--primary-color);
}

.spinner-border.text-primary,
.spinner-grow.text-primary {
    color: var(--primary-color) !important;
}

/* --- Badge primary ----------------------------------------------------- */
.badge.bg-primary,
.badge.text-bg-primary {
    background-color: var(--primary-color) !important;
    color: #fff;
}

/* --- Native select option highlighted (Webkit / Firefox) -------------- */
option:checked,
option:checked:focus {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

option:hover,
option:focus,
option:active {
    background-color: rgba(17, 17, 17, 0.08) !important;
    color: var(--text-color) !important;
}

/* --- Text selection highlight ----------------------------------------- */
::selection {
    background-color: rgba(17, 17, 17, 0.18);
    color: inherit;
}

/* ==========================================================================
   Custom Select Dropdown
   ========================================================================== */

.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 46px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--panel);
    background-clip: padding-box;
    border: 1px solid var(--border2);
    border-radius: var(--radius-control);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
}

.custom-select-trigger:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 0.25rem var(--accent-soft);
}

.custom-select-wrapper.is-disabled .custom-select-trigger {
    background-color: #f6f7fb;
    color: var(--muted-text);
    cursor: not-allowed;
    pointer-events: none;
}

.custom-select-trigger-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-trigger-icon {
    flex-shrink: 0;
    color: var(--muted-text);
    transition: transform 0.18s ease;
    display: flex;
    align-items: center;
}

.custom-select-wrapper.is-open .custom-select-trigger-icon {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    display: none;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 1050;
    background: var(--panel);
    border: 1px solid var(--border2);
    border-radius: var(--radius-control);
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
}

.custom-select-wrapper.is-open .custom-select-dropdown {
    display: block;
}

.custom-select-wrapper.opens-up .custom-select-dropdown {
    top: auto;
    bottom: calc(100% + 4px);
}

.custom-select-option {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color);
    transition: background 0.12s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-select-option:hover {
    background: rgba(17, 17, 17, 0.06);
}

.custom-select-option.is-selected {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.custom-select-option.is-selected:hover {
    background: var(--accent-soft);
}

.custom-select-option.is-disabled {
    color: var(--muted-text);
    cursor: not-allowed;
    pointer-events: none;
}

.custom-select-option.is-disabled {
    color: var(--muted-text);
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   Dark Theme
   Ativado via atributo data-bs-theme="dark" nativo do Bootstrap no elemento <html>
   ========================================================================== */

[data-bs-theme="dark"] {
    /* --- Design tokens — Redesign Opus127 (tema escuro) ---------------- */
    --bg: #0A0D11;
    --panel: #11161D;
    --panel2: #161C25;
    --border: rgba(255, 255, 255, .07);
    --border2: rgba(255, 255, 255, .14);
    --text: #E8EDF2;
    --text2: #8B96A5;
    --text3: #57616F;
    --accent: #29ABE2;
    --accent-soft: rgba(41, 171, 226, .12);
    --accent-line: rgba(41, 171, 226, .35);
    --green: #2AD4A6;
    --green-soft: rgba(42, 212, 166, .12);
    --red: #FF5C7A;
    --red-soft: rgba(255, 92, 122, .12);
    --shadow: 0 10px 36px rgba(0, 0, 0, .38);
    --grid: rgba(255, 255, 255, .028);
    --glow1: rgba(41, 171, 226, .084);
    --glow2: rgba(42, 212, 166, .06);

    /* --- Variáveis de cor principais (legado reapontado) ---------------- */
    --bg-color: var(--bg);
    --card-bg: var(--panel);
    --text-color: var(--text);
    --muted-text: var(--text2);
    --primary-color: var(--accent);
    --primary-color-dark: var(--accent);

    /* --- Variáveis do Bootstrap customizadas p/ dark mode -------------- */
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border2);
    --bs-border-color-translucent: var(--border);
    --bs-primary: var(--accent);
    --bs-primary-rgb: 41, 171, 226;
    --bs-link-color: var(--accent);
    --bs-link-hover-color: var(--accent);
    --bs-focus-ring-color: var(--accent-line);
    --bs-card-bg: var(--panel);
    --bs-modal-bg: var(--panel);
    --bs-modal-color: var(--text);
    --bs-secondary-bg: var(--panel2);
}

/* --- Body e fundo geral ------------------------------------------------ */
[data-bs-theme="dark"] body {
    background: var(--bg-color);
    color: var(--text-color);
}

/* --- Sidebar/header: já usam tokens (--panel, --accent-soft…), sem necessidade de overrides --- */

/* --- Cards ------------------------------------------------------------- */
[data-bs-theme="dark"] .card {
    background-color: var(--panel);
    border-color: var(--border);
    color: var(--text-color);
}

[data-bs-theme="dark"] .shadow-sm {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4) !important;
}

[data-bs-theme="dark"] .bg-light {
    background: #1a1a1c !important;
}

/* --- Dropdowns --------------------------------------------------------- */
[data-bs-theme="dark"] .dropdown .dropdown-menu {
    background: var(--panel2);
    border-color: var(--border2);
    box-shadow: var(--shadow);
    color: var(--text);
}

[data-bs-theme="dark"] .dropdown .dropdown-item {
    color: #e8e8e8;
}

[data-bs-theme="dark"] .dropdown .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* --- Formulários: inputs, selects, textareas --------------------------- */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--panel);
    color: var(--text-color);
    border-color: var(--border2);
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: var(--text3);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: var(--panel);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.25rem var(--accent-soft);
    color: var(--text-color);
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-select:disabled,
[data-bs-theme="dark"] .usuario-detail-form--modal .form-control:disabled,
[data-bs-theme="dark"] .usuario-detail-form--modal .form-select:disabled {
    background-color: #101010;
    color: var(--muted-text);
    border-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .form-label {
    color: var(--text-color);
}

/* --- Labels de filtros ------------------------------------------------- */
[data-bs-theme="dark"] .usuario-detail-filtro-item .form-label,
[data-bs-theme="dark"] .tools-filtro-item .form-label {
    color: var(--muted-text);
}

[data-bs-theme="dark"] .usuario-detail-filtro-item .form-control,
[data-bs-theme="dark"] .usuario-detail-filtro-item .form-select,
[data-bs-theme="dark"] .tools-filtro-item .form-control,
[data-bs-theme="dark"] .tools-filtro-item .form-select {
    background-color: #1a1a1c;
    border-color: rgba(255, 255, 255, 0.15);
}

/* --- Painéis de filtros ------------------------------------------------ */
[data-bs-theme="dark"] .usuario-detail-filtros,
[data-bs-theme="dark"] .tools-filtros {
    border-color: rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, #18181a 0%, #141414 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .usuario-detail-filtros-icon,
[data-bs-theme="dark"] .tools-filtros-icon {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* --- Tabelas (Bootstrap v5 native overrides) --------------------------- */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-color);
    --bs-table-border-color: rgba(255, 255, 255, 0.1);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    --bs-table-hover-color: var(--text-color);
}

[data-bs-theme="dark"] .table-responsive {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .usuario-detail-table-wrap .table-responsive {
    background: var(--panel);
    border-color: var(--border);
}

[data-bs-theme="dark"] .usuario-detail-table thead th {
    background: var(--panel);
}

[data-bs-theme="dark"] .table tbody td,
[data-bs-theme="dark"] .table tbody th {
    color: var(--text-color) !important;
}

[data-bs-theme="dark"] .text-muted {
    color: var(--muted-text) !important;
}

[data-bs-theme="dark"] .badge-status {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

/* --- Botões ------------------------------------------------------------ */
[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: var(--text);
    --bs-btn-border-color: var(--border2);
    --bs-btn-hover-bg: var(--accent-soft);
    --bs-btn-hover-color: var(--accent);
    --bs-btn-hover-border-color: var(--accent-line);
    --bs-btn-active-bg: var(--accent-soft);
    --bs-btn-active-color: var(--accent);
    --bs-btn-active-border-color: var(--accent-line);
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-color: #08131B;
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-hover-color: #08131B;
    --bs-btn-active-bg: var(--accent);
    --bs-btn-active-color: #08131B;
}

/* --- Focus rings ------------------------------------------------------- */
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] .form-check-input:focus,
[data-bs-theme="dark"] .btn:focus-visible,
[data-bs-theme="dark"] .btn-primary:focus,
[data-bs-theme="dark"] .btn-primary:focus-visible,
[data-bs-theme="dark"] .btn-outline-secondary:focus,
[data-bs-theme="dark"] .btn-outline-secondary:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.25rem var(--accent-soft);
}

/* --- Checkboxes e switches -------------------------------------------- */
[data-bs-theme="dark"] .form-check-input {
    background-color: var(--panel2);
    border-color: var(--border2);
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

[data-bs-theme="dark"] .form-switch .form-check-input {
    background-color: var(--panel2);
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255%2C255%2C255%2C0.6%29'/%3e%3c/svg%3e");
}

[data-bs-theme="dark"] .form-switch .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* --- Modais ------------------------------------------------------------ */
[data-bs-theme="dark"] .modal-content {
    background: var(--panel) !important;
    color: var(--text-color);
    box-shadow: var(--shadow) !important;
    border: 1px solid var(--border) !important;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .modal-tabs {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .modal-tabs .nav-link {
    color: var(--muted-text);
}

[data-bs-theme="dark"] .modal-tabs .nav-link.active {
    background: #1a1a1c;
    color: var(--primary-color);
    border-color: rgba(255, 255, 255, 0.1);
    border-bottom-color: #1a1a1c;
}

/* --- WhatsApp / QR ----------------------------------------------------- */
[data-bs-theme="dark"] .whatsapp-toolbar {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.08), rgba(20, 20, 20, 0.8));
    border-color: rgba(37, 211, 102, 0.2);
}

[data-bs-theme="dark"] .whatsapp-toolbar__icon {
    background: #1e1e1e;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .whatsapp-reconnect__qr-box {
    background: #1e1e1e;
}

[data-bs-theme="dark"] .whatsapp-reconnect__pill {
    background: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

[data-bs-theme="dark"] .whatsapp-reconnect__steps {
    border-top-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .whatsapp-reconnect__list {
    color: var(--text-color);
}

[data-bs-theme="dark"] .whatsapp-connect__icon {
    background: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.1);
}

/* --- Editor SQL -------------------------------------------------------- */
[data-bs-theme="dark"] .sql-editor-view {
    background: #1a1a1c;
    border-color: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .sql-editor-view.ace_editor {
    background: #1a1a1c;
}

[data-bs-theme="dark"] .sql-editor-view.ace_editor .ace_gutter {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted-text);
}

[data-bs-theme="dark"] .sql-editor-view.ace_editor .ace_gutter-active-line {
    background: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .sql-editor-view.ace_editor .ace_marker-layer .ace_active-line {
    background: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .sql-editor-view.ace_editor.ace_focus {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

/* --- Custom Select ----------------------------------------------------- */
[data-bs-theme="dark"] .custom-select-trigger {
    background-color: var(--panel);
    color: var(--text-color);
    border-color: var(--border2);
}

[data-bs-theme="dark"] .custom-select-trigger:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.25rem var(--accent-soft);
}

[data-bs-theme="dark"] .custom-select-wrapper.is-disabled .custom-select-trigger {
    background-color: var(--panel2);
    color: var(--muted-text);
}

[data-bs-theme="dark"] .custom-select-dropdown {
    background: var(--panel);
    border-color: var(--border2);
    box-shadow: var(--shadow);
}

[data-bs-theme="dark"] .custom-select-option {
    color: var(--text-color);
}

[data-bs-theme="dark"] .custom-select-option:hover {
    background: var(--panel2);
}

[data-bs-theme="dark"] .custom-select-option.is-selected {
    background: var(--accent-soft);
    color: var(--accent);
}

[data-bs-theme="dark"] .custom-select-option.is-selected:hover {
    background: var(--accent-soft);
}

/* --- Seções de agendamento --------------------------------------------- */
[data-bs-theme="dark"] .agendamento-section+.agendamento-section {
    border-top-color: rgba(255, 255, 255, 0.08);
}

/* --- Nav tabs ---------------------------------------------------------- */
[data-bs-theme="dark"] .nav-tabs .nav-link.active,
[data-bs-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    color: var(--primary-color);
    border-color: rgba(255, 255, 255, 0.1) rgba(255, 255, 255, 0.1) var(--card-bg);
    background-color: var(--card-bg);
}

[data-bs-theme="dark"] .nav-tabs {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover,
[data-bs-theme="dark"] .nav-tabs .nav-link:focus {
    color: var(--primary-color);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .nav-pills .nav-link.active,
[data-bs-theme="dark"] .nav-pills .show>.nav-link {
    background-color: var(--primary-color);
    color: #111111;
}

/* --- Seleção de texto -------------------------------------------------- */
[data-bs-theme="dark"] ::selection {
    background-color: rgba(255, 255, 255, 0.25);
    color: inherit;
}

/* --- Badges ------------------------------------------------------------ */
[data-bs-theme="dark"] .badge-status {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted-text);
}

[data-bs-theme="dark"] .badge-status.badge-success,
[data-bs-theme="dark"] .badge-status.bg-success-subtle,
[data-bs-theme="dark"] .badge-status.text-success,
[data-bs-theme="dark"] .badge-status.badge-success-soft {
    background: rgba(25, 135, 84, 0.15) !important;
    color: #75b798 !important;
    border-color: rgba(25, 135, 84, 0.2);
}

[data-bs-theme="dark"] .badge-status.badge-danger,
[data-bs-theme="dark"] .badge-status.bg-danger-subtle,
[data-bs-theme="dark"] .badge-status.text-danger,
[data-bs-theme="dark"] .badge-status.badge-danger-soft {
    background: rgba(220, 53, 69, 0.15) !important;
    color: #ea868f !important;
    border-color: rgba(220, 53, 69, 0.2);
}

[data-bs-theme="dark"] .badge-status.badge-warning,
[data-bs-theme="dark"] .badge-status.bg-warning-subtle,
[data-bs-theme="dark"] .badge-status.text-warning,
[data-bs-theme="dark"] .badge-status.badge-warning-soft {
    background: rgba(255, 193, 7, 0.15) !important;
    color: #ffda6a !important;
    border-color: rgba(255, 193, 7, 0.2);
}

/* --- Formulário de detalhes do usuário --------------------------------- */
[data-bs-theme="dark"] .usuario-detail-form {
    border-top-color: rgba(255, 255, 255, 0.08);
}

/* --- Logos ------------------------------------------------------------- */
/* O filtro inverte a luminosidade (preto vira branco) e gira 180 graus na matriz de cor
   permitindo devolver os tons reais (ex azul, verde) que foram invertidos pelo passo 1 */
[data-bs-theme="dark"] .sidebar-logo-img,
[data-bs-theme="dark"] .login-logo,
[data-bs-theme="dark"] .login-visual-logo,
[data-bs-theme="dark"] .login-form-logo {
    filter: invert(1) hue-rotate(180deg) brightness(1.5);
}
/* intl-tel-input: ocupa largura total do campo */
.iti { width: 100%; }
/* z-index acima do modal Bootstrap (1055) para o dropdown de país aparecer corretamente */
.iti__dropdown-content { z-index: 1060; }

/* --- intl-tel-input: tema do design system ------------------------------ */
.iti__country-list {
    background: #fff;
    border: 1px solid rgba(17, 17, 17, 0.12);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(17, 17, 17, 0.14);
    padding: 4px 0;
}

.iti__search-input {
    color: var(--text-color);
    background-color: #fff;
    border: 1px solid rgba(17, 17, 17, 0.14);
    border-radius: 0.375rem;
}

.iti__search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(17, 17, 17, 0.18);
}

.iti__country {
    color: var(--text-color);
    padding: 9px 14px;
}

.iti__country.iti__highlight,
.iti__country:hover {
    background-color: rgba(17, 17, 17, 0.06);
}

.iti__dial-code {
    color: var(--muted-text);
}

.iti__divider {
    border-bottom: 1px solid rgba(17, 17, 17, 0.12);
}

[data-bs-theme="dark"] .iti__country-list {
    background: var(--panel);
    border-color: var(--border2);
    box-shadow: var(--shadow);
}

[data-bs-theme="dark"] .iti__search-input {
    background-color: var(--panel2);
    color: var(--text-color);
    border-color: var(--border2);
}

[data-bs-theme="dark"] .iti__country {
    color: var(--text-color);
}

[data-bs-theme="dark"] .iti__country.iti__highlight,
[data-bs-theme="dark"] .iti__country:hover {
    background-color: var(--panel2);
}

[data-bs-theme="dark"] .iti__dial-code {
    color: var(--muted-text);
}

[data-bs-theme="dark"] .iti__divider {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Botão de país selecionado (inline dentro do input) */
.iti__selected-country-primary,
.iti__selected-dial-code {
    color: var(--text-color);
}

.iti__selected-country:hover .iti__selected-country-primary,
.iti__selected-country[aria-expanded="true"] .iti__selected-country-primary {
    background-color: rgba(17, 17, 17, 0.06);
}

.iti__arrow {
    border-top-color: var(--muted-text);
}

.iti__arrow--up {
    border-bottom-color: var(--muted-text);
}

[data-bs-theme="dark"] .iti__selected-country:hover .iti__selected-country-primary,
[data-bs-theme="dark"] .iti__selected-country[aria-expanded="true"] .iti__selected-country-primary {
    background-color: rgba(255, 255, 255, 0.1);
}
