:root {
    /* 🎨 BRAND COLORS (Pro Max Palette) */
    --primary: #6366f1;
    /* Indigo 500 */
    --primary-dark: #4f46e5;
    /* Indigo 600 */
    --primary-light: #e0e7ff;
    /* Indigo 100 */
    --primary-rgb: 99, 102, 241;

    --secondary: #ec4899;
    /* Pink 500 */
    --secondary-dark: #db2777;
    --secondary-light: #fce7f3;

    --success: #10b981;
    /* Emerald 500 */
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    /* Amber 500 */
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    /* Red 500 */
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    /* Blue 500 */
    --info-bg: #dbeafe;

    /* 🌑 NEUTRALS & BACKGROUNDS */
    --bg-body: #f3f4f6;
    /* Gray 100 */
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #f9fafb;
    /* Gray 50 */

    --text-primary: #111827;
    /* Gray 900 */
    --text-secondary: #4b5563;
    /* Gray 600 */
    --text-muted: #9ca3af;
    /* Gray 400 */

    --border: #e5e7eb;
    /* Gray 200 */

    /* ✨ EFFECTS */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 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: 12px;
    --radius-sm: 8px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* 📏 DIMENSIONS */
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    /* Slate 900 */
    --bg-card: #1e293b;
    /* Slate 800 */
    --bg-sidebar: #1e293b;
    --bg-input: #334155;
    /* Slate 700 */

    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #cbd5e1;
    /* Slate 300 */
    --text-muted: #64748b;
    /* Slate 500 */

    --border: #334155;

    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

    --primary-light: rgba(99, 102, 241, 0.15);
    --bg-body: #080c14;
    /* Black Deep Slate */
    --bg-card: #151c2c;
    --bg-sidebar: #151c2c;
    --bg-input: #1e293b;
    --border: rgba(255, 255, 255, 0.08);
}

/* ✨ PRO MAX ANIMATIONS */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseSubtle {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes spinSubtle {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}

/* ============================
   LAYOUT SYSTEM
   ============================ */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Legacy Sidebar V2 styles removed to avoid conflict with components.css */

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    /* Glassmorphism */
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 40;
}

[data-theme="dark"] .topbar {
    background: rgba(30, 41, 59, 0.8);
}

@media (max-width: 768px) {
    .topbar {
        border-bottom: none;
        background: var(--bg-body);
        /* Seamless with body */
        box-shadow: none;
        /* Remove shadow */
    }

    .page-title {
        font-size: 1.1rem;
    }
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content-wrapper {
    padding: 24px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================
   MOBILE OPTIMIZATIONS
   ============================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {

    /* Tablet & Mobile */
    .sidebar-v2 {
        transform: translateX(-100%);
        z-index: 105;
    }

    .sidebar-v2.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
        z-index: 104;
    }

    #sidebar-toggle {
        display: block !important;
    }
}

#sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
}

/* ============================
   COMPONENTS
   ============================ */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-light);
}

.card h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    /* Fixed alignment issue */
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
    height: 44px;
    /* Touch friendly */
}

textarea {
    height: auto;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--bg-card);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    font-size: 0.95rem;
    height: 44px;
    /* Touch friendly */
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    filter: brightness(90%);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    filter: brightness(90%);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-input);
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    /* min-width: 600px;  Removed global min-width, handled by specific classes or media queries if needed */
}

@media (min-width: 769px) {
    .table-responsive table {
        min-width: 600px;
        /* Only force width on desktop scrollable tables */
    }
}

th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-input);
}

.orders-table-premium tr:hover td {
    background: transparent;
}

/* Notifications & Badges */
.badge {
    padding: 4px 10px;
    border-radius: 9999px;
    /* Pill shape */
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* Theme Toggle */
.theme-switch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.theme-switch:hover {
    background: var(--bg-input);
    color: var(--primary);
}

/* ============================
   MODALS
   ============================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--bg-card);
    margin: auto;
    padding: 24px;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalSlideIn 0.3s ease-out forwards;
    max-height: 90vh;
    overflow-y: auto;
    flex-shrink: 0;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Modal Headers */
.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* Modais Dark Mode */
[data-theme="dark"] .modal-content {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="dark"] .modal-content label {
    color: var(--text-primary);
}

[data-theme="dark"] .modal-content input,
[data-theme="dark"] .modal-content select,
[data-theme="dark"] .modal-content textarea {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="dark"] .modal-content .btn-secondary {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border);
}

/* ============================
   MOBILE OPTIMIZATIONS & UTILITIES
   ============================ */

/* Utility Classes */
.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

