@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #FFFFFF;
    --bg-surface: #F1F5F9;
    --bg-card: #FFFFFF;
    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-glow: rgba(59, 130, 246, 0.06);
    --success: #16A34A; --success-bg: rgba(22,163,74,0.08);
    --warning: #D97706; --warning-bg: rgba(217,119,6,0.08);
    --danger: #DC2626; --danger-bg: rgba(220,38,38,0.08);
    --info: #3B82F6; --info-bg: rgba(59,130,246,0.08);
    --text-primary: #1A202C;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E8ECF1; --border-hover: #CBD5E1;
    --radius: 16px; --radius-sm: 10px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.03);
    --sidebar-width: 240px; --sidebar-collapsed: 68px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg-surface); color: var(--text-primary); min-height: 100vh; -webkit-font-smoothing: antialiased; position: relative; z-index: 0; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.10); border-radius: 3px; }

/* ===== LOGIN ===== */
#login-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background-color: #0C2340;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(59,130,246,0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(59,130,246,0.08) 0%, transparent 40%),
        radial-gradient(circle at 60% 80%, rgba(255,255,255,0.03) 0%, transparent 40%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s, visibility 0.5s;
}
#login-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.login-container {
    text-align: center; max-width: 420px; width: 90%;
    background: rgba(255,255,255,0.98);
    border-radius: 24px; padding: 3rem 2.5rem;
    box-shadow: 0 25px 80px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.1);
}
.login-logo {
    width: 72px; height: 72px; margin: 0 auto 1.25rem;
    border-radius: var(--radius); object-fit: cover;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.login-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.3rem; }
.login-subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 2rem; }
.login-field { text-align: left; margin-bottom: 1.15rem; }
.login-field label { display: block; font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; margin-bottom: 0.4rem; }
.login-field input {
    width: 100%; padding: 0.75rem 1rem; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); background: var(--bg-surface);
    font-family: var(--font); font-size: 0.9rem; color: var(--text-primary);
    outline: none; transition: all 0.2s;
}
.login-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); background: #fff; }
.password-toggle-btn {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%; outline: none; padding: 0;
    transition: background 0.15s, color 0.15s;
}
.password-toggle-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--accent); }
.login-error { font-size: 0.8rem; color: var(--danger); min-height: 1.2rem; margin-bottom: 0.5rem; }
.login-btn { width: 100%; padding: 0.8rem; font-size: 0.9rem; margin-top: 0.5rem; justify-content: center; border-radius: var(--radius-sm); }

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

