/* =====================================================
   AGRORASTRO - Professional Stylesheet
   Rastreabilidade Inteligente do Campo ao Destino
   ===================================================== */

:root {
    --primary: #2E7D32;
    --primary-light: #4CAF50;
    --primary-dark: #1B5E20;
    --secondary: #F57C00;
    --secondary-light: #FFB74D;
    --secondary-dark: #E65100;
    --accent: #8BC34A;
    --bg: #F5F7FA;
    --bg-card: #FFFFFF;
    --text: #212121;
    --text-secondary: #757575;
    --text-light: #9E9E9E;
    --border: #E0E0E0;
    --border-light: #F0F0F0;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --info: #2196F3;
    --sidebar-width: 260px;
    --header-height: 64px;
    --mobile-nav-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
[data-theme="dark"] {
    --bg: #121212;
    --bg-card: #1E1E1E;
    --text: #E0E0E0;
    --text-secondary: #BDBDBD;
    --text-light: #9E9E9E;
    --border: #333333;
    --border-light: #2A2A2A;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* Bloquear transições no carregamento */
body.preload, body.preload * { transition: none !important; animation: none !important; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.35); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== UTILITIES ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.5rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

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

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
/* Sidebar retrátil desktop */
.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .sidebar-brand h1,
.sidebar.collapsed .sidebar-brand small,
.sidebar.collapsed .sidebar-nav .nav-section,
.sidebar.collapsed .sidebar-nav a span:not(.nav-icon),
.sidebar.collapsed .sidebar-nav a .badge-nav,
.sidebar.collapsed .sidebar-user .user-info,
.sidebar.collapsed .sidebar-user a { display: none; }
.sidebar.collapsed .sidebar-brand a { justify-content: center; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 0.75rem; border-left: none; }
.sidebar.collapsed .sidebar-nav a .nav-icon { width: auto; font-size: 1.2rem; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 1rem 0.5rem; }
.sidebar.collapsed ~ .main-content { margin-left: 68px; }
.sidebar-brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-brand .logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.sidebar-brand h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.sidebar-brand small {
    font-size: 0.65rem;
    opacity: 0.7;
    display: block;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.sidebar-nav { flex: 1; padding: 0.75rem 0; }
.sidebar-nav .nav-section {
    padding: 0.75rem 1.5rem 0.5rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.5;
    font-weight: 600;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.sidebar-nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: var(--secondary);
}
.sidebar-nav a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}
.sidebar-nav a .badge-nav {
    margin-left: auto;
    background: var(--secondary);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}
.sidebar-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-user img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.sidebar-user .user-info { flex: 1; }
.sidebar-user .user-info .name { font-size: 0.85rem; font-weight: 600; }
.sidebar-user .user-info .role { font-size: 0.7rem; opacity: 0.7; }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ===== HEADER ===== */
.header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-left h2 { font-size: 1.25rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 1rem; position: relative; }
.btn-menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
    padding: 0.25rem;
    transition: var(--transition);
    border-radius: 8px;
}
.btn-menu-toggle:hover { background: var(--bg); }
.header-search {
    position: relative;
}
.header-search input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 25px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    font-size: 0.85rem;
    color: var(--text);
    width: 200px;
}
.header-search input:focus {
    outline: none;
    border-color: var(--primary);
}
.header-search input::placeholder { color: var(--text-light); }
.header-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}
.btn-notification {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
    color: var(--text-secondary);
}
.btn-notification:hover { border-color: var(--primary); color: var(--primary); }
.btn-notification .notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ===== NOTIFICATIONS POPUP ===== */
.notif-popup {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    margin-top: 0.5rem;
}
.notif-popup.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
}
.notif-header h3 { font-size: 0.9rem; font-weight: 600; margin: 0; }
.notif-close {
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-light);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.notif-close:hover { background: var(--bg); color: var(--text); }
.notif-body { padding: 1rem; max-height: 300px; overflow-y: auto; }
.notif-empty {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-light);
}
.notif-empty i { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.3; }
.notif-empty p { font-size: 0.85rem; margin: 0; }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 1.5rem; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.breadcrumb {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb span::before { content: '/'; margin-right: 0.5rem; color: var(--text-light); }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-light); }

