/* ===================================================
   SISTEMA DE OFICINA MECÂNICA - CSS MODERNO
   Design Clean & Responsivo
   =================================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.2s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* ===== SIDEBAR MODERNO ===== */
.sidebar-modern {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: var(--white);
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-modern .sidebar-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-modern .sidebar-header img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 0.5rem;
    border: 2px solid var(--primary);
    object-fit: contain;
    object-position: center;
    background: rgba(255,255,255,.06);
}

.sidebar-modern .sidebar-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--white);
}

.sidebar-modern .sidebar-header small {
    color: var(--gray-400);
    font-size: 0.75rem;
}

.sidebar-modern .sidebar-header .badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.sidebar-modern .nav-menu {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.sidebar-modern .nav-menu li {
    margin: 2px 0.5rem;
}

.sidebar-modern .nav-menu li a {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: var(--gray-300);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 0.85rem;
    font-weight: 500;
}

.sidebar-modern .nav-menu li a:hover,
.sidebar-modern .nav-menu li a.active {
    background: rgba(37, 99, 235, 0.2);
    color: var(--white);
}

.sidebar-modern .nav-menu li a i {
    width: 20px;
    margin-right: 0.75rem;
    text-align: center;
    font-size: 1rem;
}

.sidebar-modern .nav-section {
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-500);
    font-weight: 700;
}

/* ===== CONTENT AREA ===== */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    transition: var(--transition);
}

/* ===== TOP BAR ===== */
.topbar {
    background: var(--white);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gray-200);
}

.topbar .topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar .topbar-left h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    display: none;
}

.btn-toggle-sidebar:hover {
    background: var(--gray-100);
}

/* ===== CONTENT WRAPPER ===== */
.content-wrapper {
    padding: 1.5rem;
}