/* ===== SIDEBAR ===== */
#sidebar {
    width: var(--sidebar-width); min-height: 100vh; background: var(--bg-primary);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transition: width 0.3s;
}
#sidebar.collapsed { width: var(--sidebar-collapsed); }
#sidebar.collapsed .nav-text, #sidebar.collapsed .sidebar-brand-text, #sidebar.collapsed .sidebar-footer-text, #sidebar.collapsed .nav-badge, #sidebar.collapsed .sidebar-mascot { display: none; }
.sidebar-header { padding: 1.5rem 1.25rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.75rem; }
.sidebar-brand-icon { width: 32px; height: 32px; background: var(--accent); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.sidebar-brand-text { font-size: 0.72rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; line-height: 1.2; }
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1rem;
    border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none;
    font-size: 0.85rem; font-weight: 500; transition: all 0.2s; position: relative;
}
.sidebar-nav a:hover { color: var(--text-primary); background: var(--bg-surface); }
.sidebar-nav a.active { color: var(--accent); font-weight: 600; background: var(--info-bg); }
.sidebar-nav a.active::before { content: ''; position: absolute; left: -0.75rem; top: 15%; bottom: 15%; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge { background: var(--accent); color: white; font-size: 0.65rem; font-weight: 700; padding: 0.15rem 0.45rem; border-radius: 9999px; margin-left: auto; }
.sidebar-toggle { position: absolute; right: -12px; top: 50%; width: 24px; height: 24px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; transition: all 0.2s; z-index: 10; box-shadow: var(--shadow-card); }
.sidebar-toggle:hover { color: var(--accent); border-color: var(--accent); }
.sidebar-footer { padding: 1rem 0.75rem; border-top: 1px solid var(--border); }
.sidebar-footer-text { font-size: 0.7rem; color: var(--text-muted); text-align: center; margin-top: 0.5rem; }

/* ===== HAMBURGER ===== */
#hamburger { display: none; position: fixed; top: 0.8rem; left: 0.8rem; z-index: 200; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary); font-size: 1.2rem; cursor: pointer; align-items: center; justify-content: center; box-shadow: var(--shadow-card); }
#sidebarOverlay { display: none; position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
#sidebarOverlay.active { display: block; }

/* ===== MAIN ===== */
#main-content { margin-left: var(--sidebar-width); flex: 1; padding: 2rem 2.5rem 3rem; transition: margin-left 0.3s; min-height: 100vh; }
#sidebar.collapsed ~ #main-content { margin-left: var(--sidebar-collapsed); }
.view { display: none; } .view.active { display: block; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== HEADER ===== */
.view-header { margin-bottom: 2rem; }
.view-title { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem; letter-spacing: -0.01em; }
.view-subtitle { font-size: 0.85rem; color: var(--text-muted); }
.header-actions { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.75rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.55rem 1.1rem; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 500; cursor: pointer; font-family: var(--font); transition: all 0.2s; border: 1.5px solid var(--border); background: var(--bg-card); color: var(--text-primary); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; box-shadow: 0 2px 8px rgba(59,130,246,0.2); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.25); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.72rem; gap: 0.3rem; }
.btn-sm svg { width: 12px; height: 12px; }
.btn-success { background: var(--success); border-color: var(--success); color: white; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }

/* ===== KPI ===== */
.kpi-grid { display: grid; gap: 1rem; margin-bottom: 1.5rem; grid-template-columns: repeat(4, 1fr); }
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 0.85rem;
    transition: all 0.3s ease; position: relative;
    box-shadow: var(--shadow-card);
}
.kpi-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.kpi-section-label {
    font-size: 0.95rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: 1.2px; margin-bottom: 0.75rem; margin-top: 1rem;
    padding-bottom: 0.5rem; border-bottom: 2px solid var(--border);
}
.kpi-icon-box {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.kpi-icon-box svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi-icon-box.accent { background: var(--info-bg); color: var(--accent); }
.kpi-icon-box.success { background: var(--success-bg); color: var(--success); }
.kpi-icon-box.warning { background: var(--warning-bg); color: var(--warning); }
.kpi-icon-box.danger { background: var(--danger-bg); color: var(--danger); }
.kpi-icon-box.neutral { background: var(--bg-surface); color: var(--text-secondary); }
.kpi-info { flex: 1; min-width: 0; }
.kpi-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 0.3rem; }
.kpi-value { font-size: 1.55rem; font-weight: 700; color: var(--text-primary); line-height: 1.15; letter-spacing: -0.02em; }

