:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0891b2;
    --bg: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; overflow-x: hidden; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* ========== LOGIN ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 16px;
}
.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}
.login-card .logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-card .logo i { font-size: 48px; color: var(--primary); }
.login-card .logo h1 { font-size: 24px; font-weight: 700; margin-top: 8px; }
.login-card .logo p { color: var(--text-muted); font-size: 14px; }

/* ========== LAYOUT ========== */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
.sidebar-header {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-height: 64px;
    position: relative;
}
.sidebar-logo-icon {
    font-size: 26px;
    color: var(--sidebar-active);
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}
.sidebar-brand {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.sidebar-brand h2 { font-size: 17px; font-weight: 700; color: #fff; }
.sidebar-brand span { font-size: 11px; color: var(--sidebar-text); }
.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-section {
    padding: 12px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #475569;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.nav-item.active {
    background: rgba(59,130,246,0.12);
    color: #fff;
    border-left-color: var(--sidebar-active);
}
.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-footer .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 14px;
    flex-shrink: 0;
}
.sidebar-footer .user-info {
    flex: 1; min-width: 0;
    overflow: hidden;
    transition: opacity 0.2s;
}
.sidebar-footer .user-info strong {
    display: block; color: #fff; font-size: 13px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-footer .user-info small { color: var(--sidebar-text); font-size: 11px; }
.btn-logout {
    background: none; border: none;
    color: var(--sidebar-text);
    cursor: pointer; padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-logout:hover { background: rgba(220,38,38,0.15); color: var(--danger); }

/* ── Sidebar Colapsado (desktop) ── */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .sidebar-brand { opacity: 0; width: 0; }
.sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }
.sidebar.collapsed .nav-section span { opacity: 0; }
.sidebar.collapsed .nav-item span { opacity: 0; width: 0; }
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    border-left-width: 0;
}
.sidebar.collapsed .nav-item i { width: auto; font-size: 20px; }
.sidebar.collapsed .sidebar-footer .user-info { opacity: 0; width: 0; }
.sidebar.collapsed .sidebar-footer .btn-logout { opacity: 0; width: 0; padding: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 14px 8px; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 8px; gap: 0; }
.sidebar.collapsed .sidebar-collapse-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* Tooltip no sidebar colapsado */
.sidebar.collapsed .nav-item:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(var(--sidebar-collapsed) - 4px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
    transition: margin-left 0.25s cubic-bezier(.4,0,.2,1);
}
.app-layout.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.topbar-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.topbar-toggle:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}
.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar .breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========== NOTIFICATIONS BELL ========== */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    flex-shrink: 0;
}
.notif-bell {
    position: relative;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notif-bell:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.notif-bell.has-notif { color: var(--warning); }
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: notifPulse 2s ease-in-out infinite;
}
@keyframes notifPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-height: 480px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
}
.notif-dropdown.open { display: block; animation: notifSlide 0.2s ease; }
@keyframes notifSlide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.notif-header strong { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.notif-header strong i { color: var(--primary); }
.notif-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px;
    border-radius: 6px;
}
.notif-close:hover { background: var(--border); color: var(--danger); }
.notif-body {
    overflow-y: auto;
    max-height: 400px;
    padding: 8px;
}
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
}
.notif-item:hover { background: var(--bg); }
.notif-item:active { background: var(--border); }
.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.notif-icon.orange { background: #fff7ed; color: #ea580c; }
.notif-icon.green { background: #f0fdf4; color: #16a34a; }
.notif-icon.blue { background: #eff6ff; color: #2563eb; }
.notif-icon.cyan { background: #ecfeff; color: #0891b2; }
.notif-icon.red { background: #fef2f2; color: #dc2626; }
.notif-icon.yellow { background: #fefce8; color: #ca8a04; }
.notif-text { flex: 1; min-width: 0; }
.notif-text strong { font-size: 13px; display: block; margin-bottom: 2px; }
.notif-text small { font-size: 11px; color: var(--text-muted); }
.notif-count {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}
.notif-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}
.notif-empty i { font-size: 32px; display: block; margin-bottom: 8px; color: var(--success); }
.notif-empty p { font-size: 13px; }

.page-content {
    padding: 24px;
    max-width: 100%;
}

/* ========== CARDS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }
.stat-card.clickable:active { transform: translateY(0); }
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #fed7aa; color: #ea580c; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.cyan { background: #cffafe; color: #0891b2; }
.stat-info h3 { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-info p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    min-width: 0;
}
.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* ========== TABLES ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; }
table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table tbody tr:hover { background: #f8fafc; }
table tbody tr:last-child td { border-bottom: none; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn i { font-size: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-sm i { font-size: 14px; }
.btn-group { display: flex; gap: 4px; flex-wrap: nowrap; }

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600;
    margin-bottom: 6px; color: var(--text);
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
    color: var(--text);
    min-width: 0;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
select.form-control { appearance: auto; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    padding: 16px;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--card-bg);
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.2s;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
    border-radius: 16px 16px 0 0;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: var(--text-muted);
    padding: 4px; border-radius: 6px; flex-shrink: 0;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: calc(100vw - 32px);
}
.toast {
    padding: 12px 16px;
    border-radius: 10px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease;
    max-width: 100%;
    word-break: break-word;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========== CHARTS ========== */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.chart-container { position: relative; height: 280px; }

/* ========== QR CODE ========== */
.qr-display { text-align: center; padding: 24px; }
.qr-display img {
    max-width: 280px;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

/* ========== FILE UPLOAD ========== */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbfc;
}
.file-upload-area:hover, .file-upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.file-upload-area i { font-size: 42px; color: var(--primary); margin-bottom: 8px; }

/* ========== EMPTY STATE ========== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 42px; margin-bottom: 12px; color: var(--border); }
.empty-state p { font-size: 14px; }

/* ========== ALERT ========== */
.alert-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 14px;
}
.alert-card.alert-danger { background: #fef2f2; border-left: 4px solid var(--danger); color: #991b1b; }
.alert-card.alert-warning { background: #fffbeb; border-left: 4px solid var(--warning); color: #92400e; }

/* ========== LOADING ========== */
.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-loading { display: flex; align-items: center; justify-content: center; padding: 80px; }
.page-loading .spinner { width: 40px; height: 40px; border-width: 3px; }

/* ========== SEARCH ========== */
.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-box i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--text-muted); font-size: 16px;
}

/* ========== NFE WORKSPACE ========== */
.nfe-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.nfe-info-box {
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
}
.nfe-info-box small { color: var(--text-muted); font-size: 11px; }
.nfe-info-box strong { display: block; font-size: 13px; margin-top: 2px; word-break: break-word; }
.nfe-chave {
    padding: 6px 12px;
    background: #f1f5f9;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 11px;
    word-break: break-all;
    font-family: monospace;
    line-height: 1.5;
}
.nfe-section {
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}
.nfe-section-destino { background: #eff6ff; border: 1px solid #bfdbfe; }
.nfe-section-forn-ok { background: #f0fdf4; border: 1px solid #bbf7d0; }
.nfe-section-forn-new { background: #fffbeb; border: 1px solid #fde68a; }
.nfe-section-itens { border: 1px solid var(--border); }
.nfe-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.nfe-section p.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.nfe-forn-status {
    margin-bottom: 10px; padding: 8px 12px;
    background: #dcfce7; border-radius: 6px;
    font-size: 13px; display: flex;
    align-items: center; gap: 8px; flex-wrap: wrap;
}
.nfe-actions {
    display: flex; gap: 10px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.nfe-item-nome-input { font-size: 13px !important; padding: 6px 8px !important; min-width: 120px; }
.nfe-item-qtd-input { width: 70px; font-size: 13px !important; padding: 6px 8px !important; }

.nfe-detail-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.nfe-detail-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.nfe-detail-box { padding: 10px; border-radius: 8px; }
.nfe-detail-box small { color: var(--text-muted); display: block; font-size: 11px; }
.nfe-detail-box strong { display: block; margin-top: 2px; }
.nfe-detail-box.bg-gray { background: #f8fafc; }
.nfe-detail-box.bg-green { background: #f0fdf4; border: 1px solid #bbf7d0; }
.nfe-detail-box.bg-blue { background: #eff6ff; border: 1px solid #bfdbfe; }
.nfe-detail-box.bg-yellow { background: #fefce8; border: 1px solid #fde68a; }

/* ========== UTILITY HELPERS ========== */
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.flex-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono { font-family: monospace; }

/* ========================================= */
/* ========== RESPONSIVE BREAKPOINTS ======= */
/* ========================================= */

/* Tablets / small desktops */
@media (max-width: 1100px) {
    .nfe-detail-grid-3 { grid-template-columns: 1fr 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
}

/* ── MOBILE ( <=768px ) ── */
@media (max-width: 768px) {
    /* Sidebar = off-canvas no mobile */
    .sidebar {
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(.4,0,.2,1);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    /* Nunca mostrar collapsed no mobile */
    .sidebar.collapsed { width: var(--sidebar-width) !important; }
    .sidebar.collapsed .sidebar-brand,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .nav-section span,
    .sidebar.collapsed .sidebar-footer .user-info,
    .sidebar.collapsed .sidebar-footer .btn-logout {
        opacity: 1 !important; width: auto !important; overflow: visible !important; padding: revert !important;
    }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 20px; border-left-width: 3px; }
    .sidebar.collapsed .nav-item i { width: 24px; font-size: 18px; }
    .sidebar.collapsed .sidebar-footer { justify-content: flex-start; padding: 14px 18px; }
    .sidebar.collapsed .sidebar-header { justify-content: flex-start; padding: 16px 18px; gap: 12px; }
    .sidebar.collapsed .sidebar-collapse-btn { position: static; transform: none; }
    .sidebar.collapsed .nav-item:hover::after { display: none; }

    .main-content {
        margin-left: 0 !important;
    }

    .topbar {
        padding: 0 12px;
        height: 50px;
    }
    .topbar h1 { font-size: 16px; }
    .topbar .breadcrumb { display: none; }
    .notif-dropdown { width: calc(100vw - 24px); right: -8px; }

    .page-content { padding: 12px; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 38px; height: 38px; font-size: 18px; }
    .stat-info h3 { font-size: 20px; }
    .stat-info p { font-size: 11px; }

    .card-header { padding: 12px 14px; }
    .card-body { padding: 14px; }

    .form-row,
    .form-row-3 { grid-template-columns: 1fr; }

    .modal { max-width: 100%; border-radius: 12px; }
    .modal-body { padding: 14px; }
    .modal-header { padding: 12px 14px; }

    table th { padding: 8px 10px; font-size: 10px; }
    table td { padding: 8px 10px; font-size: 12px; }

    .nfe-info-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .nfe-detail-grid-2,
    .nfe-detail-grid-3 { grid-template-columns: 1fr; }
    .nfe-section { padding: 12px; }
    .nfe-actions { flex-direction: column; }
    .nfe-actions .btn { width: 100%; justify-content: center; }

    .login-card { padding: 32px 24px; }
    .file-upload-area { padding: 30px 16px; }
    .file-upload-area i { font-size: 36px; }
}

/* Extra small phones */
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
    .nfe-info-grid { grid-template-columns: 1fr; }
    .topbar h1 { font-size: 14px; }
    .page-content { padding: 8px; }
    .card-header { padding: 10px 12px; }
    .card-body { padding: 10px 12px; }
}
