/* ==========================================================================
   CORE DESIGN SYSTEM & FOUNDATION (white-label)
   Os tokens --app-primary* e --app-slate* abaixo são apenas o tema padrão (RTM:
   Vinho #992831 | Slate #343e46). Em runtime eles são sobrescritos pelo bloco
   <style id="app-brand-theme"> gerado a partir da Identidade Visual do cliente
   (App\Modules\Identidade\Domain\PaletaTema). Nunca use a cor da marca literal
   nas folhas de estilo: use var(--app-primary) ou rgba(var(--app-primary-rgb), a).
   ========================================================================== */

@import url('../vendor/manrope/manrope.css');

/* O atributo hidden sempre oculta, mesmo em componentes com display próprio (ex.: .form-group) */
[hidden] {
    display: none !important;
}

:root {
    --app-primary: #992831;
    --app-primary-hover: #7e1f26;
    --app-primary-active: #66181e;
    --app-primary-light: #fbf0f1;
    --app-primary-border: #f4d0d3;
    --app-primary-rgb: 153, 40, 49;
    --app-on-primary: #ffffff;

    --app-slate: #343e46;
    --app-slate-light: #485661;
    --app-slate-dark: #242b31;
    --app-slate-rgb: 52, 62, 70;

    /* Barra de rolagem: acompanha a primária, salvo cor própria na Identidade Visual */
    --app-scrollbar: #992831;
    --app-scrollbar-hover: #7e1f26;
    --app-scrollbar-rgb: 153, 40, 49;

    --app-bg: #f8f9fa;
    --app-surface: #ffffff;
    --app-surface-alt: #f1f3f5;
    
    --app-text: #1e293b;
    --app-text-muted: #64748b;
    --app-text-light: #94a3b8;

    --app-border: #e2e8f0;
    --app-border-strong: #cbd5e1;

    --app-success: #059669;
    --app-success-light: #ecfdf5;
    --app-warning: #d97706;
    --app-warning-light: #fffbeb;
    --app-danger: #dc2626;
    --app-danger-light: #fef2f2;
    --app-info: #0284c7;
    --app-info-light: #f0f9ff;

    --app-radius-sm: 6px;
    --app-radius-md: 10px;
    --app-radius-lg: 16px;
    --app-radius-full: 9999px;

    --app-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --app-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --app-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);

    --app-font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --app-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--app-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--app-text);
    background-color: var(--app-bg);
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   SCROLLBAR NA COR DA MARCA (tokens --app-scrollbar*; theme.css refina o global)
   ========================================================================== */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--app-scrollbar-rgb), 0.55) #f8f9fa;
}

*:hover {
    scrollbar-color: var(--app-scrollbar) #f1f5f9;
}

/* WebKit (Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(var(--app-scrollbar-rgb), 0.55);
    border-radius: 4px;
    border: 2px solid #f8f9fa;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--app-scrollbar);
    border-color: #f1f5f9;
}

::-webkit-scrollbar-thumb:active {
    background: var(--app-scrollbar-hover);
}

::-webkit-scrollbar-corner {
    background: #f8f9fa;
}

.app-table-container,
.table-responsive,
.app-modal-body,
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--app-scrollbar-rgb), 0.55) #f8f9fa;
}

.app-table-container::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
.app-modal-body::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.app-table-container::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track,
.app-modal-body::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.app-table-container::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
.app-modal-body::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(var(--app-scrollbar-rgb), 0.55);
    border-radius: 4px;
    border: 1px solid #f8f9fa;
    transition: background-color 0.2s ease;
}

.app-table-container::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover,
.app-modal-body::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--app-scrollbar);
}

.app-table-container::-webkit-scrollbar-thumb:active,
.table-responsive::-webkit-scrollbar-thumb:active,
.app-modal-body::-webkit-scrollbar-thumb:active,
.sidebar-nav::-webkit-scrollbar-thumb:active {
    background: var(--app-scrollbar-hover);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--app-slate);
    font-weight: 700;
    line-height: 1.25;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p {
    color: var(--app-text-muted);
}

a {
    color: var(--app-primary);
    text-decoration: none;
    transition: var(--app-transition);
}

a:hover {
    color: var(--app-primary-hover);
}

/* Main Layout Structure: o documento rola (sem trava de viewport), para que o
   fundo e as cores acompanhem o conteúdo em qualquer página (app, setup, login).
   O shell (sidebar fixa + topbar sticky) é definido no theme.css. */
html, body {
    height: auto;
    min-height: 100%;
    margin: 0;
    padding: 0;
}

body {
    overflow-x: hidden;
}

.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.sidebar {
    width: 290px;
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid var(--app-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: var(--app-transition);
}

.sidebar-brand {
    padding: 18px 16px;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-logo {
    height: 34px;
    width: auto;
    max-width: 145px;
    object-fit: contain;
}

/* Marca sem logo configurado: nome em texto no lugar da imagem */
.brand-logo-text {
    display: inline-flex;
    align-items: center;
    height: auto;
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.2;
    color: var(--app-primary);
    letter-spacing: -0.02em;
}

.sidebar-brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 9px;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--app-primary);
    background: var(--app-primary-light);
    border: 1px solid rgba(var(--app-primary-rgb), 0.16);
    border-radius: var(--app-radius-full);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--app-text-light);
    padding: 12px 12px 4px 12px;
    letter-spacing: 0.75px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--app-slate);
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: var(--app-radius-sm);
    transition: var(--app-transition);
}