/* ===== CARDS ===== */
.card-modern {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card-modern:hover {
    box-shadow: var(--shadow-md);
}

.card-modern .card-header-modern {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-modern .card-header-modern h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-modern .card-body-modern {
    padding: 1.5rem;
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    margin-bottom: 1rem;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.bg-primary { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.bg-success { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.bg-warning { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.bg-danger { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-icon.bg-info { background: var(--info-light); color: var(--info); }

.stat-card .stat-info h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.stat-card .stat-info p {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ===== TABLES ===== */
.table-modern {
    width: 100%;
    border-collapse: collapse;
}

.table-modern thead th {
    background: var(--gray-50);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
    text-align: left;
    white-space: nowrap;
}

.table-modern tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.85rem;
    color: var(--gray-700);
    vertical-align: middle;
}

.table-modern tbody tr:hover {
    background: var(--gray-50);
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

/* ===== BUTTONS ===== */
.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.5;
}

.btn-modern:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; }

.btn-primary-modern { background: var(--primary); color: var(--white); }
.btn-primary-modern:hover { background: var(--primary-dark); color: var(--white); }

.btn-success-modern { background: var(--success); color: var(--white); }
.btn-success-modern:hover { background: #059669; color: var(--white); }

.btn-warning-modern { background: var(--warning); color: var(--white); }
.btn-warning-modern:hover { background: #d97706; color: var(--white); }

.btn-danger-modern { background: var(--danger); color: var(--white); }
.btn-danger-modern:hover { background: #dc2626; color: var(--white); }

.btn-outline-modern {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline-modern:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-sm-modern {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg-modern {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* ===== FORMS ===== */
.form-modern .form-group {
    margin-bottom: 1rem;
}

.form-modern label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.35rem;
}

.form-modern .form-control,
.form-modern select,
.form-modern textarea {
    width: 100%;
    padding: 0.6rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--gray-800);
    background: var(--white);
    transition: var(--transition);
    outline: none;
}

.form-modern .form-control:focus,
.form-modern select:focus,
.form-modern textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #155e75; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* ===== PHOTO GALLERY ===== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.photo-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: var(--transition);
}

.photo-item:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .photo-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.photo-item:hover .photo-delete {
    opacity: 1;
}

.photo-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-50);
}

.photo-upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.photo-upload-area i {
    font-size: 2rem;
    color: var(--gray-400);
    margin-bottom: 0.5rem;
}

.photo-upload-area p {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin: 0;
}

/* ===== CHART CONTAINER ===== */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--primary-dark) 100%);
    padding: 1rem;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-box .logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.login-box .logo-area img {
    width: 120px;
    margin-bottom: 1rem;
}

.login-box .logo-area h3 {
    color: var(--gray-800);
    font-weight: 700;
    margin: 0 0 0.25rem;
    font-size: 1.3rem;
}

.login-box .logo-area p {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin: 0;
}

/* ===== PAYMENT CARDS ===== */
.plan-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 2px solid var(--gray-200);
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
}

.plan-card:hover,
.plan-card.featured {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.plan-card.featured {
    position: relative;
}

.plan-card.featured::before {
    content: 'Popular';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 0.2rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.plan-card h4 {
    font-size: 1.1rem;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.plan-card .price {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.plan-card .price small {
    font-size: 0.9rem;
    color: var(--gray-500);
    font-weight: 400;
}

.plan-card .features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    text-align: left;
}

.plan-card .features li {
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.plan-card .features li i {
    color: var(--success);
    margin-right: 0.5rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar-modern {
        transform: translateX(-100%);
    }
    
    .sidebar-modern.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .btn-toggle-sidebar {
        display: block;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card .stat-info h3 {
        font-size: 1.2rem;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .topbar {
        padding: 0.5rem 1rem;
    }
    
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 1.5rem;
    }
    
    .table-modern {
        font-size: 0.75rem;
    }
    
    .table-modern thead th,
    .table-modern tbody td {
        padding: 0.5rem;
    }
}

/* ===== OVERLAY SIDEBAR MOBILE ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== MODAL MODERNO ===== */
.modal-modern .modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-modern .modal-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
}

.modal-modern .modal-body {
    padding: 1.5rem;
}

.modal-modern .modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

/* ===== ALERTS ===== */
.alert-modern {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success-modern { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger-modern { background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning-modern { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info-modern { background: var(--info-light); color: #155e75; border: 1px solid #67e8f9; }

/* ===== STATUS INDICATORS ===== */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--gray-400); }
.status-dot.blocked { background: var(--danger); }
.status-dot.pending { background: var(--warning); }

/* ===== LIGHTBOX ===== */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    border: none;
}

/* ===== PROGRESS BAR ===== */
.progress-modern {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-modern .progress-bar-modern {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h5 {
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ===== LEGACY CONTENT COMPATIBILITY =====
   Mantém páginas antigas legíveis quando usam o header/footer moderno. */
.ibox {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.ibox-title {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

.ibox-title .btn-block {
    text-align: left;
    font-weight: 600;
    border-radius: var(--radius);
}

.ibox-content {
    background: var(--white);
    padding: 1.5rem;
}

.float-e-margins {
    margin-bottom: 1.5rem;
}

.btn-white {
    background: var(--white);
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-white:hover,
.btn-white:focus {
    background: var(--gray-100);
    color: var(--gray-800);
}

.table-responsive {
    border-radius: var(--radius);
}

.table thead th,
.table tfoot th {
    background: var(--gray-50);
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody td {
    color: var(--gray-700);
    font-size: 0.85rem;
    vertical-align: middle;
}

.form-horizontal .form-control,
.form-horizontal select,
.form-horizontal textarea,
.form-horizontal input[type="text"],
.form-horizontal input[type="email"],
.form-horizontal input[type="password"],
.form-horizontal input[type="number"],
.form-horizontal input[type="date"] {
    max-width: 100%;
}

/* ===== MODERNIZAÇÃO RESPONSIVA DOS FORMULÁRIOS LEGADOS =====
   Aplica o mesmo comportamento visual do cadastro moderno de cliente
   nas páginas antigas que ainda usam form-horizontal/ibox. */
.ibox .form-horizontal {
    max-width: 1180px;
    margin: 0 auto;
}

.ibox .form-horizontal > .row,
.ibox .form-horizontal .tab-pane > .row {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin: 0 0 1.25rem;
    background: var(--gray-50);
}

.ibox .form-horizontal .row {
    margin-left: 0;
    margin-right: 0;
}

.ibox .form-horizontal .row > [class*="col-"],
.ibox .form-horizontal [class*="col-"] > [class*="col-"] {
    float: none;
    padding-left: 0;
    padding-right: 0;
}

.ibox .form-horizontal .row > .col-md-12,
.ibox .form-horizontal .row > .col-lg-12,
.ibox .form-horizontal .row > .col-sm-12 {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}

.ibox .form-horizontal .row > .col-md-12 > h3,
.ibox .form-horizontal .row > .col-lg-12 > h3,
.ibox .form-horizontal .row > .col-sm-12 > h3,
.ibox .form-horizontal .row > .col-md-12 > center,
.ibox .form-horizontal .row > .col-lg-12 > center,
.ibox .form-horizontal .row > .col-sm-12 > center {
    grid-column: 1 / -1;
    margin: 0 0 0.25rem;
}

.ibox .form-horizontal h3 {
    color: var(--gray-800);
    font-size: 0.95rem;
    font-weight: 700;
    text-align: left !important;
}

.ibox .form-horizontal h3 .text-warning {
    color: var(--gray-800) !important;
}

.ibox .form-horizontal .row > .col-md-12 > .col-md-3,
.ibox .form-horizontal .row > .col-lg-12 > .col-md-3,
.ibox .form-horizontal .row > .col-sm-12 > .col-md-3 {
    grid-column: span 3;
    width: auto;
    max-width: none;
}

.ibox .form-horizontal .row > .col-md-12 > .col-md-4,
.ibox .form-horizontal .row > .col-lg-12 > .col-md-4,
.ibox .form-horizontal .row > .col-sm-12 > .col-md-4,
.ibox .form-horizontal .row > .col-md-12 > .col-sm-4,
.ibox .form-horizontal .row > .col-lg-12 > .col-sm-4,
.ibox .form-horizontal .row > .col-sm-12 > .col-sm-4 {
    grid-column: span 4;
    width: auto;
    max-width: none;
}

.ibox .form-horizontal .row > .col-md-12 > .col-md-6,
.ibox .form-horizontal .row > .col-lg-12 > .col-md-6,
.ibox .form-horizontal .row > .col-sm-12 > .col-md-6 {
    grid-column: span 6;
    width: auto;
    max-width: none;
}

.ibox .form-horizontal .row > .col-md-12 > .col-md-8,
.ibox .form-horizontal .row > .col-lg-12 > .col-md-8,
.ibox .form-horizontal .row > .col-sm-12 > .col-md-8 {
    grid-column: span 8;
    width: auto;
    max-width: none;
}

.ibox .form-horizontal .row > .col-md-12 > .col-md-12,
.ibox .form-horizontal .row > .col-lg-12 > .col-md-12,
.ibox .form-horizontal .row > .col-sm-12 > .col-md-12,
.ibox .form-horizontal .row > .col-md-12 > .col-lg-12,
.ibox .form-horizontal .row > .col-lg-12 > .col-lg-12,
.ibox .form-horizontal .row > .col-sm-12 > .col-lg-12 {
    grid-column: 1 / -1;
    width: auto;
    max-width: none;
}

.ibox .form-horizontal [class*="col-"] > [class*="col-"] {
    width: 100%;
    max-width: none;
}

.ibox .form-horizontal label.form-control,
.ibox .form-horizontal label {
    display: block;
    width: 100% !important;
    height: auto;
    min-height: 0;
    margin: 0 0 0.35rem;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--gray-700);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.35;
}

.ibox .form-horizontal .form-control,
.ibox .form-horizontal select,
.ibox .form-horizontal textarea,
.ibox .form-horizontal input[type="text"],
.ibox .form-horizontal input[type="email"],
.ibox .form-horizontal input[type="password"],
.ibox .form-horizontal input[type="number"],
.ibox .form-horizontal input[type="date"] {
    width: 100% !important;
    max-width: 100%;
    min-height: 42px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-800);
    font-size: 0.9rem;
}

.ibox .form-horizontal textarea.form-control,
.ibox .form-horizontal textarea {
    min-height: 110px;
    resize: vertical;
}

.ibox .form-horizontal .form-control:focus,
.ibox .form-horizontal select:focus,
.ibox .form-horizontal textarea:focus,
.ibox .form-horizontal input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.12);
    outline: none;
}

.ibox .form-horizontal input[readonly],
.ibox .form-horizontal textarea[readonly],
.ibox .form-horizontal select[disabled] {
    background: var(--gray-100);
    color: var(--gray-600);
}

.ibox .form-horizontal center,
.ibox .form-horizontal .form-actions,
.ibox .form-horizontal .col-lg-12 center {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    text-align: right;
}

.ibox .form-horizontal .btn {
    min-height: 38px;
    border-radius: var(--radius);
    font-weight: 600;
    margin-top: 0 !important;
}

.ibox .form-horizontal .table-responsive,
.ibox .form-horizontal table {
    grid-column: 1 / -1;
}

@media (max-width: 991.98px) {
    .ibox .form-horizontal .row > .col-md-12 > .col-md-3,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-3,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-3,
    .ibox .form-horizontal .row > .col-md-12 > .col-md-4,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-4,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-4,
    .ibox .form-horizontal .row > .col-md-12 > .col-sm-4,
    .ibox .form-horizontal .row > .col-lg-12 > .col-sm-4,
    .ibox .form-horizontal .row > .col-sm-12 > .col-sm-4,
    .ibox .form-horizontal .row > .col-md-12 > .col-md-6,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-6,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-6,
    .ibox .form-horizontal .row > .col-md-12 > .col-md-8,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-8,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-8 {
        grid-column: span 6;
    }
}

@media (max-width: 575.98px) {
    .ibox .form-horizontal > .row,
    .ibox .form-horizontal .tab-pane > .row {
        padding: 1rem;
    }

    .ibox .form-horizontal .row > .col-md-12,
    .ibox .form-horizontal .row > .col-lg-12,
    .ibox .form-horizontal .row > .col-sm-12 {
        grid-template-columns: 1fr;
    }

    .ibox .form-horizontal .row > .col-md-12 > .col-md-3,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-3,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-3,
    .ibox .form-horizontal .row > .col-md-12 > .col-md-4,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-4,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-4,
    .ibox .form-horizontal .row > .col-md-12 > .col-sm-4,
    .ibox .form-horizontal .row > .col-lg-12 > .col-sm-4,
    .ibox .form-horizontal .row > .col-sm-12 > .col-sm-4,
    .ibox .form-horizontal .row > .col-md-12 > .col-md-6,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-6,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-6,
    .ibox .form-horizontal .row > .col-md-12 > .col-md-8,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-8,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-8,
    .ibox .form-horizontal .row > .col-md-12 > .col-md-12,
    .ibox .form-horizontal .row > .col-lg-12 > .col-md-12,
    .ibox .form-horizontal .row > .col-sm-12 > .col-md-12 {
        grid-column: 1 / -1;
    }

    .ibox .form-horizontal center,
    .ibox .form-horizontal .form-actions,
    .ibox .form-horizontal .col-lg-12 center {
        flex-direction: column-reverse;
    }

    .ibox .form-horizontal center .btn,
    .ibox .form-horizontal .form-actions .btn,
    .ibox .form-horizontal .col-lg-12 center .btn {
        width: 100%;
    }
}

/* Correção para formulários legados que usam .row > .form-group diretamente. */
.ibox .form-horizontal > .row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}

.ibox .form-horizontal > .row > .form-group,
.ibox .form-horizontal .tab-pane > .row > .form-group {
    grid-column: span 4;
    min-width: 0;
    margin-bottom: 0;
}

.ibox .form-horizontal > .row > center,
.ibox .form-horizontal .tab-pane > .row > center,
.ibox .form-horizontal > .row > h2,
.ibox .form-horizontal .tab-pane > .row > h2,
.ibox .form-horizontal > .row > h3,
.ibox .form-horizontal .tab-pane > .row > h3 {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin: 0;
    text-align: left;
}

.ibox .form-horizontal > .row > center h2,
.ibox .form-horizontal .tab-pane > .row > center h2,
.ibox .form-horizontal > .row > center h3,
.ibox .form-horizontal .tab-pane > .row > center h3 {
    margin: 0;
    color: var(--gray-800);
    font-size: 0.95rem;
    font-weight: 700;
}

.ibox .form-horizontal .form-group > [class*="col-"] {
    width: 100%;
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

.ibox .form-horizontal .form-group label[class*="col-"] {
    width: 100% !important;
    max-width: none;
}

@media (max-width: 991.98px) {
    .ibox .form-horizontal > .row > .form-group,
    .ibox .form-horizontal .tab-pane > .row > .form-group {
        grid-column: span 6;
    }
}

@media (max-width: 575.98px) {
    .ibox .form-horizontal > .row {
        grid-template-columns: 1fr;
    }

    .ibox .form-horizontal > .row > .form-group,
    .ibox .form-horizontal .tab-pane > .row > .form-group {
        grid-column: 1 / -1;
    }
}

/* ===== FORMULÁRIOS MODERNOS DE CADASTRO ===== */
.cadastro-form-card {
    max-width: 1180px;
    margin: 0 auto;
}

.cadastro-form-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.cadastro-form-intro p {
    margin: 0;
    color: var(--gray-500);
    font-size: 0.9rem;
}

.cadastro-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--gray-50);
}

.cadastro-section-title,
.cadastro-client-header .cadastro-section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    color: var(--gray-800);
    font-size: 0.95rem;
    font-weight: 700;
}

.cadastro-client-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.cadastro-client-header .cadastro-section-title {
    margin-bottom: 0;
}

.cadastro-section-title i {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 999px;
}

.cadastro-form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}

.cadastro-field {
    grid-column: span 4;
    min-width: 0;
}

.cadastro-field--wide {
    grid-column: span 8;
}

.cadastro-field--full {
    grid-column: 1 / -1;
}

.cadastro-field label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--gray-700);
    font-size: 0.8rem;
    font-weight: 600;
}

.cadastro-required {
    color: var(--danger);
}

.cadastro-field .form-control,
.cadastro-field select,
.cadastro-field textarea {
    width: 100%;
    min-height: 42px;
    border-color: var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.cadastro-field .form-control:focus,
.cadastro-field select:focus,
.cadastro-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.12);
}

.cadastro-field textarea.form-control,
.cadastro-field textarea {
    min-height: 110px;
    resize: vertical;
}

.cadastro-help {
    display: block;
    margin-top: 0.3rem;
    color: var(--gray-500);
    font-size: 0.75rem;
}

.cadastro-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;
}

.cadastro-items-table {
    min-width: 760px;
}

@media (max-width: 991.98px) {
    .cadastro-field,
    .cadastro-field--wide {
        grid-column: span 6;
    }
}

@media (max-width: 575.98px) {
    .cadastro-section {
        padding: 1rem;
    }

    .cadastro-field,
    .cadastro-field--wide {
        grid-column: 1 / -1;
    }

    .cadastro-actions {
        flex-direction: column-reverse;
    }

    .cadastro-actions .btn-modern {
        width: 100%;
        justify-content: center;
    }
}

/* ===== PWA MOBILE RESPONSIVENESS PASS =====
   Ajustes globais para uso no celular/PWA sem alterar regras de negócio. */
html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-width: 0;
    overflow-x: hidden;
}

img,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

.table-responsive,
.card-body-modern,
.ibox-content,
.panel-body,
.modal-body {
    -webkit-overflow-scrolling: touch;
}

.table-responsive,
.card-body-modern,
.ibox-content,
.panel-body {
    overflow-x: auto;
}

.table-modern,
.table,
table.dataTable,
.fc-table {
    max-width: 100%;
}

.table-modern th,
.table-modern td,
.table th,
.table td {
    vertical-align: middle;
}

.form-control,
.form-modern .form-control,
.form-modern select,
.form-modern textarea,
.cadastro-field .form-control,
.cadastro-field select,
.cadastro-field textarea {
    min-height: 42px;
}

.btn,
.btn-modern,
button,
input[type="button"],
input[type="submit"] {
    min-height: 40px;
    touch-action: manipulation;
}

.btn-modern,
.btn,
.card-header-modern,
.topbar,
.cadastro-actions,
.ordem-card__actions,
.modal-footer,
.form-inline,
.bulk-delete-toolbar {
    flex-wrap: wrap;
}

.photo-upload-area {
    min-height: 120px;
}

.modal-dialog {
    max-width: calc(100% - 1rem);
}

.modal-content {
    max-height: calc(100vh - 1rem);
    overflow: hidden;
}

.modal-body {
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .content-wrapper {
        padding: 1rem;
    }

    .card-modern .card-header-modern,
    .card-modern .card-body-modern {
        padding: 1rem;
    }

    .stat-card {
        min-height: 100%;
    }

    .table-modern,
    .table,
    table.dataTable,
    .fc-table,
    .ordem-items,
    .cadastro-items-table {
        min-width: 720px;
    }
}

@media (max-width: 768px) {
    .main-content {
        width: 100%;
        max-width: 100vw;
    }

    .sidebar-modern {
        width: min(86vw, 320px);
    }

    .topbar {
        gap: 0.75rem;
    }

    .topbar .topbar-left {
        min-width: 0;
        flex: 1;
    }

    .topbar .topbar-left h5 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar .topbar-right {
        gap: 0.5rem;
        justify-content: flex-end;
    }

    .topbar .user-info {
        justify-content: flex-end;
    }

    .card-modern {
        border-radius: var(--radius);
        margin-bottom: 1rem;
    }

    .card-modern .card-header-modern {
        align-items: flex-start;
        gap: 0.75rem;
    }

    .row.mb-3 > [class*="col-"] {
        margin-bottom: 0.75rem;
        text-align: left !important;
    }

    .table-modern,
    .table,
    table.dataTable,
    .fc-table,
    .ordem-items,
    .cadastro-items-table {
        display: block;
        width: 100%;
        min-width: 680px;
        overflow-x: auto;
        white-space: nowrap;
    }

    .table-modern thead,
    .table-modern tbody,
    .table-modern tr,
    .table-modern th,
    .table-modern td {
        white-space: nowrap;
    }

    .btn-modern,
    .btn {
        padding: 0.6rem 0.85rem;
    }

    .btn-sm-modern,
    .btn-sm {
        min-height: 36px;
        padding: 0.45rem 0.65rem;
    }

    .form-inline {
        align-items: stretch;
        gap: 0.5rem;
    }

    .form-inline .form-control,
    .form-inline .btn,
    .form-inline .btn-modern {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 0.5rem;
    }

    .photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .photo-item .photo-delete {
        opacity: 1;
        width: 34px;
        height: 34px;
    }

    .photo-upload-area {
        padding: 1.25rem;
    }

    .modal-dialog {
        margin: 0.5rem auto;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 0.92rem;
    }

    .login-page {
        padding: 1rem;
        align-items: flex-start;
    }

    .login-box {
        width: 100%;
        max-width: 100%;
        margin-top: 1rem;
        border-radius: var(--radius-lg);
    }

    .login-box .logo-area img {
        width: 92px !important;
    }

    .login-box .logo-area h3 {
        font-size: 1.15rem;
    }

    .content-wrapper {
        padding: 0.75rem;
    }

    .topbar {
        padding: 0.5rem 0.75rem;
    }

    .topbar .topbar-right .btn-modern {
        padding: 0.45rem 0.6rem;
        font-size: 0.75rem;
    }

    .card-modern .card-header-modern,
    .card-modern .card-body-modern {
        padding: 0.85rem;
    }

    .card-modern .card-header-modern h5 {
        font-size: 0.92rem;
    }

    .stat-card {
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.9rem;
    }

    .stat-card .stat-icon {
        flex: 0 0 auto;
    }

    .alert-modern {
        align-items: flex-start;
        padding: 0.85rem;
    }

    .btn-modern,
    .btn,
    .btn-lg-modern {
        width: 100%;
        justify-content: center;
    }

    td .btn-modern,
    td .btn,
    .card-header-modern .btn-modern,
    .card-header-modern .btn {
        width: auto;
    }

    .cadastro-section,
    .ibox .form-horizontal > .row,
    .ibox .form-horizontal .tab-pane > .row {
        padding: 0.85rem;
        border-radius: var(--radius);
    }

    .cadastro-form-intro,
    .cadastro-client-header,
    .cadastro-section-title,
    .ordem-card__header,
    .ordem-card__actions,
    .cadastro-actions,
    .modal-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .ordem-card__header,
    .ordem-section {
        padding: 1rem;
    }

    .ordem-card__title h2 {
        font-size: 1.2rem;
    }

    .ordem-total-box {
        text-align: left;
    }

    .photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .photo-upload-area i {
        font-size: 1.6rem;
    }

    [style*="width:350px"],
    [style*="width:430%"],
    [style*="width:90px"],
    [style*="width:120px"],
    [style*="width: 120px"] {
        max-width: 100% !important;
    }

    input[style*="width:350px"],
    select[style*="width:350px"],
    input[style*="width:430%"],
    select[style*="width:430%"] {
        width: 100% !important;
    }
}

@media (max-width: 390px) {
    .photo-grid {
        grid-template-columns: 1fr;
    }

    .table-modern,
    .table,
    table.dataTable,
    .fc-table,
    .ordem-items,
    .cadastro-items-table {
        min-width: 620px;
    }
}

/* ===== TEMA CLARO/ESCURO ===== */
.theme-switcher {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--gray-600);
}

.theme-switcher select {
    min-width: 96px;
    background: var(--white);
    color: var(--gray-800);
    border-color: var(--gray-300);
}

body.theme-escuro {
    --primary-light: #1e3a8a;
    --secondary: #94a3b8;
    --dark: #e2e8f0;
    --gray-50: #0f172a;
    --gray-100: #111827;
    --gray-200: #1f2937;
    --gray-300: #334155;
    --gray-400: #94a3b8;
    --gray-500: #cbd5e1;
    --gray-600: #d1d5db;
    --gray-700: #e2e8f0;
    --gray-800: #f8fafc;
    --gray-900: #020617;
    --white: #111827;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow: 0 1px 3px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.35);
    --shadow-md: 0 8px 18px rgba(0,0,0,0.4);
    --shadow-lg: 0 18px 30px rgba(0,0,0,0.45);
    background: var(--gray-50);
    color: var(--gray-800);
}

body.theme-escuro .sidebar-modern {
    background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
    border-right: 1px solid var(--gray-200);
}

body.theme-escuro .topbar,
body.theme-escuro .card-modern,
body.theme-escuro .stat-card,
body.theme-escuro .modal-content,
body.theme-escuro .dropdown-menu,
body.theme-escuro .ibox-content,
body.theme-escuro .ibox-title {
    background: var(--white);
    color: var(--gray-800);
    border-color: var(--gray-200);
}

body.theme-escuro .form-control,
body.theme-escuro .custom-select,
body.theme-escuro input,
body.theme-escuro select,
body.theme-escuro textarea {
    background: #0f172a;
    color: #f8fafc;
    border-color: var(--gray-300);
}

body.theme-escuro .form-control:focus,
body.theme-escuro textarea:focus,
body.theme-escuro select:focus {
    background: #0f172a;
    color: #f8fafc;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

body.theme-escuro .table,
body.theme-escuro .table-modern,
body.theme-escuro table {
    color: var(--gray-800);
}

body.theme-escuro .table-modern thead,
body.theme-escuro table thead,
body.theme-escuro .table thead th {
    background: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--gray-200);
}

body.theme-escuro .table-modern td,
body.theme-escuro .table-modern th,
body.theme-escuro .table td,
body.theme-escuro .table th,
body.theme-escuro table td,
body.theme-escuro table th {
    border-color: var(--gray-200);
}

body.theme-escuro .text-muted,
body.theme-escuro small,
body.theme-escuro .help-block {
    color: var(--gray-400) !important;
}

@media (max-width: 768px) {
    .theme-switcher select {
        max-width: 82px;
    }
}

/* Reforço de contraste do tema escuro em telas legadas e componentes Bootstrap/Inspinia */
html.theme-escuro,
body.theme-escuro {
    background: #0f172a !important;
    color: #f8fafc !important;
}

body.theme-escuro .main-content,
body.theme-escuro .content-wrapper,
body.theme-escuro .wrapper,
body.theme-escuro .wrapper-content,
body.theme-escuro .gray-bg {
    background: #0f172a !important;
    color: #f8fafc !important;
}

body.theme-escuro h1,
body.theme-escuro h2,
body.theme-escuro h3,
body.theme-escuro h4,
body.theme-escuro h5,
body.theme-escuro h6,
body.theme-escuro p,
body.theme-escuro span,
body.theme-escuro label,
body.theme-escuro .control-label,
body.theme-escuro .form-text,
body.theme-escuro .help-block,
body.theme-escuro .topbar .user-info,
body.theme-escuro .topbar .topbar-left h5,
body.theme-escuro .card-modern .card-header-modern h5,
body.theme-escuro .ibox-title h5,
body.theme-escuro .ibox-content,
body.theme-escuro .panel-body,
body.theme-escuro .modal-title {
    color: #f8fafc !important;
}

body.theme-escuro i,
body.theme-escuro .fa,
body.theme-escuro .fas,
body.theme-escuro .far,
body.theme-escuro .fab,
body.theme-escuro .btn-toggle-sidebar,
body.theme-escuro .theme-switcher i,
body.theme-escuro .nav-menu a i {
    color: #e0f2fe !important;
}

body.theme-escuro a:not(.btn):not(.nav-link),
body.theme-escuro .btn-link {
    color: #93c5fd !important;
}

body.theme-escuro .btn-outline-modern,
body.theme-escuro .btn-default,
body.theme-escuro .btn-white {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

body.theme-escuro .well,
body.theme-escuro .panel,
body.theme-escuro .panel-heading,
body.theme-escuro .panel-body,
body.theme-escuro .modal-header,
body.theme-escuro .modal-body,
body.theme-escuro .modal-footer,
body.theme-escuro .list-group-item {
    background: #111827 !important;
    color: #f8fafc !important;
    border-color: #1f2937 !important;
}

body.theme-escuro .table-modern tbody tr:hover,
body.theme-escuro .table tbody tr:hover,
body.theme-escuro table tbody tr:hover {
    background: #1e293b !important;
}

body.theme-escuro .table-striped tbody tr:nth-of-type(odd),
body.theme-escuro table tbody tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.55);
}

body.theme-escuro .badge,
body.theme-escuro .label {
    color: #ffffff !important;
}

/* Badges/status com contraste alto no tema escuro */
body.theme-escuro .badge,
body.theme-escuro .label,
body.theme-escuro .fc-badge {
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.35), 0 0 12px rgba(148, 163, 184, 0.16) !important;
    font-weight: 700 !important;
    text-shadow: none !important;
}

body.theme-escuro .badge-success,
body.theme-escuro .label-success,
body.theme-escuro .fc-badge-ok {
    background: #16a34a !important;
    color: #ffffff !important;
    border-color: #86efac !important;
}

body.theme-escuro .badge-primary,
body.theme-escuro .label-primary,
body.theme-escuro .fc-badge-info {
    background: #2563eb !important;
    color: #ffffff !important;
    border-color: #93c5fd !important;
}

body.theme-escuro .badge-warning,
body.theme-escuro .label-warning,
body.theme-escuro .label-warning-light,
body.theme-escuro .badge-warning-light,
body.theme-escuro .fc-badge-warn {
    background: #d97706 !important;
    color: #ffffff !important;
    border-color: #fcd34d !important;
}

body.theme-escuro .badge-danger,
body.theme-escuro .label-danger,
body.theme-escuro .fc-badge-bad {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #fca5a5 !important;
}

body.theme-escuro .badge-secondary,
body.theme-escuro .label-default,
body.theme-escuro .label-inverse,
body.theme-escuro .badge-inverse {
    background: #475569 !important;
    color: #ffffff !important;
    border-color: #cbd5e1 !important;
}

/* Correção de contraste dos formulários no tema escuro.
   Algumas telas financeiras usam cards claros com labels globais do tema escuro,
   o que deixava textos e placeholders quase invisíveis. Mantemos os cards,
   tabelas e campos escuros no tema escuro para garantir leitura consistente. */
body.theme-escuro .topbar,
body.theme-escuro .card-modern,
body.theme-escuro .stat-card,
body.theme-escuro .ibox,
body.theme-escuro .ibox-title,
body.theme-escuro .ibox-content,
body.theme-escuro .panel,
body.theme-escuro .panel-heading,
body.theme-escuro .panel-body,
body.theme-escuro .modal-content,
body.theme-escuro .dropdown-menu {
    background: #111827 !important;
    color: #f8fafc !important;
    border-color: #1f2937 !important;
}

body.theme-escuro .card-modern .card-header-modern,
body.theme-escuro .card-modern .card-body-modern,
body.theme-escuro .stat-card .stat-info,
body.theme-escuro .form-inline,
body.theme-escuro details,
body.theme-escuro summary {
    background: transparent !important;
    color: #f8fafc !important;
}

body.theme-escuro .card-modern h1,
body.theme-escuro .card-modern h2,
body.theme-escuro .card-modern h3,
body.theme-escuro .card-modern h4,
body.theme-escuro .card-modern h5,
body.theme-escuro .card-modern h6,
body.theme-escuro .card-modern p,
body.theme-escuro .card-modern span,
body.theme-escuro .card-modern label,
body.theme-escuro .card-modern small,
body.theme-escuro .stat-card h1,
body.theme-escuro .stat-card h2,
body.theme-escuro .stat-card h3,
body.theme-escuro .stat-card h4,
body.theme-escuro .stat-card p,
body.theme-escuro .stat-card span,
body.theme-escuro .stat-card label,
body.theme-escuro .stat-card small {
    color: #f8fafc !important;
}

body.theme-escuro .form-control,
body.theme-escuro .custom-select,
body.theme-escuro input,
body.theme-escuro select,
body.theme-escuro textarea {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
    caret-color: #f8fafc;
}

body.theme-escuro .form-control::placeholder,
body.theme-escuro input::placeholder,
body.theme-escuro textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1;
}

