:root {
    --eklim-primary: #138C51;
    --eklim-primary-dark: #0B3D2E;
    --eklim-primary-darker: #082a21;
    --eklim-secondary: #83B04C;
    --eklim-accent: #249B9C;
    --eklim-bg: #EEF1F0;
    --eklim-card: #FFFFFF;
    --eklim-text: #1A2332;
    --eklim-text-muted: #6B7280;
    --eklim-border: #E8EBEA;
    --eklim-danger: #DC2626;
    --eklim-warning: #F59E0B;
    --sidebar-width: 272px;
    --sidebar-collapsed: 80px;
    --header-height: 68px;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
    font-family: 'Sora', -apple-system, sans-serif;
    background: var(--eklim-bg);
    color: var(--eklim-text);
    margin: 0;
    font-size: 0.875rem;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--eklim-primary); text-decoration: none; }
a:hover { color: #0f6d3f; }

/* ─── Sidebar oscuro ─── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--eklim-primary-dark) 0%, var(--eklim-primary-darker) 100%);
    z-index: 1040;
    transition: width .25s ease, transform .25s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .profile-info,
.sidebar.collapsed .profile-chevron,
.sidebar.collapsed .sidebar-logout span { display: none; }

.sidebar-brand {
    flex-shrink: 0;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-nav-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-logo-link { display: flex; align-items: center; justify-content: center; }
.sidebar-logo-img { max-height: 44px; max-width: 160px; object-fit: contain; filter: brightness(0) invert(1); }
.sidebar-logo-fallback {
    width: 44px; height: 44px;
    background: var(--eklim-primary);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 1.25rem;
}

.nav-section {
    padding: 20px 20px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: .08em;
    color: rgba(255,255,255,.35);
    list-style: none;
}

.sidebar-nav { list-style: none; padding: 4px 12px 16px; margin: 0; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.65);
    transition: all .15s;
    margin-bottom: 2px;
    font-weight: 400;
    font-size: 0.85rem;
}

.sidebar-nav .nav-link i { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; opacity: .8; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active {
    background: rgba(19,140,81,.35);
    color: #fff;
    font-weight: 500;
}
.sidebar-nav .nav-link.active i { opacity: 1; }

/* Perfil sidebar — fijo abajo */
.sidebar-profile {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,.15) 100%);
}

.sidebar-profile .nav-section { padding: 8px 14px 6px; }

.sidebar-profile-link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.85);
    transition: background .15s;
}

.sidebar-profile-link:hover, .sidebar-profile-link.active {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.profile-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--eklim-accent), var(--eklim-primary));
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.9rem; color: #fff; flex-shrink: 0;
}

.profile-info { flex: 1; min-width: 0; }
.profile-name { display: block; font-weight: 500; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-role { display: block; font-size: 0.7rem; color: rgba(255,255,255,.45); text-transform: capitalize; }
.profile-chevron { font-size: 0.75rem; opacity: .4; }

.sidebar-logout {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    color: rgba(255,255,255,.4);
    font-size: 0.8rem;
    margin-top: 4px;
    border-radius: 8px;
    transition: all .15s;
}

.sidebar-logout:hover { color: #ff8a8a; background: rgba(220,38,38,.1); }

/* ─── Main layout ─── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left .25s ease;
}

.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-collapsed); }

.top-header {
    position: sticky; top: 0;
    height: var(--header-height);
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--eklim-border);
    display: flex; align-items: center;
    padding: 0 28px; gap: 16px; z-index: 1030;
}

.btn-toggle-sidebar {
    background: none; border: none;
    font-size: 1.3rem; color: var(--eklim-text-muted);
    cursor: pointer; padding: 8px; border-radius: 8px;
}
.btn-toggle-sidebar:hover { background: var(--eklim-bg); }

.header-greeting { font-size: 0.8rem; color: var(--eklim-text-muted); font-weight: 400; }

.global-search { flex: 1; max-width: 420px; position: relative; }
.global-search input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid var(--eklim-border);
    border-radius: 12px;
    background: var(--eklim-bg);
    font-family: 'Sora', sans-serif;
    font-size: 0.85rem;
    transition: all .15s;
}
.global-search input:focus { outline: none; border-color: var(--eklim-primary); background: #fff; box-shadow: 0 0 0 3px rgba(19,140,81,.1); }
.global-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--eklim-text-muted); }

.demo-badge {
    background: var(--eklim-warning); color: #fff;
    font-size: 0.6rem; padding: 4px 10px;
    border-radius: 20px; font-weight: 600; letter-spacing: .04em;
}

.main-content { padding: 28px; }

/* ─── Page header ─── */
.page-title { font-size: 1.65rem; font-weight: 600; margin: 0 0 4px; letter-spacing: -.02em; }
.breadcrumb { margin: 0; font-size: 0.78rem; }
.breadcrumb-item a { color: var(--eklim-text-muted); }
.breadcrumb-bar { margin-bottom: 24px; }

/* ─── Stat cards ─── */
.stat-card {
    background: var(--eklim-card);
    border: 1px solid var(--eklim-border);
    border-radius: var(--radius);
    padding: 24px;
    height: 100%;
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,0,0,.06); }

.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; margin-bottom: 16px;
}