.sidebar-link i {
    font-size: 1.15rem;
    color: var(--app-text-muted);
    width: 22px;
    text-align: center;
    transition: var(--app-transition);
}

.sidebar-link:hover {
    background-color: var(--app-surface-alt);
    color: var(--app-primary);
}

.sidebar-link:hover i {
    color: var(--app-primary);
}

.sidebar-link.active {
    background-color: var(--app-primary-light);
    color: var(--app-primary);
    font-weight: 700;
}

.sidebar-link.active i {
    color: var(--app-primary);
}

/* Painel do Usuário Logado na Sidebar */
.sidebar-user-section {
    padding: 12px 14px;
    border-top: 1px solid var(--app-border);
    background: #ffffff;
    flex-shrink: 0;
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--app-radius-sm);
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

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

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--app-radius-full);
    background: var(--app-primary-light);
    color: var(--app-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--app-slate);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.70rem;
    font-weight: 600;
    color: var(--app-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sidebar-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--app-radius-sm);
    background: #ffffff;
    border: 1px solid var(--app-border);
    color: var(--app-danger);
    transition: var(--app-transition);
    flex-shrink: 0;
    cursor: pointer;
}

.sidebar-logout-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.sidebar-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--app-text-muted);
    flex-shrink: 0;
}

.main-content {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background-color: var(--app-bg);
    position: relative;
    z-index: 1;
}

.topbar {
    height: 70px;
    background: #ffffff;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
    z-index: 40;
}

.page-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px;
}

.app-global-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    background: #ffffff;
    border-top: 1px solid var(--app-border);
    font-size: 0.82rem;
    color: var(--app-text-muted);
    z-index: 30;
}

.app-global-footer .badge {
    margin-left: 6px;
    font-weight: 600;
}

/* Botão Toggle Mobile na Topbar */
.btn-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #ffffff;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    color: var(--app-slate);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--app-transition);
    margin-right: 6px;
    flex-shrink: 0;
}

.btn-sidebar-toggle:hover {
    background: var(--app-surface-alt);
    color: var(--app-primary);
    border-color: var(--app-primary-border);
}

.btn-sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--app-radius-sm);
    color: var(--app-text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--app-transition);
}

.btn-sidebar-close:hover {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

/* Backdrop da Sidebar no Mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--app-slate);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.env-tag {
    padding: 4px 10px;
    border-radius: var(--app-radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.env-tag-dev {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.env-tag-prod {
    background: var(--app-success-light);
    color: var(--app-success);
    border: 1px solid #a7f3d0;
}

.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--app-slate);
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: var(--app-radius-sm);
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    color: #b91c1c;
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Page Container */
.page-container {
    padding: 28px 32px 48px 32px;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* Page Header & Actions Component (Universal) */
.page-header-actions,
.page-header-bar,
.equipe-header-actions,
.usuarios-header-bar,
.categorias-header-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2.25rem;
    padding-bottom: 0.25rem;
}

.page-header-actions .header-title-group,
.page-header-bar .header-title-group,
.equipe-header-actions > div:first-child,
.usuarios-header-bar > div:first-child,
.categorias-header-bar > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 950px;
}

.page-header-actions h2,
.page-header-bar h2,
.equipe-header-actions h2,
.usuarios-header-bar h2,
.categorias-header-bar h2 {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--app-slate-dark);
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.page-header-actions p,
.page-header-bar p,
.equipe-header-actions p,
.usuarios-header-bar p,
.categorias-header-bar p {
    font-size: 0.92rem;
    color: var(--app-text-muted, #64748b);
    margin: 0;
    line-height: 1.55;
}

.page-header-actions .header-btns,
.page-header-bar .header-btns,
.equipe-header-actions .header-btns,
.usuarios-header-bar .header-btns,
.categorias-header-bar .header-btns {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .page-header-actions,
    .page-header-bar,
    .equipe-header-actions,
    .usuarios-header-bar,
    .categorias-header-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
        margin-bottom: 1.75rem;
    }
}

/* Card Component */
.app-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-md);
    box-shadow: var(--app-shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--app-transition);
}

.app-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
}

.app-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--app-slate);
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-card-title i {
    color: var(--app-primary);
}

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

.app-card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--app-border);
    background: var(--app-surface-alt);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* Uniform Form Elements & Grids */
.form-grid-1 { display: grid; grid-template-columns: 1fr; gap: 20px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

@media (max-width: 992px) {
    .form-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .form-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .form-grid-2, .form-grid-4 { grid-template-columns: 1fr; }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--app-slate);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-label .required {
    color: var(--app-danger);
}

.form-control, .form-select {
    width: 100%;
    height: 42px;
    padding: 8px 14px;
    font-size: 0.92rem;
    font-family: var(--app-font);
    color: var(--app-text);
    background-color: #ffffff;
    border: 1px solid var(--app-border-strong);
    border-radius: var(--app-radius-sm);
    transition: var(--app-transition);
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(var(--app-primary-rgb), 0.15);
}

.form-control.is-invalid, .form-select.is-invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: #dc2626;
    font-weight: 500;
    text-align: left;
}