body.theme-escuro .form-control:focus,
body.theme-escuro input:focus,
body.theme-escuro select:focus,
body.theme-escuro textarea:focus {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 0.2rem rgba(96, 165, 250, 0.28) !important;
}

body.theme-escuro input:-webkit-autofill,
body.theme-escuro input:-webkit-autofill:hover,
body.theme-escuro input:-webkit-autofill:focus,
body.theme-escuro textarea:-webkit-autofill,
body.theme-escuro select:-webkit-autofill {
    -webkit-text-fill-color: #f8fafc !important;
    -webkit-box-shadow: 0 0 0 1000px #0f172a inset !important;
    box-shadow: 0 0 0 1000px #0f172a inset !important;
}

body.theme-escuro .table-modern,
body.theme-escuro .table,
body.theme-escuro table {
    background: #111827 !important;
    color: #f8fafc !important;
}

body.theme-escuro .table-modern thead th,
body.theme-escuro .table thead th,
body.theme-escuro table thead th {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

body.theme-escuro .table-modern tbody td,
body.theme-escuro .table tbody td,
body.theme-escuro table tbody td {
    color: #e2e8f0 !important;
    border-color: #1f2937 !important;
}

/* O tema também pode ser aplicado primeiro no <html> pelo JavaScript
   (antes de o <body> existir). Estas regras garantem contraste mesmo quando
   apenas html.theme-escuro estiver presente durante a renderização inicial. */
html.theme-escuro {
    --primary-light: #1e3a8a;
    --secondary: #94a3b8;
    --dark: #e2e8f0;
    --gray-50: #0f172a;
    --gray-100: #111827;
    --gray-200: #1f2937;
    --gray-300: #334155;
    --gray-400: #94a3b8;
    --gray-500: #cbd5e1;
    --gray-600: #d1d5db;
    --gray-700: #e2e8f0;
    --gray-800: #f8fafc;
    --gray-900: #020617;
    --white: #111827;
}

html.theme-escuro body,
html.theme-escuro body .main-content,
html.theme-escuro body .content-wrapper,
html.theme-escuro body .wrapper,
html.theme-escuro body .wrapper-content,
html.theme-escuro body .gray-bg {
    background: #0f172a !important;
    color: #f8fafc !important;
}

html.theme-escuro body .topbar,
html.theme-escuro body .card,
html.theme-escuro body .card-body,
html.theme-escuro body .card-header,
html.theme-escuro body .card-modern,
html.theme-escuro body .stat-card,
html.theme-escuro body .ibox,
html.theme-escuro body .ibox-title,
html.theme-escuro body .ibox-content,
html.theme-escuro body .panel,
html.theme-escuro body .panel-heading,
html.theme-escuro body .panel-body,
html.theme-escuro body .modal-content,
html.theme-escuro body .dropdown-menu,
html.theme-escuro body .bg-white,
html.theme-escuro body [class*="bg-light"] {
    background: #111827 !important;
    color: #f8fafc !important;
    border-color: #1f2937 !important;
}

html.theme-escuro body h1,
html.theme-escuro body h2,
html.theme-escuro body h3,
html.theme-escuro body h4,
html.theme-escuro body h5,
html.theme-escuro body h6,
html.theme-escuro body p,
html.theme-escuro body span,
html.theme-escuro body label,
html.theme-escuro body small,
html.theme-escuro body .form-text,
html.theme-escuro body .help-block,
html.theme-escuro body .text-muted,
html.theme-escuro body .control-label,
html.theme-escuro body .stat-info,
html.theme-escuro body .card-title,
html.theme-escuro body .card-text {
    color: #f8fafc !important;
}

html.theme-escuro body .form-control,
html.theme-escuro body .custom-select,
html.theme-escuro body input,
html.theme-escuro body select,
html.theme-escuro body textarea {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
    caret-color: #f8fafc !important;
}

html.theme-escuro body .form-control::placeholder,
html.theme-escuro body input::placeholder,
html.theme-escuro body textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

html.theme-escuro body .form-control:focus,
html.theme-escuro body input:focus,
html.theme-escuro body select:focus,
html.theme-escuro body textarea:focus {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 0.2rem rgba(96, 165, 250, 0.28) !important;
}

html.theme-escuro body table,
html.theme-escuro body .table,
html.theme-escuro body .table-modern {
    background: #111827 !important;
    color: #f8fafc !important;
}

html.theme-escuro body table thead,
html.theme-escuro body table thead th,
html.theme-escuro body .table thead th,
html.theme-escuro body .table-modern thead th {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

html.theme-escuro body table td,
html.theme-escuro body table th,
html.theme-escuro body .table td,
html.theme-escuro body .table th,
html.theme-escuro body .table-modern td,
html.theme-escuro body .table-modern th {
    color: #e2e8f0 !important;
    border-color: #1f2937 !important;
}

/* ===== LEGACY LIST MODERNIZATION ===== */
.legacy-list-card {
    margin-bottom: 1.5rem;
}

.list-toolbar-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.table-actions-modern {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    white-space: nowrap;
}

.btn-icon-modern {
    width: 2rem;
    height: 2rem;
    justify-content: center;
    padding: 0;
}

/* ===================================================
   LAYOUT HORIZONTAL 2026
   Mantém o markup e as permissões do menu legado, alterando somente sua
   apresentação: barra superior no desktop e drawer no mobile.
   =================================================== */
:root {
    --primary: #6438f5;
    --primary-dark: #5124df;
    --primary-light: #eee9ff;
    --bg-page: #f7f9fc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e3e8f1;
    --text-primary: #111827;
    --text-secondary: #64748b;
    --header-height: 72px;
    --nav-height: 58px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 2px 8px rgba(15, 23, 42, .06);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, .09);
}

html.theme-escuro,
body.theme-escuro {
    --primary: #7547ff;
    --primary-dark: #6033ed;
    --primary-light: rgba(109, 53, 255, .18);
    --bg-page: #08111f;
    --bg-surface: #0d1829;
    --bg-card: #111d30;
    --border-color: #22314a;
    --text-primary: #f5f7fb;
    --text-secondary: #9aabc3;
    --gray-50: #08111f;
    --gray-100: #0d1829;
    --gray-200: #22314a;
    --gray-300: #34445e;
    --gray-400: #94a3b8;
    --gray-500: #9aabc3;
    --gray-600: #c3cede;
    --gray-700: #dbe3ef;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
    --white: #111d30;
    --shadow: 0 2px 10px rgba(0, 0, 0, .2);
    --shadow-md: 0 16px 36px rgba(0, 0, 0, .28);
}

body.sigma-app {
    background: var(--bg-page);
    color: var(--text-primary);
    min-width: 0;
}

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1040;
    min-height: var(--header-height);
    height: var(--header-height);
    padding: 0 clamp(16px, 2.1vw, 32px) 0 clamp(210px, 18vw, 292px);
    background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
    backdrop-filter: blur(14px);
}