/* KPI Glow Variants */
.kpi-card.glow-accent { background: linear-gradient(135deg, var(--accent) 0%, #1D4ED8 100%); color: white; border: none; box-shadow: 0 12px 24px -6px rgba(59, 130, 246, 0.6), 0 8px 12px -8px rgba(59, 130, 246, 0.2); }
.kpi-card.glow-accent .kpi-label { color: rgba(255,255,255,0.85); }
.kpi-card.glow-accent .kpi-value { color: white; }
.kpi-card.glow-accent .kpi-icon-box { background: rgba(255,255,255,0.2); color: white; }

.kpi-card.glow-success { background: linear-gradient(135deg, var(--success) 0%, #15803d 100%); color: white; border: none; box-shadow: 0 12px 24px -6px rgba(22, 163, 74, 0.6), 0 8px 12px -8px rgba(22, 163, 74, 0.2); }
.kpi-card.glow-success .kpi-label { color: rgba(255,255,255,0.85); }
.kpi-card.glow-success .kpi-value { color: white; }
.kpi-card.glow-success .kpi-icon-box { background: rgba(255,255,255,0.2); color: white; }

.kpi-card.glow-warning { background: linear-gradient(135deg, var(--warning) 0%, #b45309 100%); color: white; border: none; box-shadow: 0 12px 24px -6px rgba(217, 119, 6, 0.6), 0 8px 12px -8px rgba(217, 119, 6, 0.2); }
.kpi-card.glow-warning .kpi-label { color: rgba(255,255,255,0.85); }
.kpi-card.glow-warning .kpi-value { color: white; }
.kpi-card.glow-warning .kpi-icon-box { background: rgba(255,255,255,0.2); color: white; }

.kpi-card.glow-danger { background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%); color: white; border: none; box-shadow: 0 12px 24px -6px rgba(220, 38, 38, 0.6), 0 8px 12px -8px rgba(220, 38, 38, 0.2); }
.kpi-card.glow-danger .kpi-label { color: rgba(255,255,255,0.85); }
.kpi-card.glow-danger .kpi-value { color: white; }
.kpi-card.glow-danger .kpi-icon-box { background: rgba(255,255,255,0.2); color: white; }


/* ===== CHARTS ===== */
.chart-grid { display: grid; gap: 1.25rem; margin-bottom: 1.5rem; }
.chart-grid-1 { grid-template-columns: 1fr; } .chart-grid-2 { grid-template-columns: repeat(2, 1fr); }
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); transition: box-shadow 0.3s; }
.chart-card:hover { box-shadow: var(--shadow-card-hover); }
.chart-card.tall .chart-canvas-wrap { height: 380px; }
.chart-header { padding: 1.25rem 1.5rem; display: flex; align-items: center; justify-content: space-between; }
.chart-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 0.5rem; }
.chart-title svg { width: 14px; height: 14px; fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-canvas-wrap { padding: 1rem 1.5rem 1.5rem; height: 300px; position: relative; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.7rem; border-radius: 9999px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-neutral { color: var(--text-secondary); background: var(--bg-surface); }

/* ===== TABLE ===== */
.table-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.table-toolbar { padding: 1rem 1.5rem; display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.table-search-wrap { position: relative; flex: 1; min-width: 200px; }
.table-search-wrap .search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke: var(--text-muted); stroke-width: 2; }
.table-search { width: 100%; padding: 0.5rem 2rem 0.5rem 2.3rem; background: var(--bg-surface); border: 1.5px solid transparent; border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.82rem; font-family: var(--font); outline: none; transition: all 0.2s; }
.table-search:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-glow); }
.search-clear-btn { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 0 0.25rem; line-height: 1; border-radius: 50%; transition: all 0.15s; }
.search-clear-btn:hover { color: var(--danger, #DC2626); background: rgba(220,38,38,0.08); }
.table-info { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.filter-select { padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); background: var(--bg-surface); border: 1.5px solid transparent; color: var(--text-primary); font-size: 0.82rem; font-family: var(--font); outline: none; transition: all 0.2s; cursor: pointer; }
.filter-select:focus { border-color: var(--accent); background: #fff; }
.data-table-wrap { overflow-x: auto; max-height: calc(100vh - 280px); overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table thead { position: sticky; top: 0; z-index: 2; }
.data-table th { text-align: left; padding: 0.8rem 1rem; background: var(--bg-surface); font-weight: 600; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 0.7rem 1rem; border-bottom: 1px solid #F1F5F9; color: var(--text-secondary); white-space: nowrap; }
.data-table tbody tr:hover td { background: rgba(59,130,246,0.02); }
.data-table tbody tr { cursor: pointer; transition: background 0.15s; }
.table-pagination { padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: center; gap: 0.3rem; border-top: 1px solid var(--border); }
.table-pagination button { width: 32px; height: 32px; border-radius: var(--radius-sm); background: transparent; border: 1.5px solid var(--border); color: var(--text-secondary); cursor: pointer; font-size: 0.8rem; font-family: var(--font); transition: all 0.2s; }
.table-pagination button:hover { border-color: var(--accent); color: var(--accent); }
.table-pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(59,130,246,0.2); }
.table-pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; z-index: 1500; background: rgba(15,23,42,0.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-card); border-radius: 20px; width: 90%; max-width: 720px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 25px 80px rgba(0,0,0,0.15); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { width: 30px; height: 30px; border-radius: var(--radius-sm); border: none; background: var(--bg-surface); color: var(--text-muted); cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; margin-bottom: 1.5rem; }
.modal-meta-item { }
.modal-meta-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.25rem; }
.modal-meta-value { font-size: 0.85rem; color: var(--text-primary); font-weight: 500; }
.modal-section-title { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ===== INLINE EDIT ===== */
.inline-input { padding: 0.35rem 0.6rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.78rem; font-family: var(--font); width: 110px; outline: none; transition: all 0.2s; background: var(--bg-surface); }
.inline-input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-glow); }

/* ===== ANIMATE ===== */
.animate-in { opacity: 0; transform: translateY(10px); animation: animIn 0.45s ease-out forwards; }
@keyframes animIn { to { opacity: 1; transform: translateY(0); } }
.animate-in:nth-child(2) { animation-delay: 0.05s; }
.animate-in:nth-child(3) { animation-delay: 0.1s; }
.animate-in:nth-child(4) { animation-delay: 0.15s; }
.animate-in:nth-child(5) { animation-delay: 0.2s; }
.animate-in:nth-child(6) { animation-delay: 0.25s; }
.animate-in:nth-child(7) { animation-delay: 0.3s; }
.animate-in:nth-child(8) { animation-delay: 0.35s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* Sidebar: off-canvas drawer */
    #sidebar { transform: translateX(-100%); position: fixed; width: 260px; }
    #sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,0.15); }
    #hamburger { display: flex; }
    .sidebar-toggle { display: none; }

    /* Main: full width */
    #main-content { margin-left: 0 !important; padding: 1rem 0.75rem 3rem; padding-top: 3.5rem; }

    /* KPIs */
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .kpi-card { padding: 0.85rem; gap: 0.5rem; }
    .kpi-value { font-size: 1.2rem; }
    .kpi-label { font-size: 0.65rem; }
    .kpi-icon-box { width: 34px; height: 34px; border-radius: 8px; }
    .kpi-icon-box svg { width: 16px; height: 16px; }
    .kpi-section-label { font-size: 0.8rem; margin-top: 0.5rem; }

    /* Charts */
    .chart-canvas-wrap { height: 220px; padding: 0.75rem; }
    .chart-header { padding: 0.85rem 1rem; }

    /* Tables */
    .table-toolbar { padding: 0.75rem; gap: 0.5rem; flex-direction: column; align-items: stretch; }
    .table-search-wrap { min-width: unset; }
    .data-table-wrap { max-height: 60vh; }
    .data-table th, .data-table td { padding: 0.5rem 0.6rem; font-size: 0.72rem; }
    .table-pagination { padding: 0.75rem; }
    .table-pagination button { width: 28px; height: 28px; font-size: 0.72rem; }
    .filter-select { font-size: 0.75rem; padding: 0.4rem 0.5rem; width: 100%; }

    /* Buttons */
    .btn { padding: 0.45rem 0.75rem; font-size: 0.75rem; gap: 0.35rem; }
    .btn svg { width: 13px; height: 13px; }

    /* Headers */
    .view-title { font-size: 1.1rem; }
    .header-actions { flex-direction: column; gap: 0.75rem; }
    .header-right { flex-wrap: wrap; gap: 0.4rem; }

    /* Global filters */
    .global-filter-bar { flex-direction: column; gap: 0.5rem; }
    .filter-panel { padding: 0.85rem; }
    .filter-panel-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }

    /* Modal */
    .modal { width: 95%; max-height: 90vh; border-radius: 16px; }
    .modal-body { padding: 1rem; }
    .modal-meta { grid-template-columns: 1fr; gap: 0.6rem; }
    .modal-actions { flex-direction: column; }
    .modal-actions .btn { flex: unset; }

    /* Mascot: hide on mobile */
    .mascot-float { display: none; }

    /* Inline inputs */
    .inline-date, .inline-input { width: 100px; font-size: 0.72rem; padding: 0.25rem 0.4rem; }
}

@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .filter-panel-grid { grid-template-columns: 1fr; }
    .login-container { padding: 2rem 1.5rem; }
    .login-title { font-size: 1.2rem; }
    #main-content { padding: 0.75rem 0.5rem 2rem; padding-top: 3.5rem; }
    /* Hide less-critical columns on small phones */
    #odcTable th:nth-child(1), #odcTable td:nth-child(1),   /* Checkbox */
    #odcTable th:nth-child(4), #odcTable td:nth-child(4),   /* F. Entrega */
    #odcTable th:nth-child(8), #odcTable td:nth-child(8),   /* Pavo */
    #odcTable th:nth-child(9), #odcTable td:nth-child(9),   /* Pierna */
    #odcTable th:nth-child(10), #odcTable td:nth-child(10), /* Hot Dog */
    #odcTable th:nth-child(12), #odcTable td:nth-child(12), /* Cajas */
    #odcTable th:nth-child(14), #odcTable td:nth-child(14), /* Lote */
    #odcTable th:nth-child(16), #odcTable td:nth-child(16)  /* Actions */
    { display: none; }
}

/* ===== GLOBAL FILTER PANEL ===== */
.global-filter-bar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.filter-toggle-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 1.1rem; border-radius: var(--radius-sm);
    font-size: 0.82rem; font-weight: 600; cursor: pointer;
    font-family: var(--font); transition: all 0.2s;
    border: 1.5px solid var(--border); background: var(--bg-card);
    color: var(--text-primary); position: relative;
}
.filter-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-toggle-btn.active { border-color: var(--accent); color: var(--accent); background: var(--info-bg); }
.filter-toggle-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.filter-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%; font-size: 0.62rem;
    font-weight: 700; background: var(--accent); color: white;
}