.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback,
.is-invalid-group .invalid-feedback {
    display: block;
}

.form-control:disabled, .form-select:disabled {
    background-color: var(--app-surface-alt);
    color: var(--app-text-muted);
    cursor: not-allowed;
}

.form-help {
    font-size: 0.78rem;
    color: var(--app-text-muted);
    margin-top: 2px;
}

/* Button System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--app-font);
    border-radius: var(--app-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--app-transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    height: 42px;
}

.btn-sm {
    height: 34px;
    padding: 6px 14px;
    font-size: 0.82rem;
}

.btn-lg {
    height: 48px;
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--app-primary);
    color: var(--app-on-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover {
    background-color: var(--app-primary-hover);
    border-color: var(--app-primary-hover);
    color: var(--app-on-primary);
    box-shadow: 0 4px 10px rgba(var(--app-primary-rgb), 0.25);
}

.btn-secondary {
    background-color: var(--app-surface-alt);
    color: var(--app-slate);
    border-color: var(--app-border-strong);
}

.btn-secondary:hover {
    background-color: #e5e7eb;
    color: var(--app-slate-dark);
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-outline-primary:hover {
    background-color: var(--app-primary-light);
    color: var(--app-primary-hover);
}

.btn-success {
    background-color: var(--app-success);
    color: #ffffff;
}

.btn-success:hover {
    background-color: #047857;
}

.btn-danger {
    background-color: var(--app-danger);
    color: #ffffff;
    border-color: var(--app-danger);
}

.btn-danger:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
}

.btn-outline-danger {
    background-color: transparent;
    color: var(--app-danger);
    border-color: var(--app-danger);
}

.btn-outline-danger:hover {
    background-color: var(--app-danger-light);
    color: #b91c1c;
}

.btn-outline-success {
    background-color: transparent;
    color: var(--app-success);
    border-color: var(--app-success);
}

.btn-outline-success:hover {
    background-color: var(--app-success-light);
    color: #047857;
}

.border-danger {
    border-color: #ef4444 !important;
}

.border-success {
    border-color: #10b981 !important;
}

.bg-danger-subtle {
    background-color: #fef2f2 !important;
}

.bg-success-subtle {
    background-color: #f0fdf4 !important;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--app-radius-full);
}

.badge-success { background: var(--app-success-light); color: var(--app-success); }
.badge-warning { background: var(--app-warning-light); color: var(--app-warning); }
.badge-danger { background: var(--app-danger-light); color: var(--app-danger); }
.badge-info { background: var(--app-info-light); color: var(--app-info); }
.badge-secondary { background: var(--app-surface-alt); color: var(--app-text-muted); }

/* Table Base System com Scroll Obrigatório */
.app-table-container,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: min(720px, calc(100vh - 280px));
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    background: #ffffff;
    position: relative;
}

.app-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    text-align: left;
}

.app-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--app-surface-alt);
    color: var(--app-slate);
    font-weight: 700;
    padding: 12px 16px;
    border-bottom: 2px solid var(--app-border);
    white-space: nowrap;
    box-shadow: 0 1px 0 var(--app-border);
}

.app-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--app-border);
    color: var(--app-text);
    vertical-align: middle;
}

.app-table tbody tr:hover {
    background-color: #fafbfc;
}

/* Colunas Especiais de Tabela */
.col-w-expand {
    width: 44px !important;
    min-width: 44px !important;
    text-align: center !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

.cell-actions {
    width: 90px !important;
    min-width: 90px !important;
    text-align: center !important;
}

.btn-toggle-expand-row {
    background: transparent;
    border: 1px solid var(--app-border);
    color: var(--app-primary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-toggle-expand-row:hover {
    background: var(--app-primary-light);
    border-color: var(--app-primary);
}

.btn-toggle-expand-row .chevron-icon,
.btn-toggle-expand-row .expand-icon {
    font-size: 0.75rem;
    transition: color 0.15s ease;
}

tr[aria-expanded="true"] .btn-toggle-expand-row {
    background: var(--app-primary);
    color: var(--app-on-primary);
    border-color: var(--app-primary);
}

/* Classes utilitárias tipográficas e de componentes para evitar CSS inline */
.bullet-dot { font-size: 0.5rem !important; vertical-align: middle; }
.fs-2xs { font-size: 0.72rem !important; }
.fs-3xs { font-size: 0.65rem !important; }
.modal-w-520 { max-width: 520px !important; width: 92% !important; }
.ls-wide { letter-spacing: 0.5px !important; }
.cursor-pointer { cursor: pointer !important; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--app-success); }
.text-danger { color: var(--app-danger); }
.text-muted { color: var(--app-text-muted); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }

/* Stepper / Wizard (Para Setup em Trilha) */
.wizard-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    position: relative;
    padding: 0 16px;
}

.wizard-stepper::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 48px;
    right: 48px;
    height: 3px;
    background: var(--app-border);
    z-index: 1;
}