.sidebar-modern.top-navigation {
    position: fixed;
    inset: var(--header-height) 0 auto 0;
    width: 100%;
    height: var(--nav-height);
    min-height: var(--nav-height);
    padding: 8px clamp(16px, 2.1vw, 32px);
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: visible;
    background: var(--bg-surface);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 3px 12px rgba(15, 23, 42, .04);
    z-index: 1035;
}

.sidebar-modern .sidebar-header {
    position: fixed;
    top: 0;
    left: clamp(16px, 2.1vw, 32px);
    z-index: 1050;
    width: auto;
    height: var(--header-height);
    padding: 0;
    display: flex;
    align-items: center;
    border: 0;
}

.brand-link,
.brand-link:hover {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    text-decoration: none;
}

.brand-link img { width: 42px; height: 42px; object-fit: contain; border: 0; margin: 0; }
.brand-link span { display: flex; flex-direction: column; line-height: 1.12; }
.brand-link strong { font-size: 1.08rem; letter-spacing: -.025em; }
.brand-link small { color: var(--text-secondary); font-size: .66rem; margin-top: 3px; }

.sidebar-modern .nav-section {
    position: relative;
    margin: 0;
    padding: 9px 13px;
    border-radius: 9px;
    color: var(--text-secondary);
    font-size: .73rem;
    font-weight: 650;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    white-space: nowrap;
}
.sidebar-modern .nav-section::after { content: '\f107'; font-family: 'Font Awesome 5 Free'; font-weight: 900; margin-left: 7px; font-size: .66rem; }
.sidebar-modern .nav-section:hover,
.sidebar-modern .nav-section.menu-open { background: var(--primary-light); color: var(--primary); }

