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

.container {
    width: 100%;
    padding: 0 1.5rem;
    margin: 0 auto;
    max-width: 1140px;
}

.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 {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 22px;
    min-height: 44px;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 10px 20px rgba(17, 17, 17, 0.18);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-color-dark);
}

.btn-outline-secondary {
    background: #fff;
    color: var(--text-color);
    border: 1px solid rgba(17, 17, 17, 0.15);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    color: var(--text-color);
    background: rgba(17, 17, 17, 0.05);
    border-color: rgba(17, 17, 17, 0.25);
}

.btn-outline-primary {
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.btn-danger {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 10px 20px rgba(17, 17, 17, 0.18);
}

.btn-danger:hover,
.btn-danger:focus {
    background: var(--primary-color-dark);
    border-color: var(--primary-color-dark);
    color: #fff;
}

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

.btn-outline-danger {
    background: #fff;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background: var(--danger-color);
    color: #fff;
    border-color: var(--danger-color);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

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

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

.actions-dropdown {
    position: relative;
}

.actions-dropdown .dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    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);
    display: none;
    z-index: 20;
}

.actions-dropdown.dropup .dropdown-menu {
    top: auto;
    bottom: calc(100% + 4px);
    box-shadow: 0 -12px 24px rgba(17, 17, 17, 0.12);
}

.actions-dropdown.show .dropdown-menu {
    display: block;
}

.dropdown-overflow-visible {
    overflow: visible !important;
}

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

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

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

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

.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 {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow);
}

.card.p-4 {
    padding: 24px !important;
}

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

.g-4 {
    gap: 1.5rem !important;
}

.d-flex {
    display: flex !important;
}

.d-grid {
    display: grid !important;
}

.flex-column {
    flex-direction: column !important;
}

.flex-fill {
    flex: 1 1 auto !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.justify-content-center {
    justify-content: center !important;
}

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

.align-items-start {
    align-items: flex-start !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.me-2 {
    margin-right: 0.5rem !important;
}

.gap-3 {
    gap: 1rem !important;
}

.gap-4 {
    gap: 1.5rem !important;
}

.w-100 {
    width: 100% !important;
}

.h-100 {
    height: 100% !important;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

.table thead th {
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted-text);
    padding: 12px 16px;
    border-bottom: 1px solid rgba(17, 17, 17, 0.08);
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(17, 17, 17, 0.05);
    vertical-align: middle;
}

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

.table tbody tr:hover {
    background: rgba(17, 17, 17, 0.05);
}

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

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

.list-group {
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-group-item {
    padding: 16px 0;
    border-bottom: 1px solid rgba(17, 17, 17, 0.05);
}

.list-group-item:last-child {
    border-bottom: none;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-control,
.form-select,
textarea,
input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid #d8d8d8;
    padding: 12px 14px;
    font-size: 0.95rem;
    transition: border-color 0.15s ease;
    font-family: inherit;
}

.form-control:focus,
.form-select:focus,
textarea:focus,
input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    border-radius: 20px;
    position: relative;
    appearance: none;
    background: rgba(17, 17, 17, 0.1);
    outline: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.form-switch .form-check-input::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 6px;
    width: 1rem;
    height: 1rem;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 6px rgba(17, 17, 17, 0.15);
}

.form-switch .form-check-input:checked {
    background: var(--success-color);
}

.form-switch .form-check-input:checked::after {
    transform: translateX(18px);
}

.alert {
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.9rem;
}

.alert-danger {
    background: rgba(255, 77, 109, 0.12);
    color: var(--danger-color);
}

.alert-success {
    background: rgba(56, 193, 114, 0.12);
    color: var(--success-color);
}

.alert-warning {
    background: rgba(252, 191, 73, 0.16);
    color: #c97a11;
}

.nav {
    display: flex;
    gap: 12px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.nav-tabs .nav-item {
    display: flex;
}

.nav-tabs button[data-active="true"] {
    background: var(--primary-color);
    color: #fff;
}

.d-none {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(17, 17, 17, 0.35);
    z-index: 1050;
    --modal-vertical-gap: clamp(16px, 5vh, 48px);
    --modal-horizontal-gap: clamp(16px, 6vw, 48px);
    --modal-viewport-height: calc(100vh - 2 * var(--modal-vertical-gap));
    --modal-viewport-width: calc(100vw - 2 * var(--modal-horizontal-gap));
    padding: var(--modal-vertical-gap) var(--modal-horizontal-gap);
    overflow-y: auto;
}

.modal.show {
    display: flex;
}

.modal-dialog {
    width: min(640px, var(--modal-viewport-width));
    max-width: 100%;
    max-height: min(var(--modal-viewport-height), 92vh);
    display: flex;
}

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

.modal-dialog.modal-tool .modal-content {
    max-height: var(--modal-tool-max-height);
}

.modal-dialog-centered {
    align-items: center;
}

.modal-lg {
    width: min(860px, var(--modal-viewport-width));
    max-width: 100%;
}

.modal-content {
    background: #fff;
    border-radius: 20px;
    border: none;
    box-shadow: 0 20px 40px rgba(17, 17, 17, 0.15);
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    width: 100%;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: none;
    padding-bottom: 12px;
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
}

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

.btn-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(17, 17, 17, 0.08);
    cursor: pointer;
    position: relative;
}

.btn-close::before,
.btn-close::after {
    content: '';
    position: absolute;
    top: 9px;
    left: 16px;
    width: 2px;
    height: 16px;
    background: rgba(17, 17, 17, 0.6);
}

.btn-close::before {
    transform: rotate(45deg);
}

.btn-close::after {
    transform: rotate(-45deg);
}

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

.token-chart {
    width: 100%;
    overflow-x: auto;
    padding: 46px 0 12px;
}

.token-chart::-webkit-scrollbar {
    height: 6px;
}

.token-chart::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 999px;
}

.token-chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 200px;
}