.filter-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem; box-shadow: var(--shadow-card);
    display: none; animation: fadeIn 0.25s ease-out;
}
.filter-panel.open { display: block; }
.filter-panel-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
    align-items: end;
}
.filter-field { display: flex; flex-direction: column; gap: 0.35rem; }
.filter-field label {
    font-size: 0.7rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
}
.filter-field select, .filter-field input[type="text"] {
    padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); background: var(--bg-surface);
    color: var(--text-primary); font-size: 0.82rem; font-family: var(--font);
    outline: none; transition: all 0.2s; cursor: pointer; width: 100%;
}
.filter-field select:focus, .filter-field input[type="text"]:focus {
    border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-glow);
}
.filter-active-tags {
    display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem;
}
.filter-tag {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.2rem 0.6rem; border-radius: 9999px;
    background: var(--info-bg); color: var(--accent);
    font-size: 0.72rem; font-weight: 600; cursor: pointer;
    transition: all 0.15s;
}
.filter-tag:hover { background: rgba(59,130,246,0.15); }
.filter-tag-x { font-size: 0.9rem; line-height: 1; }
@media (max-width: 900px) { .filter-panel-grid { grid-template-columns: repeat(2, 1fr); } }

/* Sortable headers */
.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable:hover { color: var(--accent); }
.sort-icon { font-size: 0.65rem; margin-left: 2px; color: var(--accent); vertical-align: middle; }