.step-item {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: transparent;
}

.step-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--app-border);
    color: var(--app-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    transition: var(--app-transition);
}

.step-item.active .step-circle {
    border-color: var(--app-primary);
    background: var(--app-primary);
    color: var(--app-on-primary);
    box-shadow: 0 0 0 5px rgba(var(--app-primary-rgb), 0.15);
}

.step-item.completed .step-circle {
    border-color: var(--app-success);
    background: var(--app-success);
    color: #ffffff;
}

.step-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--app-text-muted);
    text-align: center;
}

.step-item.active .step-title {
    color: var(--app-primary);
    font-weight: 700;
}

.step-item.completed .step-title {
    color: var(--app-slate);
}

/* Corporate Ultra-Modern Loading Overlay */
#app-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 33, 39, 0.72);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#app-loading-overlay.visible {
    display: flex;
    opacity: 1;
}

.app-loading-card {
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 25px 60px -15px rgba(var(--app-primary-rgb), 0.3), 0 0 0 1px rgba(var(--app-primary-rgb), 0.08);
    padding: 2.25rem 2.5rem;
    min-width: 320px;
    max-width: 400px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#app-loading-overlay.visible .app-loading-card {
    transform: scale(1);
}

/* Dual Glowing Animated Rings */
.app-loader-rings {
    position: relative;
    width: 84px;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.app-loader-ring-outer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3.5px solid rgba(var(--app-primary-rgb), 0.12);
    border-top-color: var(--app-primary);
    border-right-color: #b91c1c;
    animation: appSpinClockwise 1.1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
    box-shadow: 0 0 15px rgba(var(--app-primary-rgb), 0.2);
}

.app-loader-ring-inner {
    position: absolute;
    top: 9px;
    left: 9px;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: 2.5px solid rgba(var(--app-slate-rgb), 0.1);
    border-bottom-color: var(--app-slate);
    border-left-color: var(--app-primary);
    animation: appSpinCounter 1.5s ease-in-out infinite;
}

.app-loader-center {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(var(--app-primary-rgb), 0.12), rgba(var(--app-primary-rgb), 0.04));
    display: flex;
    align-items: center;
    justify-content: center;
    animation: appPulseGlow 1.8s ease-in-out infinite;
    z-index: 2;
}

.app-loader-center i {
    font-size: 1.25rem;
    color: var(--app-primary);
}

@keyframes appSpinClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes appSpinCounter {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@keyframes appPulseGlow {
    0%, 100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(var(--app-primary-rgb), 0.25);
    }
    50% {
        transform: scale(1.06);
        box-shadow: 0 0 12px 4px rgba(var(--app-primary-rgb), 0.2);
    }
}

.app-loading-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--app-slate);
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
}

.app-loading-subtitle {
    font-size: 0.775rem;
    font-weight: 500;
    color: var(--app-text-muted, #718096);
    margin-bottom: 1.15rem;
}

/* Glowing Indeterminate Shimmer Progress Bar */
.app-loading-progress-bar {
    width: 100%;
    height: 4px;
    background: #f1f5f9;
    border-radius: 9999px;
    overflow: hidden;
    position: relative;
}

.app-loading-progress-shimmer {
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--app-primary), #dc2626, transparent);
    border-radius: 9999px;
    animation: appShimmerMove 1.4s ease-in-out infinite;
}

@keyframes appShimmerMove {
    0% {
        left: -50%;
        width: 30%;
    }
    50% {
        left: 35%;
        width: 55%;
    }
    100% {
        left: 100%;
        width: 30%;
    }
}

/* Modal Institutional Style - Premium Design */
.app-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.68);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 24px 16px;
    animation: backdrop-fade 0.2s ease-out;
}

.app-modal-backdrop.visible {
    display: flex !important;
}