.sidebar-modern .nav-menu {
    display: none;
    position: absolute;
    top: calc(100% - 5px);
    min-width: 238px;
    max-height: min(68vh, 560px);
    overflow-y: auto;
    margin: 0;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 1100;
}
.sidebar-modern .nav-menu.menu-open { display: block; }
.sidebar-modern .nav-menu li { margin: 2px 0; }
.sidebar-modern .nav-menu li a {
    min-height: 39px;
    padding: 9px 11px;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: .78rem;
}
.sidebar-modern .nav-menu li a:hover { color: var(--text-primary); background: var(--gray-100); transform: none; }
.sidebar-modern .nav-menu li a.active { color: #fff; background: var(--primary); box-shadow: 0 5px 14px rgba(100, 56, 245, .24); }
.sidebar-modern .nav-menu li a i { width: 22px; color: inherit; }

/* O primeiro agrupamento contém o dashboard e funciona como item principal. */
.sidebar-modern .sidebar-header + .nav-section { display: none; }
.sidebar-modern .sidebar-header + .nav-section + .nav-menu {
    position: static;
    display: flex;
    min-width: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
}
.sidebar-modern .sidebar-header + .nav-section + .nav-menu li a { padding: 9px 14px; }

.main-content { margin-left: 0; width: 100%; padding-top: calc(var(--header-height) + var(--nav-height)); background: var(--bg-page); }
.content-wrapper { padding: clamp(18px, 2vw, 32px); min-height: calc(100vh - var(--header-height) - var(--nav-height)); }

.topbar-left { min-width: 0; }
.topbar-left h5 { margin: 0; color: var(--text-primary); font-size: 1.02rem; font-weight: 700; }
.page-heading-global { display: flex; flex-direction: column; line-height: 1.2; }
.page-eyebrow { color: var(--text-secondary); font-size: .66rem; font-weight: 600; }
.btn-toggle-sidebar { display: none; color: var(--text-primary); }
.topbar-right { gap: 12px; }
.theme-switcher { background: var(--bg-page); border: 1px solid var(--border-color); border-radius: 22px; padding: 4px 8px 4px 11px; }
.theme-switcher .form-control { width: 82px; color: var(--text-primary); background: transparent; border: 0; box-shadow: none; }
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border-color); object-fit: cover; background: var(--bg-page); }
.user-info { color: var(--text-primary); gap: 9px; }
.user-copy { flex-direction: column; line-height: 1.2; }
.user-copy strong { font-size: .76rem; font-weight: 650; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: var(--text-secondary); font-size: .64rem; }