/* ===== STATS CARDS (Dashboard) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    border-left: 4px solid var(--primary);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.orange { border-left-color: var(--secondary); }
.stat-card.blue { border-left-color: var(--info); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.green { border-left-color: var(--success); }
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-icon.green { background: rgba(76,175,80,0.1); color: var(--success); }
.stat-icon.orange { background: rgba(255,152,0,0.1); color: var(--warning); }
.stat-icon.blue { background: rgba(33,150,243,0.1); color: var(--info); }
.stat-icon.red { background: rgba(244,67,54,0.1); color: var(--danger); }
.stat-info h4 { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-info .stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
.stat-info .stat-change { font-size: 0.75rem; color: var(--success); font-weight: 500; }

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

/* ===== TABLE ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.table thead th {
    background: var(--bg);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: rgba(46,125,50,0.03); }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-success { background: rgba(76,175,80,0.12); color: #2E7D32; }
.badge-warning { background: rgba(255,152,0,0.12); color: #E65100; }
.badge-danger { background: rgba(244,67,54,0.12); color: #C62828; }
.badge-info { background: rgba(33,150,243,0.12); color: #1565C0; }
.badge-secondary { background: rgba(158,158,158,0.12); color: #616161; }
.badge-primary { background: rgba(46,125,50,0.12); color: #2E7D32; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
}
.btn-group { display: flex; gap: 0.5rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.25rem; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}
.form-control {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,125,50,0.1);
}
.form-control::placeholder { color: var(--text-light); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23757575' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.form-text { font-size: 0.78rem; color: var(--text-light); margin-top: 0.25rem; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ===== ALERTS / FLASH ===== */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}
.alert-success { background: rgba(76,175,80,0.1); color: #2E7D32; border-left: 4px solid var(--success); }
.alert-erro, .alert-danger { background: rgba(244,67,54,0.1); color: #C62828; border-left: 4px solid var(--danger); }
.alert-warning { background: rgba(255,152,0,0.1); color: #E65100; border-left: 4px solid var(--warning); }
.alert-info { background: rgba(33,150,243,0.1); color: #1565C0; border-left: 4px solid var(--info); }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: 0.6rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
    position: absolute;
    left: -1.65rem;
    top: 0.25rem;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}
.timeline-dot.orange { background: var(--secondary); box-shadow: 0 0 0 2px var(--secondary); }
.timeline-dot.blue { background: var(--info); box-shadow: 0 0 0 2px var(--info); }
.timeline-dot.green { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-content h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; }
.timeline-content p { font-size: 0.8rem; color: var(--text-secondary); }
.timeline-content .timeline-date { font-size: 0.7rem; color: var(--text-light); margin-top: 0.25rem; }

/* ===== MOBILE BOTTOM NAV ===== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 1001;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.more-menu-overlay { display: none; }
.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    padding: 0 0.5rem;
}
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    color: var(--text-light);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-decoration: none;
}
.mobile-nav-item .nav-icon { font-size: 1.3rem; }
.mobile-nav-item.active, .mobile-nav-item:hover { color: var(--primary); }
.mobile-nav-item.active { background: rgba(46,125,50,0.08); }
button.mobile-nav-item { background: none; border: none; cursor: pointer; font-family: inherit; }

/* ===== MORE MENU POPUP (Mobile) ===== */
.more-menu-overlay {
    display: none !important;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: flex-end;
    justify-content: center;
}
.more-menu-overlay.active { display: flex !important; }
.more-menu-popup {
    display: none !important;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    animation: slideMenuUp 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.more-menu-overlay.active .more-menu-popup { display: block !important; }
@keyframes slideMenuUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.more-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}
.more-menu-header h3 { font-size: 1.1rem; font-weight: 700; }
.more-menu-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-light);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.more-menu-close:hover { background: var(--bg); }
.more-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
    padding: 1rem;
}
.more-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    transition: var(--transition);
}
.more-menu-item:hover { background: var(--bg); }
.more-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Desktop QR button */
.fab-scan-desktop {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(46,125,50,0.4);
    cursor: pointer;
    z-index: 999;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}
.fab-scan-desktop:hover { transform: scale(1.1); box-shadow: 0 6px 24px rgba(46,125,50,0.5); color: #fff; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 50%, #F57C00 100%);
    padding: 1rem;
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}
.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-logo .logo-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
}
.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -1px;
}
.login-logo p { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.25rem; }