@keyframes backdrop-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.app-modal {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-enter 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-modal form {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 90vh;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

.app-modal-lg {
    max-width: 920px;
}

@keyframes modal-enter {
    from { opacity: 0; transform: translateY(-16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.app-modal-header {
    padding: 20px 26px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    flex-shrink: 0;
}

.app-modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--app-slate);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.app-modal-title i {
    color: var(--app-primary);
}

.app-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 1.25rem;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
}

.app-modal-close:hover {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
    transform: rotate(90deg);
}

.app-modal-body {
    padding: 24px 26px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #ffffff;
}

.app-modal-footer {
    padding: 16px 26px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

.app-modal-footer .btn {
    min-width: 115px;
    height: 42px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 18px;
    cursor: pointer;
}

.app-modal-footer .btn-secondary {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.app-modal-footer .btn-secondary:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #94a3b8;
}

.app-modal-footer .btn-primary {
    background: var(--app-primary);
    border: 1px solid #7f1d24;
    color: var(--app-on-primary);
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(var(--app-primary-rgb), 0.25);
}

.app-modal-footer .btn-primary:hover {
    background: var(--app-primary-hover);
    box-shadow: 0 4px 8px rgba(var(--app-primary-rgb), 0.35);
    transform: translateY(-1px);
}

/* ==========================================================================
   TOGGLE SWITCH UNIVERSAL (Substituto Elegante de Checkboxes de Flag)
   ========================================================================== */
.status-toggle-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .25s ease;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .25s ease;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--app-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    cursor: pointer;
    margin: 0;
    font-size: 0.9rem;
    color: #1e293b;
    line-height: 1.4;
}

/* ==========================================================================
   TOGGLE ESPECIAL: TIPO DE FLUXO (RECEITA vs DESPESA)
   Aberto = Receita (Verde), Fechado = Despesa (Vinho/Vermelho)
   ========================================================================== */
.fluxo-toggle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    transition: all 0.25s ease;
    cursor: pointer;
}

.fluxo-toggle-card.mode-income {
    background: #f0fdf4;
    border-color: #86efac;
}

.fluxo-toggle-card.mode-expense {
    background: #fff1f2;
    border-color: #fecdd3;
}

.fluxo-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fluxo-icon-box {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.25s ease;
}

.mode-income .fluxo-icon-box {
    background: #dcfce7;
    color: #15803d;
}

.mode-expense .fluxo-icon-box {
    background: #ffe4e6;
    color: var(--app-primary);
}

.fluxo-texts h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    transition: color 0.25s ease;
}

.mode-income .fluxo-texts h4 {
    color: #15803d;
}

.mode-expense .fluxo-texts h4 {
    color: var(--app-primary);
}

.fluxo-texts p {
    margin: 2px 0 0 0;
    font-size: 0.78rem;
    color: #64748b;
}

/* Toggle Switch com cores dinâmicas para fluxo */
.fluxo-switch {
    position: relative;
    display: inline-block;
    width: 54px;
    height: 30px;
    flex-shrink: 0;
}

.fluxo-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.fluxo-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--app-primary); /* Fechado = Despesa (Vinho) */
    transition: .28s ease;
    border-radius: 30px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

.fluxo-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .28s ease;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.25);
}

.fluxo-switch input:checked + .fluxo-slider {
    background-color: #10b981; /* Aberto = Receita (Verde) */
}

.fluxo-switch input:checked + .fluxo-slider:before {
    transform: translateX(24px);
}

/* Segmented Control Global (Receita vs Despesa / Alternativas) */
.app-segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    height: 40px;
}

.app-segmented-control .segmented-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-segmented-control .segmented-btn:hover {
    color: #1e293b;
}

.app-segmented-control .segmented-btn[data-flow="income"].active,
.app-segmented-control .segmented-btn[data-tipo="income"].active,
.app-segmented-control .segmented-btn.mode-income.active {
    background: #ffffff !important;
    color: #16a34a !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid rgba(22, 163, 74, 0.3) !important;
}

.app-segmented-control .segmented-btn[data-flow="expense"].active,
.app-segmented-control .segmented-btn[data-tipo="expense"].active,
.app-segmented-control .segmented-btn.mode-expense.active {
    background: #ffffff !important;
    color: var(--app-primary) !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid rgba(var(--app-primary-rgb), 0.3) !important;
}


/* ==========================================================================
   SEARCHABLE SELECT (DROPDOWN COM BUSCA EM TEMPO REAL)
   ========================================================================== */
.app-searchable-wrapper {
    position: relative;
    width: 100%;
}

.app-searchable-trigger {
    width: 100%;
    min-height: 42px;
    padding: 8px 14px;
    background: #ffffff;
    border: 1px solid var(--app-border, #cbd5e1);
    border-radius: var(--app-radius-md, 8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--app-slate);
    user-select: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.app-searchable-trigger:hover {
    border-color: #94a3b8;
}

.app-searchable-wrapper.is-open .app-searchable-trigger {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(var(--app-primary-rgb), 0.12);
}

.app-searchable-trigger-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-searchable-trigger-arrow {
    color: #64748b;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.app-searchable-wrapper.is-open .app-searchable-trigger-arrow {
    transform: rotate(180deg);
}

.app-searchable-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14), 0 4px 10px rgba(0, 0, 0, 0.06);
    z-index: 1050;
    display: none;
    overflow: hidden;
    animation: modal-enter 0.15s ease-out;
}

.app-searchable-wrapper.is-open .app-searchable-dropdown,
.app-searchable-dropdown.is-floating {
    display: block;
}

/* Aberta, a lista vai para o <body> e flutua sobre o conteúdo (inclusive modais) */
.app-searchable-dropdown.is-floating {
    position: fixed;
    right: auto;
    z-index: 9500;
}

.app-searchable-search-box {
    padding: 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    display: flex;
    align-items: center;
}

.app-searchable-search-box i {
    position: absolute;
    left: 20px;
    color: #94a3b8;
    font-size: 0.85rem;
    pointer-events: none;
}

.app-searchable-search-input {
    width: 100%;
    height: 36px;
    padding: 6px 12px 6px 34px;
    font-size: 0.88rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.app-searchable-search-input:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 2px rgba(var(--app-primary-rgb), 0.15);
}