@media (min-width: 769px) {
    .d-md-none {
        display: none !important;
    }

    .d-md-block {
        display: block !important;
    }

    .d-md-table {
        display: table !important;
    }

    .d-md-flex {
        display: flex !important;
    }
}

@media (max-width: 768px) {

    /* 🎨 UNWRAP MAIN CARD ON MOBILE (PRO MAX UI)
       Removes the "Card inside a Card" effect. 
       The main content becomes the viewport background. 
    */
    .card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin-bottom: 0 !important;
    }

    /* Clean up the Header on Mobile */
    .card h2 {
        border-bottom: none !important;
        /* Remove the "Gray Bar" */
        padding-bottom: 0 !important;
        margin-bottom: 16px !important;
        font-size: 1.5rem;
        color: var(--text-primary);
        justify-content: center;
        /* Center title on mobile */
    }

    .page-header {
        margin-bottom: 20px;
        justify-content: center;
    }

    /* Hide Desktop Elements */
    .page-header .btn:not(.fab-add) {
        display: none;
    }

    /* ✨ PRO MAX CARD DESIGN */
    .mobile-cards-view {
        display: flex;
        flex-direction: column;
        gap: 20px;
        padding-bottom: 80px;
        /* Space for FAB */
    }

    .mobile-card {
        background: var(--bg-card);
        border: 1px solid rgba(0, 0, 0, 0.05);
        /* Very subtle border */
        border-radius: 20px;
        /* Modern "Squircle" feel */
        box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
        /* Soft, diffused shadow */
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
        /* transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); */
        /* Removed scale effect */
    }

    /* Removed :active scale to prevent scroll glitching */

    .mobile-card-header {
        padding: 18px 20px;
        background: transparent;
        border-bottom: none !important;
        /* Force remove internal border if user dislikes it */
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-card-title {
        font-weight: 700;
        font-size: 1.05rem;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        /* Take available space */
        min-width: 0;
        /* Enable truncation in flexbox */
        padding-right: 12px;
        /* Space before the badge */
        letter-spacing: -0.02em;
    }

    .mobile-card-body {
        padding: 20px;
        background: var(--bg-card);
        gap: 16px;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 12px;
        border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
    }

    .mobile-card-row:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .mobile-card-label {
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-muted);
        /* Slate-400 */
        font-weight: 600;
    }

    .mobile-card-value {
        font-weight: 500;
        color: var(--text-secondary);
        font-size: 0.95rem;
    }

    .mobile-card-value.truncate {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60%;
        text-align: right;
        display: block;
    }

    /* Action Bar - Seamless White */
    .mobile-card-actions {
        padding: 16px 20px;
        background: var(--bg-card);
        /* White background to merge with body */
        border-top: none;
        display: flex;
        gap: 12px;
        align-items: center;
    }

}

/* ============================
   BOTTOM NAVIGATION (APP FEEL)
   ============================ */
.bottom-nav {
    display: none;
    /* Hidden on Desktop */
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        color: var(--text-muted);
        /* Slate-400 */
        text-decoration: none;
        gap: 4px;
        transition: color 0.2s ease;
    }

    .nav-item i {
        font-size: 1.5rem;
        transition: transform 0.2s ease;
    }

    .nav-item span {
        font-size: 0.75rem;
        font-weight: 500;
        letter-spacing: -0.01em;
    }

    .nav-item.active {
        color: var(--primary);
    }

    .nav-item.active i {
        transform: translateY(-2px);
    }

    /* Adjust Main Content to not be covered by Bottom Nav */
    body {
        padding-bottom: 70px;
    }
}

@media (max-width: 768px) {
    .mobile-card-actions .btn {
        flex: 1;
        border-radius: 12px;
        height: 42px;
        font-size: 0.85rem;
        font-weight: 600;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        border: none;
    }

    .btn-whatsapp {
        background: #dcfce7;
        /* Green-100 */
        color: #166534;
        /* Green-800 */
    }

    .btn-outline {
        background: var(--bg-card);
        border: 1px solid var(--border);
        color: var(--text-secondary);
    }

    .btn-danger {
        background: #fee2e2;
        /* Red-100 */
        color: #991b1b;
        /* Red-800 */
        box-shadow: none;
    }
}

/* Desktop Only Resets */
@media (min-width: 769px) {

    .mobile-cards-view,
    .fab-add,
    .bottom-nav {
        display: none !important;
    }
}