.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.stat-card .stat-label { color: var(--eklim-text-muted); font-size: 0.8rem; margin-top: 6px; font-weight: 400; }

.stat-card-lg .stat-value { font-size: 2.25rem; }

/* ─── Panels ─── */
.card-panel {
    background: var(--eklim-card);
    border: 1px solid var(--eklim-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card-panel .card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--eklim-border);
    display: flex; align-items: center; justify-content: space-between;
    background: transparent;
}

.card-panel .card-header h6 { font-weight: 600; font-size: 0.95rem; margin: 0; }
.card-panel .card-body { padding: 22px; }

/* ─── Alertas panel ─── */
.alertas-panel { height: 100%; }
.alertas-list { max-height: 380px; overflow-y: auto; }

.alerta-item {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--eklim-border);
}
.alerta-item:last-child { border-bottom: none; }

.alerta-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 0.95rem;
}

.alerta-icon.warning { background: #FEF3C7; color: #D97706; }
.alerta-icon.info { background: #DBEAFE; color: #2563EB; }
.alerta-icon.success { background: #D1FAE5; color: #059669; }
.alerta-icon.primary { background: #E0E7FF; color: #4F46E5; }

.alerta-content strong { display: block; font-weight: 500; font-size: 0.85rem; margin-bottom: 2px; }
.alerta-content p { margin: 0; font-size: 0.8rem; color: var(--eklim-text-muted); }
.alerta-content a { font-size: 0.75rem; font-weight: 500; }

.alerta-empty {
    text-align: center; padding: 48px 20px;
    color: var(--eklim-text-muted);
}
.alerta-empty i { font-size: 2.5rem; opacity: .3; display: block; margin-bottom: 12px; }

.threshold-form {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 22px;
    background: var(--eklim-bg);
    border-top: 1px solid var(--eklim-border);
    font-size: 0.8rem;
}
.threshold-form input {
    width: 60px; padding: 4px 8px;
    border: 1px solid var(--eklim-border);
    border-radius: 6px; font-family: 'Sora', sans-serif;
    text-align: center;
}

/* ─── Chart ─── */
.chart-container { position: relative; height: 280px; }
.chart-link { font-size: 0.8rem; font-weight: 500; }

/* ─── Tables ─── */
.table-eklim { margin: 0; font-size: 0.85rem; }
.table-eklim thead th {
    background: var(--eklim-bg);
    border-bottom: 1px solid var(--eklim-border);
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--eklim-text-muted);
    padding: 12px 18px; white-space: nowrap;
}
.table-eklim tbody td { padding: 13px 18px; vertical-align: middle; border-color: var(--eklim-border); }
.table-eklim tbody td.text-end { white-space: nowrap; }
.table-eklim tbody tr:hover { background: rgba(19,140,81,.02); }

/* ─── Buttons ─── */
.btn-eklim {
    background: var(--eklim-primary);
    border-color: var(--eklim-primary);
    color: #fff; font-family: 'Sora', sans-serif;
    font-weight: 500; border-radius: 10px;
    padding: 8px 18px;
}
.btn-eklim:hover { background: #0f6d3f; border-color: #0f6d3f; color: #fff; }

.btn-dark-modern {
    background: var(--eklim-text); border: none; color: #fff;
    font-family: 'Sora', sans-serif; font-weight: 500;
    border-radius: 10px; padding: 8px 18px;
}
.btn-dark-modern:hover { background: #0f1419; color: #fff; }

/* ─── Badges ─── */
.badge { font-weight: 500; font-size: 0.72rem; padding: 5px 10px; border-radius: 20px; font-family: 'Sora', sans-serif; }

/* ─── Drawer ─── */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1050; opacity: 0; visibility: hidden;
    transition: all .3s;
}
.drawer-overlay.show { opacity: 1; visibility: visible; }

.drawer {
    position: fixed; top: 0; right: 0;
    width: 480px; max-width: 100vw; height: 100vh;
    background: var(--eklim-card);
    z-index: 1051;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    display: flex; flex-direction: column;
    box-shadow: -12px 0 40px rgba(0,0,0,.12);
}
.drawer.show { transform: translateX(0); }
.drawer-header { padding: 22px 24px; border-bottom: 1px solid var(--eklim-border); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.drawer-header h5 { font-weight: 600; }
.drawer-body { padding: 24px; overflow-y: auto; flex: 1; }
.drawer-footer { padding: 16px 24px; border-top: 1px solid var(--eklim-border); display: flex; gap: 8px; justify-content: flex-end; }

/* ─── Auth ─── */
.auth-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #e8f5ee 0%, var(--eklim-bg) 50%, #dceee4 100%);
    padding: 24px;
    font-family: 'Sora', sans-serif;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--eklim-card);
    border: 1px solid var(--eklim-border);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow);
}
.auth-card-modern { max-width: 420px; padding: 2rem 1.75rem; }
.auth-logo-wrap { text-align: center; margin-bottom: 1.5rem; }
.auth-logo-img { max-height: 56px; max-width: 200px; object-fit: contain; }
.auth-logo-fallback { width: 56px; height: 56px; margin: 0 auto 1.5rem; border-radius: 14px; background: var(--eklim-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.5rem; }
.auth-portal-switch { display: flex; background: var(--eklim-bg); border-radius: 12px; padding: 4px; margin-bottom: 0.75rem; }
.auth-portal-tab { flex: 1; text-align: center; padding: 0.55rem 0.75rem; border-radius: 10px; font-size: 0.85rem; font-weight: 600; color: var(--eklim-text-muted); text-decoration: none; transition: all 0.2s; }
.auth-portal-tab.active { background: #fff; color: var(--eklim-primary); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.auth-portal-hint { font-size: 0.8rem; }
.auth-demo-box { background: var(--eklim-bg); font-size: 0.78rem; line-height: 1.6; }

/* ─── Filters ─── */
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--eklim-border);
    background: var(--eklim-bg);
}

.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }

.filter-label {
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--eklim-text-muted);
}