.card-modern, .stat-card, .ibox, .panel, .modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-modern, .stat-card { transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.card-modern:hover, .stat-card:hover { border-color: color-mix(in srgb, var(--primary) 32%, var(--border-color)); box-shadow: var(--shadow-md); }
.card-header-modern, .ibox-title, .panel-heading { background: transparent; border-color: var(--border-color); }
.table-responsive { border-radius: 10px; }
.table-modern, .table { color: var(--text-primary); }
.table-modern thead th, .table thead th { color: var(--text-secondary); background: color-mix(in srgb, var(--bg-page) 72%, var(--bg-card)); border-color: var(--border-color); }
.table-modern td, .table td { border-color: var(--border-color); }
.form-control, .custom-select, input, select, textarea { border-radius: 9px; border-color: var(--border-color); background: var(--bg-surface); color: var(--text-primary); }
.form-control:focus, .custom-select:focus, input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); outline: 0; }
a:focus-visible, button:focus-visible, .nav-section:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.modal { z-index: 1200; }
.modal-backdrop { z-index: 1190; }
.dropdown-menu, .tooltip { z-index: 1250; }

@media (max-width: 1180px) {
    .sidebar-modern.top-navigation { gap: 2px; }
    .sidebar-modern .nav-section { padding-inline: 9px; font-size: .69rem; }
    .sidebar-modern .sidebar-header + .nav-section + .nav-menu li a { padding-inline: 11px; }
    .user-copy { display: none !important; }
}