/* Inline date & text inputs in tables */
.inline-date, .inline-input {
    padding: 0.3rem 0.5rem; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); background: var(--bg-surface);
    font-family: var(--font); font-size: 0.78rem; outline: none;
    color: var(--text-primary); width: 130px; transition: border-color 0.15s;
}
.inline-date:focus, .inline-input:focus { border-color: var(--accent); }
.inline-date::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.5; }

/* Floating mascot */
.mascot-float {
    position: fixed; bottom: 16px; right: 24px; z-index: 50;
    pointer-events: none; opacity: 0.85;
}
.mascot-float img { width: 100px; }

/* ===== MULTI-SELECT FILTER ===== */
.ms-filter { position: relative; }
.ms-trigger {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.65rem; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); background: var(--bg-surface);
    color: var(--text-primary); font-size: 0.82rem; font-family: var(--font);
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.ms-trigger:hover { border-color: var(--accent); }
.ms-trigger.active { border-color: var(--accent); background: var(--info-bg); color: var(--accent); }
.ms-trigger svg { flex-shrink: 0; transition: transform 0.2s; }
.ms-filter.open .ms-trigger svg { transform: rotate(180deg); }
.ms-count {
    display: none; min-width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); color: white; font-size: 0.62rem; font-weight: 700;
    align-items: center; justify-content: center; line-height: 1;
}
.ms-count.visible { display: inline-flex; }
.ms-dropdown {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    min-width: 220px; max-height: 320px; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    z-index: 500; padding: 0.4rem 0; animation: fadeIn 0.15s ease-out;
}
.ms-filter.open .ms-dropdown { display: block; }
.ms-option {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 0.85rem; font-size: 0.8rem; color: var(--text-primary);
    cursor: pointer; transition: background 0.1s; user-select: none;
}
.ms-option:hover { background: var(--bg-surface); }
.ms-option input[type="checkbox"] {
    width: 15px; height: 15px; accent-color: var(--accent);
    cursor: pointer; flex-shrink: 0;
}
.ms-sort-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.35rem 0.85rem 0.45rem; border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}
.ms-sort-btn {
    font-size: 0.68rem; font-weight: 600; font-family: var(--font);
    padding: 0.2rem 0.5rem; border-radius: 6px;
    border: 1px solid var(--border); background: var(--bg-surface);
    color: var(--text-secondary); cursor: pointer; transition: all 0.15s;
}
.ms-sort-btn:hover { border-color: var(--accent); color: var(--accent); }
.ms-chips {
    display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0.5rem 0;
}
.ms-chip {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.15rem 0.5rem; border-radius: 9999px;
    background: var(--info-bg); color: var(--accent);
    font-size: 0.7rem; font-weight: 600; cursor: pointer;
    transition: all 0.15s;
}
.ms-chip:hover { background: rgba(59,130,246,0.15); }
.ms-chip-x { font-size: 0.85rem; line-height: 1; }