.token-chart-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 36px;
    height: 100%;
}

.token-chart-bar {
    width: 100%;
    min-width: 24px;
    border-radius: 10px 10px 6px 6px;
    background: linear-gradient(180deg, #38c172 0%, #1f8f5a 100%);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.token-chart-bar:hover,
.token-chart-bar:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(56, 193, 114, 0.3);
}

.token-chart-label {
    font-size: 0.75rem;
    color: var(--muted-text);
    white-space: nowrap;
}

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

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

.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    padding: 12px 20px;
    border-radius: 14px;
    color: #fff;
    font-weight: 500;
    box-shadow: 0 12px 24px rgba(17, 17, 17, 0.18);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-info {
    background: var(--primary-color);
}

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

.toast-error {
    background: var(--danger-color);
}

.toast-warning {
    background: var(--warning-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;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.75rem;
}

.col {
    flex: 1 0 0;
    padding: 0.75rem;
    min-width: 0;
}

.col-12 {
    flex: 0 0 auto;
    width: 100%;
    padding: 0.75rem;
}

.col-md-6 {
    flex: 0 0 auto;
    width: 100%;
    padding: 0.75rem;
}

.col-md-4 {
    flex: 0 0 auto;
    width: 100%;
    padding: 0.75rem;
}

.col-lg-5 {
    flex: 0 0 auto;
    width: 100%;
    padding: 0.75rem;
}

.col-lg-7 {
    flex: 0 0 auto;
    width: 100%;
    padding: 0.75rem;
}

.row-cols-1>* {
    width: 100%;
}

@media (min-width: 768px) {
    .col-md-6 {
        width: 50%;
    }

    .col-md-4 {
        width: 33.3333%;
    }
}

@media (min-width: 992px) {
    .col-lg-5 {
        width: 41.6667%;
    }

    .col-lg-7 {
        width: 58.3333%;
    }
}

@media (min-width: 1200px) {
    .row-cols-xl-4>* {
        width: 25%;
    }
}

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

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