:root {
    --bg-color: #f6f6f6;
    --sidebar-width: 240px;
    --primary-color: #1f1f1f;
    --primary-color-dark: #111111;
    --text-color: #1a1a1a;
    --muted-text: #6f6f6f;
    --card-bg: #ffffff;
    --border-radius: 18px;
    --shadow: 0 12px 32px rgba(17, 17, 17, 0.08);
    --danger-color: #ff4d6d;
    --success-color: #38c172;
    --warning-color: #fcbf49;
    --whatsapp-color: #25d366;
    --whatsapp-color-dark: #1fa855;
    --whatsapp-surface: rgba(37, 211, 102, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    background: var(--bg-color);
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    color: var(--text-color);
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
}

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: column;
}

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

.app-content>[data-page-metadata] {
    flex: 1;
}

[data-page-metadata] {
    display: flex;
    height: 100%;
    min-height: 0;
    width: 100%;
    overflow-x: visible;
    overflow-y: hidden;
    align-items: stretch;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: stretch;
    flex-shrink: 0;
    width: var(--sidebar-width);
    min-height: 100vh;
    padding: 32px 24px;
    background: #fff;
    box-shadow: 8px 0 32px rgba(17, 17, 17, 0.05);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 32px;
    overflow-y: auto;
    overflow-x: visible;
}

.sidebar-logo span {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.nav-module {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-module a {
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--muted-text);
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-module a.nav-subitem {
    padding-left: 44px;
    /* Align with text start of parent items */
    font-size: 0.9em;
}

.nav-module .nav-header {
    padding: 16px 16px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted-text);
    letter-spacing: 0.05em;
}


.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: 22px;
}

.nav-module a.active,
.nav-module a:hover,
.nav-module a:focus {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
}

.sidebar-user {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(17, 17, 17, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(17, 17, 17, 0.12);
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-user-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.sidebar-user-role {
    color: var(--muted-text);
    font-size: 0.8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 140px;
}

.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: #fff;
    border-radius: 16px;
    border: 1px solid rgba(17, 17, 17, 0.08);
    padding: 8px 12px;
}

.whatsapp-table {
    background: transparent;
}

.whatsapp-table thead th {
    padding: 12px 18px;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

.whatsapp-table tbody td {
    padding: 16px 18px;
}

.whatsapp-table tbody tr {
    transition: background 0.2s ease;
}

.whatsapp-table tbody tr:hover {
    background: rgba(37, 211, 102, 0.08);
}

@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%;
    }
}

.sidebar-user-actions {
    position: relative;
}

.sidebar-user-actions .btn-icon {
    border-radius: 50%;
}

.sidebar-user-actions.dropdown .dropdown-menu {
    left: auto;
    right: 0;
    bottom: calc(100% + 4px);
    top: auto;
    transform-origin: bottom right;
}

.main-content {
    flex: 1;
    padding: 32px 48px 48px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-height: 0;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    gap: 24px;
}

.topbar h1 {
    font-weight: 700;
    font-size: 1.8rem;
    margin: 0;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted-text);
}



.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: 12px;
    border: 1px solid rgba(17, 17, 17, 0.12);
    background: #fff;
    box-shadow: 0 12px 24px rgba(17, 17, 17, 0.12);
    z-index: 20;
}

.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;
}



.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: 16px;
    border: 1px solid rgba(17, 17, 17, 0.08);
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.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: rgba(17, 17, 17, 0.08);
    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: #4b5563;
    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: rgba(17, 17, 17, 0.14);
    background: #fff;
}

.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: 16px;
    border: 1px solid rgba(17, 17, 17, 0.08);
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.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: rgba(17, 17, 17, 0.08);
    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: #4b5563;
    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: rgba(17, 17, 17, 0.14);
    background: #fff;
}

@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 rgba(17, 17, 17, 0.08);
    border-radius: 14px;
    background: var(--card-bg);
}

.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(--card-bg);
    padding: 14px 16px;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

.usuario-detail-table tbody td {
    padding: 16px;
}

.usuario-detail-table tbody tr:hover {
    background: rgba(17, 17, 17, 0.04);
}

.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: 20px !important;
    border: none !important;
    box-shadow: 0 20px 40px rgba(17, 17, 17, 0.15) !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 {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-x: hidden;
    overflow-y: hidden;
}

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

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

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

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

#form-empresa .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(--muted-text);
}

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

.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) {
    [data-page-metadata] {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        min-height: auto;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        box-shadow: none;
        top: unset;
        overflow-y: visible;
    }

    .nav-module {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .main-content {
        padding: 24px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
}

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

    .topbar {
        gap: 16px;
    }

    .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;
    }
}

.sidebar-logo-img {
    display: block;
    width: 200px;
    /* ajuste ao seu gosto */
    height: auto;
}

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

.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(--primary-color);
    --bs-primary-rgb: 31, 31, 31;
    --bs-link-color: var(--primary-color);
    --bs-link-color-rgb: 31, 31, 31;
    --bs-link-hover-color: var(--primary-color-dark);
    --bs-link-hover-color-rgb: 17, 17, 17;
    --bs-focus-ring-color: rgba(17, 17, 17, 0.25);
    --bs-focus-ring-width: 0.25rem;
}