.filter-select {
    font-family: 'Sora', sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--eklim-text);
    border: 1px solid var(--eklim-border);
    border-radius: 10px;
    padding: 10px 40px 10px 14px;
    min-width: 220px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    appearance: none; -webkit-appearance: none;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--eklim-primary);
    box-shadow: 0 0 0 3px rgba(19,140,81,.1);
}

.badge-destacados {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 20px;
    background: #FEF3C7; color: #B45309;
    font-size: 0.78rem; font-weight: 500;
}

/* ─── Product table extras ─── */
.row-destacado { background: rgba(245, 158, 11, .04) !important; }
.row-destacado:hover { background: rgba(245, 158, 11, .07) !important; }

.code-badge {
    background: var(--eklim-bg);
    padding: 4px 8px; border-radius: 6px;
    font-size: 0.78rem; color: var(--eklim-text);
}

.product-cell { display: flex; flex-direction: column; gap: 4px; }

.destacado-pill {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.68rem; font-weight: 600;
    color: #B45309; background: #FEF3C7;
    padding: 2px 8px; border-radius: 20px;
    width: fit-content;
}
.destacado-pill i { font-size: 0.6rem; }

/* ─── Action dropdown ─── */
.action-dropdown .btn-action-menu {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--eklim-border);
    background: #fff;
    color: var(--eklim-text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
    transition: all .15s;
}
.action-dropdown .btn-action-menu::after { display: none; }
.action-dropdown .btn-action-menu:hover,
.action-dropdown.show .btn-action-menu {
    background: var(--eklim-bg);
    border-color: var(--eklim-primary);
    color: var(--eklim-primary);
}