@media (max-width: 900px) {
    :root { --nav-height: 0px; }
    .topbar { padding: 0 16px; }
    .topbar-left { gap: 10px; }
    .btn-toggle-sidebar { display: inline-flex; }
    .page-eyebrow { display: none; }
    .sidebar-modern.top-navigation {
        inset: 0 auto 0 0;
        width: min(88vw, 330px);
        height: 100vh;
        max-height: none;
        padding: 84px 14px 22px;
        display: block;
        overflow-y: auto;
        transform: translateX(-105%);
        box-shadow: var(--shadow-md);
    }
    .sidebar-modern.top-navigation.active { transform: translateX(0); }
    .sidebar-modern .sidebar-header { position: absolute; left: 18px; height: 72px; }
    .sidebar-modern .nav-section,
    .sidebar-modern .sidebar-header + .nav-section { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; padding: 10px 12px; }
    .sidebar-modern .sidebar-header + .nav-section::after { display: none; }
    .sidebar-modern .nav-menu,
    .sidebar-modern .sidebar-header + .nav-section + .nav-menu {
        position: static;
        display: none;
        min-width: 0;
        max-height: none;
        padding: 5px 0 7px 8px;
        overflow: visible;
        border: 0;
        box-shadow: none;
        background: transparent;
    }
    .sidebar-modern .nav-menu.menu-open,
    .sidebar-modern .sidebar-header + .nav-section + .nav-menu { display: block; }
    .sidebar-modern .nav-menu li a { font-size: .82rem; }
    .main-content { padding-top: var(--header-height); }
    .content-wrapper { padding: 20px 16px; }
    .sidebar-overlay { z-index: 1038; background: rgba(3, 8, 20, .64); backdrop-filter: blur(2px); }
}

@media (max-width: 575px) {
    .topbar { height: 64px; min-height: 64px; padding-inline: 12px; }
    .topbar-left h5 { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
    .theme-switcher { padding-left: 8px; }
    .theme-switcher .form-control { width: 68px; font-size: .7rem; padding-inline: 4px; }
    .topbar-avatar { display: none; }
    .user-info .btn-outline-modern { width: 36px; height: 36px; padding: 0; justify-content: center; }
    .user-info .btn-outline-modern { font-size: 0; }
    .user-info .btn-outline-modern i { font-size: .8rem; }
    .content-wrapper { padding: 16px 12px; }
    .row { margin-left: -6px; margin-right: -6px; }
    [class*="col-"] { padding-left: 6px; padding-right: 6px; }
    .card-modern, .stat-card, .ibox, .panel { border-radius: 11px; }
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