/* ===== PUBLIC RASTREIO PAGE ===== */
.rastreio-page {
    min-height: 100vh;
    background: var(--bg);
}
.rastreio-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    padding: 2rem 1.5rem;
    text-align: center;
}
.rastreio-header h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.rastreio-header p { opacity: 0.8; font-size: 0.9rem; }
.passaporte-card {
    max-width: 600px;
    margin: -2rem auto 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.passaporte-hero {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 1.5rem;
    text-align: center;
}
.passaporte-hero .fruta-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.passaporte-hero h2 { font-size: 1.25rem; }
.passaporte-body { padding: 1.5rem; }
.passaporte-info { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.passaporte-info .info-item label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); font-weight: 600; display: block; margin-bottom: 0.15rem; }
.passaporte-info .info-item span { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.passaporte-section { margin-bottom: 1.5rem; }
.passaporte-section h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.cert-badge { display: inline-flex; align-items: center; gap: 0.35rem; background: rgba(76,175,80,0.1); color: var(--primary); padding: 0.35rem 0.75rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600; margin: 0.25rem; }

/* ===== QR SCAN PAGE ===== */
.scan-page {
    min-height: 100vh;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.scan-viewfinder {
    width: 280px;
    height: 280px;
    border: 3px solid var(--primary-light);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    margin-bottom: 2rem;
}
.scan-viewfinder::before, .scan-viewfinder::after {
    content: '';
    position: absolute;
    background: var(--primary-light);
}
.scan-viewfinder video { width: 100%; height: 100%; object-fit: cover; }
.scan-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.scan-subtitle { font-size: 0.85rem; opacity: 0.7; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ===== QR CODE DISPLAY ===== */
.qr-code-container { text-align: center; padding: 1rem; }
.qr-code-img { max-width: 250px; border: 8px solid #fff; box-shadow: var(--shadow); border-radius: var(--radius-sm); }

/* ===== PRINT ===== */
@media print {
    .sidebar, .header, .mobile-nav, .fab-scan, .fab-scan-desktop, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd; }
}

/* ===== RESPONSIVE ===== */
@media (min-width: 769px) {
    .mobile-nav, .more-menu-overlay, .more-menu-popup { display: none !important; }
}

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { width: 280px; }
    .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; }
    .main-content { margin-left: 0 !important; width: 100%; max-width: 100vw; padding-bottom: calc(var(--mobile-nav-height) + 1rem); }
    .btn-menu-toggle { display: none !important; }
    .mobile-logo { display: block !important; }
    .desktop-title { display: none !important; }
    .mobile-nav { display: block !important; }
    .fab-scan-desktop { display: none; }
    .header-search { display: none; }
    .page-content { padding: 1rem; overflow-x: hidden; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stat-card { padding: 1rem; }
    .stat-info .stat-value { font-size: 1.25rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .passaporte-info { grid-template-columns: 1fr; }
    .table { font-size: 0.8rem; }
    .table thead th { padding: 0.5rem 0.6rem; font-size: 0.7rem; }
    .table tbody td { padding: 0.5rem 0.6rem; }
    .card { border-radius: var(--radius-sm); }
    .card-header { padding: 0.75rem 1rem; }
    .card-body { padding: 1rem; }
    .app-layout { max-width: 100vw; overflow-x: hidden; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 1.5rem; }
    .page-content { padding: 0.5rem; }
    .page-header h1 { font-size: 1.2rem; }
    .table thead th { padding: 0.4rem; font-size: 0.65rem; }
    .table tbody td { padding: 0.4rem; font-size: 0.75rem; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.5s ease; }
.slide-up { animation: slideUp 0.5s ease; }

/* ===== LOADING ===== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== STATUS DOT ===== */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
}
.status-dot.green { background: var(--success); }
.status-dot.orange { background: var(--warning); }
.status-dot.red { background: var(--danger); }
.status-dot.blue { background: var(--info); }
.status-dot.gray { background: var(--text-light); }

/* ===== PROGRESS BAR ===== */
.progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ===== AVATAR ===== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
    object-fit: cover;
}
.avatar-lg { width: 64px; height: 64px; }

/* ===== MAP placeholder ===== */
.map-container {
    width: 100%;
    height: 250px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    border: 1px solid var(--border);
}