/* ===== FORMULA REFERENCE PANELS ===== */
.formula-panel {
    margin: 0.75rem 0 1rem; border-radius: var(--radius-sm);
    border: 1px dashed var(--border); background: var(--bg-surface);
    transition: all 0.2s;
}
.formula-panel[open] { border-style: solid; border-color: var(--accent); background: rgba(59,130,246,0.03); }
.formula-toggle {
    cursor: pointer; padding: 0.55rem 1rem;
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
    letter-spacing: 0.02em; list-style: none; user-select: none;
    display: flex; align-items: center; gap: 0.4rem;
}
.formula-toggle::-webkit-details-marker { display: none; }
.formula-toggle::after {
    content: '▸'; font-size: 0.65rem; transition: transform 0.2s;
    margin-left: auto;
}
.formula-panel[open] .formula-toggle::after { transform: rotate(90deg); }
.formula-panel[open] .formula-toggle { color: var(--accent); border-bottom: 1px solid var(--border); }
.formula-content { padding: 0.65rem 1rem 0.75rem; }
.formula-item {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem;
    padding: 0.35rem 0; border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 0.73rem; line-height: 1.5;
}
.formula-item:last-child { border-bottom: none; }
.formula-name {
    font-weight: 700; color: var(--text-primary);
    min-width: 140px; flex-shrink: 0;
}
.formula-item code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.68rem; font-weight: 500;
    background: rgba(59,130,246,0.08); color: var(--accent);
    padding: 0.15rem 0.5rem; border-radius: 4px;
    white-space: nowrap;
}
.formula-desc {
    color: var(--text-muted); font-size: 0.68rem; font-style: italic;
    flex-basis: 100%; padding-left: 140px; margin-top: -0.1rem;
}

/* ===== ALERTS BANNER ===== */
.alerts-banner {
    margin: 0.75rem 0 0.5rem; display: flex; flex-direction: column; gap: 0.4rem;
}
.alert-item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.6rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.78rem; font-weight: 500; line-height: 1.4;
    animation: alertSlide 0.3s ease-out;
}
@keyframes alertSlide { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
.alert-danger {
    background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25);
    color: #dc2626;
}
.alert-warning {
    background: rgba(234,179,8,0.08); border: 1px solid rgba(234,179,8,0.25);
    color: #b45309;
}
.alert-icon { font-size: 1rem; flex-shrink: 0; }
.alert-msg { flex: 1; }