.app-searchable-options-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 6px 0;
}

.app-searchable-option {
    padding: 9px 14px;
    font-size: 0.88rem;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s;
}

.app-searchable-option:hover:not(.disabled) {
    background: #f1f5f9;
    color: var(--app-primary);
}

.app-searchable-option.selected {
    background: var(--app-primary-light);
    color: var(--app-primary);
    font-weight: 700;
}

.app-searchable-option.disabled {
    opacity: 0.55;
    background: #f8fafc;
    cursor: not-allowed;
    color: #64748b;
}

.app-searchable-no-results {
    padding: 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ==========================================================================
   ESPAÇAMENTO OBRIGATÓRIO DE ÍCONES (Regra: sem texto grudado em ícone)
   ========================================================================== */
i.fas, i.far, i.fab, i.fa, i.bi {
    display: inline-block;
    vertical-align: middle;
}

/* Texto logo após um ícone (ou ícone após texto) em fluxo inline: um único
   espaçamento de 0.5em. Sem !important, para os componentes poderem zerar. */
i + span, i + strong, i + b, i + em, i + p, i + a, i + label,
i + h1, i + h2, i + h3, i + h4, i + h5, i + h6, i + div {
    margin-left: 0.5em;
    vertical-align: middle;
}

span + i, strong + i, b + i {
    margin-left: 0.4em;
    vertical-align: middle;
}

/* Contêineres flex com gap já espaçam ícone e texto: o gap é a única fonte de
   espaçamento (zera a margem implícita acima e utilitários me-* / ms-* nos ícones). */
:is(.btn, .badge, .form-label, .form-help, .alert-rule, .app-card-title, .app-modal-title,
    .cfg-section-title, .step-pane-title, .section-title, .card-title, .modal-title,
    .env-tag, .sidebar-link, .topbar-breadcrumb, .d-flex, .d-inline-flex, [class*="gap-"]) > i + *,
:is(.btn, .badge, .form-label, .form-help, .alert-rule, .app-card-title, .app-modal-title,
    .cfg-section-title, .step-pane-title, .section-title, .card-title, .modal-title,
    .env-tag, .sidebar-link, .topbar-breadcrumb, .d-flex, .d-inline-flex, [class*="gap-"]) > * + i {
    margin-left: 0 !important;
}

:is(.btn, .badge, .form-label, .alert-rule, .app-card-title, .app-modal-title,
    .cfg-section-title, .step-pane-title, .section-title, .card-title, .modal-title,
    .env-tag, .sidebar-link, [class*="gap-"]) > i {
    margin-right: 0 !important;
    margin-left: 0 !important;
    flex-shrink: 0;
}

/* Títulos e selos que não são flex por padrão passam a ser, com gap consistente */
.step-pane-title, .cfg-section-title, .section-title, .card-title, .modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-help {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.form-help > i {
    margin: 0.2em 0 0 !important;
    flex-shrink: 0;
}

/* Ícone solto no início de alertas sem contêiner flex */
.alert > i:first-child,
.alert > div > i:first-child,
.db-migration-card i.fa-code-branch {
    margin-right: 10px;
    flex-shrink: 0;
}

.alert > i:first-child + *,
.alert > div > i:first-child + * {
    margin-left: 0;
}

/* Quando for somente o ícone e o botão sem texto, o ícone DEVE ficar perfeitamente centralizado */
.btn.btn-icon,
.btn-icon,
.btn-icon-only,
.app-action-group .app-dropdown-toggle,
.btn:has(> i:only-child) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 0 !important;
    gap: 0 !important;
}

.btn.btn-icon i,
.btn-icon i,
.btn-icon-only i,
.app-action-group .app-dropdown-toggle i,
.btn i:only-child {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    vertical-align: middle !important;
}

/* Classes utilitárias universais de espaçamento */
.me-1 { margin-right: 4px !important; }
.me-2 { margin-right: 8px !important; }
.me-3 { margin-right: 16px !important; }
.ms-1 { margin-left: 4px !important; }
.ms-2 { margin-left: 8px !important; }
.ms-3 { margin-left: 16px !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }

/* ==========================================================================
   MODAL DE VERSIONAMENTO E MIGRAÇÕES DE BANCO (Institutional Design)
   ========================================================================== */
.mig-modal-header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mig-modal-icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(var(--app-primary-rgb), 0.08);
    color: var(--app-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(var(--app-primary-rgb), 0.12);
}

.mig-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--app-slate);
    margin: 0 0 6px 0;
}

.mig-server-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mig-chip {
    font-size: 0.74rem;
    padding: 3px 10px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #e2e8f0;
}

.mig-chip-driver {
    background: rgba(var(--app-primary-rgb), 0.08);
    color: var(--app-primary);
    border-color: rgba(var(--app-primary-rgb), 0.2);
}

.app-modal-body::-webkit-scrollbar {
    width: 6px;
}

.app-modal-body::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.app-modal-body::-webkit-scrollbar-thumb {
    background: rgba(var(--app-scrollbar-rgb), 0.55);
    border-radius: 4px;
    border: 1px solid #f8f9fa;
    transition: background-color 0.2s ease;
}