.action-menu {
    border: 1px solid var(--eklim-border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    min-width: 180px;
}

.action-menu .dropdown-item {
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.84rem;
    display: flex; align-items: center; gap: 10px;
    font-family: 'Sora', sans-serif;
}
.action-menu .dropdown-item i { width: 18px; opacity: .7; }
.action-menu .dropdown-item:hover { background: var(--eklim-bg); }
.action-menu .dropdown-item.text-danger:hover { background: #FEF2F2; }
.action-menu .dropdown-header {
    font-size: 0.68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--eklim-text-muted);
    padding: 6px 12px 4px;
}

/* ─── Drawer modern ─── */
.drawer-modern {
    width: 520px;
    border-radius: 20px 0 0 20px;
}

.drawer-modern .drawer-header {
    padding: 24px 28px;
    background: linear-gradient(180deg, #f8faf9 0%, #fff 100%);
}

.drawer-subtitle {
    font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--eklim-text-muted); margin: 0;
}

.btn-drawer-close {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--eklim-border);
    background: #fff; color: var(--eklim-text-muted);
    display: flex; align-items: center; justify-content: center;
    padding: 0; flex-shrink: 0;
}
.btn-drawer-close:hover { background: var(--eklim-bg); color: var(--eklim-text); }

.drawer-form { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.drawer-modern .drawer-body { padding: 0 28px 28px; }

.drawer-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--eklim-border);
}
.drawer-section:last-child { border-bottom: none; }

.drawer-section-title {
    font-size: 0.78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--eklim-text-muted);
    margin-bottom: 14px;
}

.destacado-toggle {
    background: var(--eklim-bg);
    border-radius: 12px;
    padding: 16px;
}

.drawer-modern .drawer-footer {
    padding: 18px 28px;
    background: #fafbfb;
    gap: 10px;
}

.btn-drawer-cancel {
    border-radius: 10px; padding: 10px 20px;
    font-weight: 500; border: 1px solid var(--eklim-border);
}
.btn-drawer-save { padding: 10px 22px; border-radius: 10px; }

/* Detail card in drawer */
.detail-card {
    background: var(--eklim-bg);
    border-radius: 14px;
    padding: 4px 0;
    overflow: hidden;
}
.detail-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--eklim-border);
    font-size: 0.85rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--eklim-text-muted); }

/* ─── QR Modal ─── */
.modal-qr .modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    padding: 8px;
}

.qr-preview-wrap {
    background: var(--eklim-bg);
    border-radius: 16px;
    padding: 24px;
    display: inline-block;
}

.qr-preview-img {
    width: 220px; height: 220px;
    object-fit: contain;
    border-radius: 8px;
}

.qr-url-label { font-size: 0.75rem; color: var(--eklim-text-muted); font-weight: 500; }
.qr-url-link { font-size: 0.8rem; word-break: break-all; }

/* ─── Legacy filter (override) ─── */
.filter-bar select:not(.filter-select), .filter-bar input {
    font-family: 'Sora', sans-serif;
    font-size: 0.82rem;
    border: 1px solid var(--eklim-border);
    border-radius: 8px; padding: 7px 12px;
}

/* ─── Forms ─── */
.form-control, .form-select {
    font-family: 'Sora', sans-serif;
    border-radius: 10px;
    border-color: var(--eklim-border);
    font-size: 0.85rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--eklim-primary);
    box-shadow: 0 0 0 3px rgba(19,140,81,.1);
}
.form-label { font-weight: 500; font-size: 0.82rem; }

/* ─── Stock list ─── */
.stock-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--eklim-border);
}
.stock-item:last-child { border-bottom: none; }
.stock-bar { height: 4px; border-radius: 2px; background: var(--eklim-border); margin-top: 6px; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 2px; background: var(--eklim-danger); }

/* ─── Responsive ─── */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; }
    .drawer { width: 100vw; }
}

@media (max-width: 576px) {
    .main-content { padding: 16px; }
    .stat-card .stat-value { font-size: 1.6rem; }
}