/* Responsive Grid Helper */
@media (min-width: 769px) {
    .form-grid-3 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .form-grid-3 {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    /* Stacked Table for Modal Items */
    #tbl-items thead {
        display: none;
    }

    #tbl-items tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-body);
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px;
        gap: 8px;
    }

    #tbl-items td {
        display: flex;
        flex-direction: column;
        border: none !important;
        padding: 5px 0 !important;
        align-items: center;
        /* Center children (labels and inputs) */
    }

    #tbl-items td::before {
        align-self: flex-start;
        /* Keep labels left aligned if desired, or center? Let's keep labels left inside the centered container context? 
                                   Actually, if td aligns center, label is center. 
                                   Let's align-items: stretch and use margin auto on inputs. */
        margin-left: 2.5%;
        /* Match input margin */
    }

    /* Inputs in Modal List */
    #tbl-items input,
    #tbl-items select,
    .select2-container {
        width: 95% !important;
        /* Safe width to prevent leak */
        margin: 5px auto !important;
        /* Center horizontally */
        max-width: 95% !important;
        box-sizing: border-box !important;
    }

    #tbl-items td {
        align-items: stretch;
        /* Reset to stretch so we can control via margin */
    }

    #tbl-items td:nth-child(1)::before {
        content: "Produto";
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-secondary);
    }

    #tbl-items td:nth-child(2)::before {
        content: "Tipo";
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-secondary);
    }

    #tbl-items td:nth-child(3)::before {
        content: "Qtd / Peso";
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-secondary);
    }

    #tbl-items td:nth-child(4)::before {
        content: "Preço";
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-secondary);
    }

    #tbl-items input,
    #tbl-items select {
        width: 100% !important;
        height: 42px;
    }

    #tbl-items td:last-child {
        align-items: flex-end;
    }

    /* Fix Select2 Width & Z-Index on Mobile */
    /* Fix Select2 Width & Z-Index on Mobile */
    .select2-container {
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        /* Kill calculated min-width */
        z-index: 9999 !important;
        box-sizing: border-box !important;
        display: block !important;
    }

    .select2-selection {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        display: block !important;
    }

    .select2-dropdown {
        z-index: 99999 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    .select2-search__field {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }


}

/* ==========================================================================
   ROMANEIO MODAL: PREMIUM UI v3.3.0
   ========================================================================== */


#modal-romaneio thead {
    display: none !important;
}

#romaneio-orders-list {
    display: block !important;
    width: 100% !important;
    table-layout: fixed !important;
    border: none !important;
    background: transparent !important;
}

/* 1. Group (Card) Styling */
.romaneio-group {
    display: block !important;
    width: 100% !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    margin-bottom: 32px !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02) !important;
    overflow: hidden !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.romaneio-group:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02) !important;
}

.romaneio-group-header,
.romaneio-group-header td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
}