.app-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--app-scrollbar);
}

.app-modal-body::-webkit-scrollbar-thumb:active {
    background: var(--app-scrollbar-hover);
}

.mig-section {
    margin-bottom: 24px;
}

.mig-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.mig-section-header.pending {
    background: #fff1f2;
    border: 1px solid #fecdd3;
}

.mig-section-header.applied {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.mig-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 700;
}

.mig-section-header.pending .mig-section-title {
    color: #be123c;
}

.mig-section-header.applied .mig-section-title {
    color: #15803d;
}

.mig-counter-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.mig-counter-badge.pending {
    background: #e11d48;
    color: #ffffff;
}

.mig-counter-badge.applied {
    background: #16a34a;
    color: #ffffff;
}

.mig-cards-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Cards de Migração */
.mig-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mig-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.mig-card.pending {
    border-left: 5px solid #e11d48;
}

.mig-card.applied {
    border-left: 5px solid #16a34a;
}

.mig-card-info {
    flex: 1;
    min-width: 0;
}

.mig-card-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.mig-version-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: monospace, var(--app-font);
}

.mig-version-pill.pending {
    background: #ffe4e6;
    color: #e11d48;
    border: 1px solid #fecdd3;
}

.mig-version-pill.applied {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.mig-card-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
}

.mig-card-desc {
    font-size: 0.83rem;
    color: #64748b;
    line-height: 1.45;
    margin-bottom: 6px;
}

.mig-blocked-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: #b91c1c;
    background: #fef2f2;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #fee2e2;
    font-weight: 500;
}

.mig-blocked-badge.mig-blocked-neutral {
    color: #64748b;
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.mig-applied-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: #059669;
    background: #f0fdf4;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 500;
    border: 1px solid #dcfce7;
}

