:root {
    --primary: #0d6e7a;
    --primary-dark: #094f58;
    --primary-light: #14a3b5;
    --secondary: #1e3a5f;
    --accent: #f59e0b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
    --transition: .2s ease;
    --bg-hover: #f1f5f9;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
html { font-size: 14px; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

.app-wrapper { display: flex; min-height: 100vh; }
.app-main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; transition: margin var(--transition); }
.app-content { flex: 1; padding: 24px; }
.app-footer { padding: 16px 24px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12px; background: var(--bg-card); }

/* Sidebar */
.sidebar {
    position: fixed; left: 0; top: 0; width: var(--sidebar-width); height: 100vh;
    background: linear-gradient(180deg, var(--secondary) 0%, #0f2744 100%);
    color: #fff; z-index: 1000; display: flex; flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
}
.sidebar-brand { padding: 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: transparent; }
.brand-name { font-weight: 700; font-size: 16px; display: block; }
.brand-sub { font-size: 11px; opacity: .7; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px;
    color: rgba(255,255,255,.75); text-decoration: none; border-radius: 8px;
    margin-bottom: 4px; transition: var(--transition); font-size: 13px; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { width: 20px; text-align: center; }
.nav-divider { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 12px 0; }
.sidebar-footer { padding: 16px; text-align: center; opacity: .5; font-size: 11px; }

/* Header */
.app-header {
    height: var(--header-height); background: var(--bg-card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle { display: none; }
.header-search { flex: 1; max-width: 400px; position: relative; }
.header-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.header-search input {
    width: 100%; padding: 10px 12px 10px 38px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--bg); font-size: 13px;
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.header-empresa { font-size: 12px; color: var(--text-muted); background: var(--bg); padding: 6px 12px; border-radius: 20px; }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; padding: 6px; border-radius: 8px; }
.user-btn:hover { background: var(--bg); }
.user-avatar {
    width: 36px; height: 36px; background: var(--primary); color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; overflow: hidden;
}
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: 100%; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 200px; padding: 8px; display: none; z-index: 200;
}
.dropdown-menu.show { display: block; }
.dropdown-menu a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    color: var(--text); text-decoration: none; border-radius: 6px; font-size: 13px;
}
.dropdown-menu a:hover { background: var(--bg); }
.dropdown-menu hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

/* Page */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }

/* Cards */
.card {
    background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border); overflow: hidden;
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 16px 20px; border-top: 1px solid var(--border); background: var(--bg); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
    display: flex; align-items: flex-start; gap: 16px; transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-icon.primary { background: rgba(13,110,122,.12); color: var(--primary); }
.stat-icon.success { background: rgba(16,185,129,.12); color: var(--success); }
.stat-icon.warning { background: rgba(245,158,11,.12); color: var(--warning); }
.stat-icon.danger { background: rgba(239,68,68,.12); color: var(--danger); }
.stat-icon.info { background: rgba(59,130,246,.12); color: var(--info); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 11px; margin-top: 6px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 1024px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px;
    border: none; border-radius: 8px; font-size: 13px; font-weight: 500;
    cursor: pointer; text-decoration: none; transition: var(--transition); font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: #3b82f6; color: #fff; }
.btn-info:hover { background: #2563eb; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 13px; font-family: inherit; transition: border var(--transition);
    background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,122,.15); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Table */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 12px 16px; background: var(--bg); font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: rgba(13,110,122,.03); }
.table .actions { white-space: nowrap; width: 1px; }
.table .actions > * { display: inline-flex; margin: 0 2px; }

/* Badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: rgba(16,185,129,.15); color: #047857; }
.badge-warning { background: rgba(245,158,11,.15); color: #b45309; }
.badge-danger { background: rgba(239,68,68,.15); color: #b91c1c; }
.badge-info { background: rgba(59,130,246,.15); color: #1d4ed8; }
.badge-secondary { background: var(--bg); color: var(--text-muted); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-card); border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-lg { max-width: 800px; }
.modal-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Toast */
.toast {
    position: fixed; top: 24px; right: 24px; background: var(--bg-card);
    padding: 14px 20px; border-radius: 10px; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 12px; z-index: 3000; animation: slideIn .3s ease;
    border-left: 4px solid var(--primary);
}
.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 18px; background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn.active { color: var(--primary); border-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Empty */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; }

/* Product thumb */
.prod-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.prod-thumb-placeholder { width: 40px; height: 40px; border-radius: 8px; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); font-size: 13px; }
.pagination a:hover { background: var(--bg); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Alerts validade */
.validade-ok { color: var(--success); }
.validade-alerta { color: var(--warning); }
.validade-critico { color: var(--danger); font-weight: 600; }
.validade-vencido { color: var(--danger); font-weight: 700; }

/* Responsive */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }
.sidebar-backdrop.show { display: block; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .sidebar-toggle i { font-size: 20px; }
    .d-none-mobile { display: none !important; }
    .app-content { padding: 16px; }
    .page-title { font-size: 20px; }
    .page-header { margin-bottom: 16px; }
    .stats-grid { gap: 12px; }
    .stat-card { padding: 1px; gap: 12px; }
    .stat-value { font-size: 22px; }
    .stat-icon { width: 40px; height: 40px; font-size: 16px; }
    .card-body { padding: 14px; }
    .table th, .table td { padding: 10px 12px; }
    .modal { margin: 10px; max-width: 100%; }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 14px 16px; }
    .modal-footer { padding: 12px 16px; flex-direction: column; }
    .modal-footer .btn { width: 100%; justify-content: center; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .app-content { padding: 12px; overflow-x: hidden; }
    .page-title { font-size: 18px; }
    .stats-grid { grid-template-columns: 1fr; gap: 8px; }
    .stat-card { padding: 10px; gap: 8px; min-width: 0; }
    .stat-card > :last-child { min-width: 0; overflow: hidden; }
    .stat-value { font-size: 15px; }
    .stat-label { font-size: 10px; }
    .stat-icon { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; flex-shrink: 0; }
    .btn { padding: 8px 14px; font-size: 12px; }
    .btn-sm { padding: 5px 10px; font-size: 11px; }
    .header-empresa { display: none; }
    .table { font-size: 12px; }
    .table th, .table td { padding: 8px 10px; white-space: nowrap; }
    .table-responsive .table { min-width: 480px; }
    .badge { font-size: 10px; padding: 3px 8px; }
    .card-header { padding: 12px 14px; }
    .card-header h3 { font-size: 14px; }
    .header-search { max-width: 200px; }
    .header-search input { padding: 8px 10px 8px 34px; font-size: 12px; }
    img { max-width: 100%; height: auto; }
    .card { min-width: 0; }
}

.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-3 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.pagination { display:flex; align-items:center; justify-content:center; gap:4px; padding:16px; }
.page-link { display:inline-flex; align-items:center; justify-content:center; min-width:36px; height:36px; padding:0 8px; border-radius:var(--radius); border:1px solid var(--border); background:var(--bg-card); color:var(--text); font-size:14px; text-decoration:none; transition:var(--transition); }
.page-link:hover { background:var(--bg-hover); }
.page-link.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.page-link:first-child, .page-link:last-child { font-size:16px; }

.list-group { border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
.list-item { border-bottom:1px solid var(--border); }
.list-item:last-child { border-bottom:none; }
.list-item-header:hover { background:var(--bg-hover); }
.list-item-body { border-top:1px solid var(--border); background:var(--bg); }
.suporte-item { color:var(--success) !important; }
.suporte-item i { color:var(--success) !important; }