/* 2. Card Header Structure */
.romaneio-header-content {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 18px 24px !important;
    background: linear-gradient(135deg, #f1f5f9 0%, #ffffff 100%) !important;
    border-bottom: 2px solid #eef2f6 !important;
}

/* Toggle shown universally now */
.btn-toggle-group {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.romaneio-header-left {
    display: flex !important;
    gap: 16px;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.romaneio-header-info {
    flex: 1;
    min-width: 0;
}

.romaneio-header-top-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center;
    margin-bottom: 6px;
}

.romaneio-drag-handle {
    cursor: move;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 4px;
}

/* 3. Badges & Labels */
.delivery-tag {
    font-size: 0.7rem !important;
    text-transform: uppercase !important;
    font-weight: 800 !important;
    color: var(--text-secondary) !important;
    background: #e2e8f0 !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    letter-spacing: 0.05em !important;
}

.romaneio-group-total-badge {
    font-size: 0.95rem !important;
    font-weight: 800 !important;
    color: #15803d !important;
    background: #dcfce7 !important;
    padding: 4px 12px !important;
    border-radius: 20px !important;
    white-space: nowrap;
}

.romaneio-client-name {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    line-height: 1.3 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* 4. Desktop Labels Row */
.romaneio-desktop-labels {
    display: table !important;
    /* Force to behave like a table to fill 100% */
    width: 100% !important;
    table-layout: fixed !important;
    background: var(--bg-card) !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

.romaneio-desktop-labels th,
.romaneio-group tr.item-row td {
    border: none !important;
    white-space: nowrap !important;
}

.romaneio-desktop-labels th:nth-child(1),
.romaneio-group tr.item-row td:nth-child(1) {
    width: 12% !important;
}

/* Pedido */
.romaneio-desktop-labels th:nth-child(2),
.romaneio-group tr.item-row td:nth-child(2) {
    width: 28% !important;
}

/* Produto */
.romaneio-desktop-labels th:nth-child(3),
.romaneio-group tr.item-row td:nth-child(3) {
    width: 15% !important;
}

/* Qtd */
.romaneio-desktop-labels th:nth-child(4),
.romaneio-group tr.item-row td:nth-child(4) {
    width: 15% !important;
}

/* Valor */
.romaneio-desktop-labels th:nth-child(5),
.romaneio-group tr.item-row td:nth-child(5) {
    width: 15% !important;
}

/* Peso */
.romaneio-desktop-labels th:nth-child(6),
.romaneio-group tr.item-row td:nth-child(6) {
    width: 15% !important;
}

/* Total */

.romaneio-desktop-labels th {
    padding: 12px 15px !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-align: left !important;
    background: #fdfdfd !important;
}

/* 5. Item Rows */
.romaneio-group tr.item-row {
    display: table !important;
    /* Force to behave like a table to fill 100% */
    width: 100% !important;
    table-layout: fixed !important;
}

.romaneio-group tr.item-row td {
    padding: 16px !important;
    vertical-align: middle !important;
    border-bottom: 1px solid #f1f5f9 !important;
    background: var(--bg-card) !important;
}

.col-oid {
    font-weight: 700 !important;
    color: var(--text-secondary) !important;
}

.item-product-name {
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    font-size: 0.95rem !important;
    white-space: normal !important;
    /* Allow product name to wrap */
}

.item-est-info {
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
}

.romaneio-input {
    height: 38px !important;
    font-size: 0.9rem !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    background: var(--bg-body) !important;
    transition: all 0.2s ease !important;
    padding: 0 10px !important;
}

.romaneio-input:focus {
    border-color: #6366f1 !important;
    background: var(--bg-card) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
    outline: none;
}

.input-highlight {
    border-color: #10b981 !important;
    background: #f0fdf4 !important;
    font-weight: 700 !important;
    color: #166534 !important;
}

.col-total {
    font-weight: 800 !important;
    color: #15803d !important;
    text-align: right !important;
}

@media (max-width: 768px) {
    .romaneio-desktop-labels {
        display: none !important;
    }

    .romaneio-group tr.item-row {
        display: block !important;
        padding: 12px !important;
    }

    .romaneio-group tr.item-row td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding: 8px 0 !important;
        border: none !important;
    }

    .romaneio-group tr.item-row td::before {
        content: attr(data-label);
        font-weight: 700 !important;
        font-size: 0.7rem !important;
        color: var(--text-muted) !important;
        text-transform: uppercase !important;
    }

    /* Product and ID special stacking */
    .romaneio-group tr.item-row td[data-label="Produto"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        border-bottom: 1px solid #f1f5f9 !important;
        margin-bottom: 8px !important;
        padding-bottom: 12px !important;
    }

    .romaneio-group tr.item-row td[data-label="Produto"]::before {
        display: none !important;
    }

    .romaneio-group tr.item-row td[data-label="Total faturado"] {
        background: #f0fdf4 !important;
        padding: 12px !important;
        border-radius: 8px !important;
        margin-top: 10px !important;
    }

    .romaneio-input {
        width: 130px !important;
    }

    .btn-toggle-group {
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 4px 10px;
    }
}

.romaneio-group[data-open="false"] tr.item-row,
.romaneio-group[data-open="false"] td .item-row,
.romaneio-group[data-open="false"] .romaneio-desktop-labels {
    display: none !important;
    opacity: 0;
}

.pulse-animation {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

#btnGerarRomaneio {
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

/* --- DASHBOARD PREMIUM v3.2.3 --- */

/* Unified Table Design */
.orders-table-premium {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
}

.orders-table-premium thead th {
    background: var(--bg-body);
    padding: 16px 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid #f1f5f9;
    text-align: left;
}

.orders-table-premium tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #f1f5f9;
}

.orders-table-premium tbody tr:nth-child(even) {
    background-color: var(--bg-body);
}

.orders-table-premium tbody tr:hover {
    cursor: pointer;
}

.orders-table-premium tbody tr:hover td {
    background: rgba(99, 102, 241, 0.08) !important;
    transition: background 0.2s ease;
}

.orders-table-premium tbody tr:hover td:first-child {
    box-shadow: inset 4px 0 0 0 #6366f1;
}

.orders-table-premium .action-btn-hover {
    transition: all 0.2s ease;
}

.orders-table-premium .action-btn-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.orders-table-premium td {
    padding: 16px 20px;
    vertical-align: middle;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.orders-table-premium tr:last-child td {
    border-bottom: none;
}

/* Dashboard Tab Hover Effects */
.orders-desktop-dash .dash-tab:hover {
    background: #f1f5f9 !important;
    color: var(--text-primary) !important;
}

/* Custom Scrollbar for responsiveness */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================
   ALERTS & NOTIFICATIONS
   ============================ */
.alert {
    padding: 16px 20px;
    margin-bottom: 24px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.alert-success {
    color: #166534;
    /* Green 800 */
    background-color: #dcfce7;
    /* Green 100 */
    border-color: #bbf7d0;
    /* Green 200 */
}

.alert-danger {
    color: #991b1b;
    /* Red 800 */
    background-color: #fee2e2;
    /* Red 100 */
    border-color: #fecaca;
    /* Red 200 */
}

.alert-warning {
    color: #92400e;
    /* Amber 800 */
    background-color: #fef3c7;
    /* Amber 100 */
    border-color: #fde68a;
    /* Amber 200 */
}

.alert-info {
    color: #1e40af;
    /* Blue 800 */
    background-color: #dbeafe;
    /* Blue 100 */
    border-color: #bfdbfe;
    /* Blue 200 */
}

.alert i {
    font-size: 1.25rem;
}

/* ============================
   WIZARD UI (MOBILE PRO MAX)
   ============================ */
.wizard-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
    padding: 0 10px;
}

.wizard-steps::before {
    content: "";
    position: absolute;
    top: 15px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.wizard-step {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.wizard-step.active .step-number {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.wizard-step.completed .step-number {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

.step-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wizard-step.active .step-label {
    color: var(--primary);
}

.wizard-content {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

.wizard-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.wizard-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wizard-footer {
    display: flex;
    justify-content: space-between;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border);
    gap: 12px;
}

/* Wizard Item Cards (Mobile) */
.wizard-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.wizard-item-card .remove-item {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--danger);
    background: var(--danger-bg);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.wizard-item-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .modal-content.wizard-modal {
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        display: flex;
        flex-direction: column;
        padding: 40px 15px 20px 15px !important;
    }

    .wizard-footer {
        padding-bottom: env(safe-area-inset-bottom);
        margin-bottom: 10px;
    }

    .wizard-steps {
        margin-bottom: 20px;
    }

    .step-label {
        font-size: 0.65rem;
    }

    #sticky-footer-actions {
        padding: 10px !important;
        background: var(--bg-body) !important;
        border-top: 1px solid var(--border) !important;
        height: 80px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #btnGerarRomaneioMobile {
        width: 100% !important;
        height: 60px !important;
        font-size: 1.1rem !important;
        font-weight: 800 !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
        margin: 0 !important;
    }
}

/* Card Step 2 Romaneio Enhancements */
.wizard-item-card {
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary) !important;
}

.wizard-item-card.minimized .wizard-order-item {
    display: none !important;
}

.wizard-item-card.minimized {
    padding-bottom: 12px;
}

.card-toggle-btn {
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.wizard-item-card.minimized .card-toggle-btn {
    transform: rotate(-180deg);
}

.delivery-badge {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    border: 1px solid #dbeafe;
}

.card-order-total {
    background: #f0fdf4 !important;
    color: #166534 !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    font-weight: 800 !important;
    font-size: 0.95rem !important;
    margin-top: 15px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-left: 3px solid #10b981 !important;
}

/* Enforce uppercase on specific inputs */
#create-name,
#edit-name,
#frig-name,
#create-product-name {
    text-transform: uppercase;
}

/* Fix Mobile Wizard Padding */
@media (max-width: 768px) {
    .modal-content.wizard-modal {
        padding-bottom: 80px !important;
    }

    .wizard-footer {
        margin-bottom: 20px !important;
    }
}

/* ============================
   DARK MODE LEGACY OVERRIDES - REMOVIDO PARA USO DE VARIÁVEIS NATIVAS
   ============================ */

/* 🔘 GLOBAL TOGGLE SWITCH (Elite Vendas Standard) */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-switch .slider {
    width: 44px;
    height: 22px;
    background: #cbd5e1;
    border-radius: 22px;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.toggle-switch .slider:before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--bg-card);
    border-radius: 50%;
    top: 3px;
    left: 4px;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked+.slider {
    background: var(--primary);
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(22px);
}

.toggle-switch .label-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================
   ALERTS & NOTIFICATIONS
   ============================ */
.notification-dropdown {
    display: none !important;
    animation: slideUpFade 0.3s ease;
}

.notification-dropdown.active {
    display: block !important;
}

.notif-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.notif-item:hover {
    background: var(--bg-input);
}

.notif-item.unread {
    background: rgba(var(--primary-rgb), 0.05);
}

.notif-item.unread::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-left: 10px;
}