/* --- Primary Buttons (Black background, white text) -------------------- */
.btn-primary {
    --bs-btn-bg: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--primary-color-dark);
    --bs-btn-hover-border-color: var(--primary-color-dark);
    --bs-btn-active-bg: var(--primary-color-dark);
    --bs-btn-active-border-color: var(--primary-color-dark);
    --bs-btn-color: #ffffff;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-active-color: #ffffff;
    --bs-btn-disabled-bg: #6b6b6b;
    --bs-btn-disabled-border-color: #6b6b6b;
    --bs-btn-focus-shadow-rgb: 17, 17, 17;
}

/* --- Secondary / Cancel Buttons --------------------------------------- */
.btn-outline-secondary {
    --bs-btn-color: var(--text-color);
    --bs-btn-border-color: rgba(17, 17, 17, 0.15);
    --bs-btn-bg: transparent;
    --bs-btn-hover-bg: rgba(17, 17, 17, 0.04);
    --bs-btn-hover-color: var(--text-color);
    --bs-btn-hover-border-color: rgba(17, 17, 17, 0.25);
    --bs-btn-active-bg: rgba(17, 17, 17, 0.08);
    --bs-btn-active-color: var(--text-color);
    --bs-btn-active-border-color: rgba(17, 17, 17, 0.3);
    --bs-btn-focus-shadow-rgb: 17, 17, 17;
}

/* --- 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(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(17, 17, 17, 0.18);
    outline: none;
}

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

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

.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 rgba(56, 193, 114, 0.25);
}

/* --- 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: 1rem;
    font-family: inherit;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(17, 17, 17, 0.14);
    border-radius: 0.375rem;
    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(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(17, 17, 17, 0.18);
}

.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: #fff;
    border: 1px solid rgba(17, 17, 17, 0.12);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(17, 17, 17, 0.14);
    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.95rem;
    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(--primary-color);
    color: #fff;
    font-weight: 500;
}

.custom-select-option.is-selected:hover {
    background: var(--primary-color-dark);
}

.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"] {
    /* --- Variáveis de cor principais ----------------------------------- */
    --bg-color: #0d0d0d;
    --card-bg: #141414;
    --text-color: #f1f1f1;
    --muted-text: #9e9e9e;
    --primary-color: #e0e0e0;
    --primary-color-dark: #ffffff;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.7);

    /* --- Variáveis do Bootstrap customizadas p/ dark mode -------------- */
    --bs-body-bg: #0d0d0d;
    --bs-body-color: #f1f1f1;
    --bs-border-color: rgba(255, 255, 255, 0.1);
    --bs-border-color-translucent: rgba(255, 255, 255, 0.1);
    --bs-primary: #e0e0e0;
    --bs-primary-rgb: 224, 224, 224;
    --bs-link-color: #e0e0e0;
    --bs-link-hover-color: #ffffff;
    --bs-focus-ring-color: rgba(255, 255, 255, 0.2);
    --bs-card-bg: #141414;
    --bs-modal-bg: #141414;
    --bs-modal-color: #f1f1f1;
    --bs-secondary-bg: #1e1e1e;
}

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

/* --- Sidebar ----------------------------------------------------------- */
[data-bs-theme="dark"] .sidebar {
    background: #101010;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .sidebar-user {
    border-top-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .sidebar-user-avatar {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

[data-bs-theme="dark"] .nav-module a.active,
[data-bs-theme="dark"] .nav-module a:hover,
[data-bs-theme="dark"] .nav-module a:focus {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary-color-dark);
}

/* --- Cards ------------------------------------------------------------- */
[data-bs-theme="dark"] .card {
    background-color: var(--card-bg);
    border-color: rgba(255, 255, 255, 0.08);
    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: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
    color: #e8e8e8;
}

[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: #1a1a1c;
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #212124;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.15);
    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(--card-bg);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .usuario-detail-table thead th {
    background: var(--card-bg);
    color: var(--muted-text);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

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

[data-bs-theme="dark"] .whatsapp-table tbody tr:hover {
    background: rgba(37, 211, 102, 0.1);
}

[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: #e8e8e8;
    --bs-btn-border-color: rgba(255, 255, 255, 0.2);
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.1);
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.35);
    --bs-btn-active-bg: rgba(255, 255, 255, 0.15);
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-border-color: rgba(255, 255, 255, 0.5);
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-bg: #e0e0e0;
    --bs-btn-border-color: #e0e0e0;
    --bs-btn-color: #111111;
    --bs-btn-hover-bg: #ffffff;
    --bs-btn-hover-border-color: #ffffff;
    --bs-btn-hover-color: #111111;
    --bs-btn-active-bg: #ffffff;
    --bs-btn-active-color: #111111;
}

/* --- 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: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.15);
}

/* --- Checkboxes e switches -------------------------------------------- */
[data-bs-theme="dark"] .form-check-input {
    background-color: #242424;
    border-color: rgba(255, 255, 255, 0.25);
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: #198754;
    border-color: #198754;
}

[data-bs-theme="dark"] .form-switch .form-check-input {
    background-color: #333333;
    --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: #198754;
    --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%2815%2C15%2C15%2C1%29'/%3e%3c/svg%3e");
}

/* --- Modais ------------------------------------------------------------ */
[data-bs-theme="dark"] .modal-content {
    background: #1a1a1c !important;
    color: var(--text-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !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: #1a1a1c;
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .custom-select-trigger:focus {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.15);
}

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

[data-bs-theme="dark"] .custom-select-dropdown {
    background: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
}

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

[data-bs-theme="dark"] .custom-select-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .custom-select-option.is-selected {
    background: #e0e0e0;
    color: #111111;
}

[data-bs-theme="dark"] .custom-select-option.is-selected:hover {
    background: #ffffff;
}

/* --- 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 {
    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; }