.mig-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.mig-card-actions .btn {
    min-width: 105px;
    height: 36px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mig-empty-state {
    padding: 24px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mig-modal-rule-callout {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: #64748b;
    background: #f8fafc;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* ==========================================================================
   SWEETALERT2 GLOBAL OVERRIDES - SEMPRE ACIMA DE MODAIS E OVERLAYS
   ========================================================================== */
.swal2-container {
    z-index: 1000005 !important;
}

.swal2-container.swal2-backdrop-show,
.swal2-container.swal2-noanimation {
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
}

.swal2-popup.app-swal-popup,
.swal2-popup {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    border-radius: 16px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    padding: 24px !important;
}

.swal2-title {
    font-family: 'Manrope', sans-serif !important;
    font-weight: 700 !important;
    color: var(--app-slate) !important;
    font-size: 1.25rem !important;
}

.swal2-html-container {
    font-family: 'Manrope', sans-serif !important;
    font-size: 0.92rem !important;
    color: #475569 !important;
    line-height: 1.5 !important;
}

/* ==========================================================================
   UTILITÁRIOS GLOBAIS
   ========================================================================== */
.d-none {
    display: none !important;
}

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

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

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

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

.justify-content-end {
    justify-content: flex-end !important;
}

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

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

.flex-grow-1 {
    flex-grow: 1 !important;
}

.flex-shrink-0 {
    flex-shrink: 0 !important;
}

/* Utilitários Flexbox e Espaçamentos de Gap */
.gap-1 { gap: 6px !important; }
.gap-2 { gap: 10px !important; }
.gap-3 { gap: 16px !important; }
.gap-4 { gap: 24px !important; }
.gap-5 { gap: 32px !important; }

.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }

/* ==========================================================================
   RESPONSIVIDADE GLOBAL (MOBILE & TABLET)
   Suporte a Telas <= 992px (Tablet) e <= 768px / 640px (Mobile)
   ========================================================================== */
@media (max-width: 992px) {
    .btn-sidebar-toggle {
        display: inline-flex;
    }

    .btn-sidebar-close {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 10050 !important;
        transform: translateX(-100%);
        box-shadow: var(--app-shadow-lg);
        width: 285px;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    body.mobile-nav-active .main-content {
        pointer-events: none;
    }

    .topbar {
        padding: 0 18px;
        height: 62px;
    }

    .topbar-title {
        font-size: 1.15rem;
    }

    .page-container {
        padding: 22px 18px;
    }

    .app-global-footer {
        padding: 12px 18px;
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 16px 14px;
    }

    .topbar {
        padding: 0 14px;
        height: 58px;
    }

    .topbar-title {
        font-size: 1.05rem;
    }

    .env-tag {
        font-size: 0.72rem;
        padding: 3px 8px;
    }

    .app-global-footer {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 12px 14px;
    }

    .app-global-footer .footer-right {
        font-size: 0.76rem;
    }
}

@media (max-width: 640px) {
    .page-container {
        padding: 14px 10px;
    }

    .app-modal {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px auto !important;
        border-radius: 12px;
    }

    .app-modal-header {
        padding: 14px 18px;
    }

    .app-modal-title {
        font-size: 1.05rem;
    }

    .app-modal-body {
        padding: 16px 18px;
        gap: 14px;
    }

    .app-modal-footer {
        padding: 12px 18px;
        flex-direction: column-reverse;
        gap: 8px;
    }

    .app-modal-footer .btn {
        width: 100%;
        min-width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   DROPDOWN MENU UNIVERSAL (BUTTON GROUP ACTIONS)
   ========================================================================== */
.app-dropdown {
    position: relative;
    display: inline-block;
}

.app-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Botão de Ações Padronizado com a identidade visual da marca (Vinho / Icon-only) */
.app-action-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.app-action-group .app-dropdown-toggle {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    gap: 0 !important;
    border-radius: var(--app-radius-sm, 6px) !important;
    background-color: var(--app-primary) !important;
    border: 1px solid var(--app-primary) !important;
    color: var(--app-on-primary) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    font-size: 0.9rem !important;
    line-height: 1 !important;
    transition: var(--app-transition, all 0.2s ease);
    cursor: pointer;
    box-sizing: border-box !important;
}

.app-action-group .app-dropdown-toggle:hover,
.app-action-group .app-dropdown-toggle:focus,
.app-action-group.show .app-dropdown-toggle {
    background-color: var(--app-primary-hover) !important;
    border-color: var(--app-primary-hover) !important;
    color: var(--app-on-primary) !important;
    box-shadow: 0 3px 8px rgba(var(--app-primary-rgb), 0.35);
}

.app-action-group .app-dropdown-toggle i {
    pointer-events: none;
    color: #ffffff !important;
    margin: 0 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1 !important;
}

.app-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    z-index: 1050;
    display: none;
    min-width: 175px;
    padding: 6px 0;
    margin: 4px 0 0;
    font-size: 0.88rem;
    color: var(--app-slate);
    text-align: left;
    list-style: none;
    background-color: #ffffff;
    background-clip: padding-box;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
    animation: app-dropdown-fade 0.15s ease-out;
}

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

@keyframes app-dropdown-fade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 14px;
    clear: both;
    font-weight: 500;
    font-size: 0.86rem;
    color: var(--app-slate);
    text-align: inherit;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.app-dropdown-item:hover,
.app-dropdown-item:focus {
    color: var(--app-primary);
    background-color: var(--app-surface-alt, #f1f3f5);
    outline: none;
}

.app-dropdown-item.text-danger:hover {
    color: #b91c1c !important;
    background-color: #fef2f2 !important;
}

.app-dropdown-item.text-success:hover {
    color: #047857 !important;
    background-color: #ecfdf5 !important;
}

.app-dropdown-item.text-primary:hover {
    color: #1d4ed8 !important;
    background-color: #eff6ff !important;
}

.app-dropdown-divider {
    height: 1px;
    margin: 5px 0;
    overflow: hidden;
    background-color: #e2e8f0;
}

/* Dropdown aberto: o menu fica acima do conteúdo. Dentro de tabelas ele é posicionado como flutuante
   (position: fixed, via App.initDropdowns), então a linha não é elevada sobre o cabeçalho fixo. */
.app-dropdown-menu.show {
    display: block;
    z-index: 1070 !important;
}

.app-dropdown-menu.is-floating {
    animation: none;
}

.app-dropdown.dropup .app-dropdown-menu {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 4px !important;
}

/* ==========================================================================
   SISTEMA DE ABAS INSTITUCIONAL
   ========================================================================== */
.app-tabs-container {
    width: 100%;
}

.app-tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
    padding: 0;
}

.app-tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 8px 8px 0 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-tab-btn:hover {
    color: #1e293b;
    background: #f8fafc;
}

.app-tab-btn.active {
    color: var(--app-primary);
    border-bottom-color: var(--app-primary);
    font-weight: 700;
    background: rgba(var(--app-primary-rgb), 0.06);
}

.app-tab-pane {
    display: none;
}

.app-tab-pane.active {
    display: block;
    animation: appTabFade 0.2s ease-out;
}

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


/* ==========================================================================
   UTILITÁRIOS RESPONSIVOS DE EXIBIÇÃO (SM, MD, LG)
   ========================================================================== */
@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-inline { display: inline !important; }
    .d-sm-inline-block { display: inline-block !important; }
    .d-sm-flex { display: flex !important; }
    .d-sm-table-cell { display: table-cell !important; }
}

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-inline { display: inline !important; }
    .d-md-inline-block { display: inline-block !important; }
    .d-md-flex { display: flex !important; }
    .d-md-table-cell { display: table-cell !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-block { display: block !important; }
    .d-lg-inline { display: inline !important; }
    .d-lg-inline-block { display: inline-block !important; }
    .d-lg-flex { display: flex !important; }
    .d-lg-table-cell { display: table-cell !important; }
}

/* Utilitários específicos Mobile (< 768px) */
.d-mobile-block,
.d-mobile-inline,
.d-mobile-flex {
    display: none !important;
}

@media (max-width: 767.98px) {
    .d-mobile-none { display: none !important; }
    .d-mobile-block { display: block !important; }
    .d-mobile-inline { display: inline !important; }
    .d-mobile-flex { display: flex !important; }
}

