:root {
    --bg-body: #f8fafc;
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: #0284c7;
    --text-dark: #0f172a;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --border-light: #e2e8f0;
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --radius: 10px;
    --header-height: 60px;
    --footer-height: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Plus Jakarta Sans', sans-serif; }
html, body { height: 100vh; overflow: hidden; background-color: var(--bg-body); color: var(--text-main); font-size: 0.85rem; }
.app-layout { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* Sidebar & Accordion Styling */
.sidebar { width: 270px; background: var(--sidebar-bg); color: #94a3b8; display: flex; flex-direction: column; flex-shrink: 0; height: 100vh; border-right: 1px solid #1e293b; z-index: 100; transition: transform 0.25s ease; }
.sidebar .brand { padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar .brand h2 { font-size: 1.1rem; color: #ffffff; font-weight: 800; letter-spacing: -0.02em; }
.sidebar .brand small { color: #38bdf8; font-size: 0.725rem; font-weight: 700; }

.sidebar-menu { flex: 1; overflow-y: auto; padding: 0.75rem 0.5rem; }

.menu-group-header { font-size: 0.65rem; text-transform: uppercase; color: #64748b; margin: 1rem 0 0.2rem 0.5rem; padding: 0.4rem 0.5rem; letter-spacing: 0.08em; font-weight: 800; cursor: pointer; display: flex; justify-content: space-between; align-items: center; user-select: none; border-radius: 4px; transition: color 0.15s; }
.menu-group-header:hover { color: #f8fafc; }
.menu-group-header .chevron { font-size: 0.6rem; transition: transform 0.2s ease; }
.menu-group-header.collapsed .chevron { transform: rotate(-90deg); }

.menu-group-items { display: none; padding-left: 0.2rem; }
.menu-group-items.show { display: block; }

.nav-link { color: #94a3b8; text-decoration: none; padding: 0.55rem 0.75rem; border-radius: 6px; font-size: 0.775rem; font-weight: 600; display: flex; align-items: center; gap: 10px; transition: all 0.15s ease; margin-bottom: 2px; }
.nav-link:hover { background: var(--sidebar-hover); color: #ffffff; }
.nav-link.active { background: var(--sidebar-active); color: #ffffff; font-weight: 700; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3); }

/* Main Layout */
.main-wrapper { flex: 1; display: flex; flex-direction: column; height: 100vh; min-width: 0; overflow: hidden; }
.top-header { height: var(--header-height); background: #ffffff; padding: 0 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.header-left, .header-right { display: flex; align-items: center; gap: 1rem; }

.mobile-toggle-btn { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-dark); }
.user-profile { display: flex; align-items: center; gap: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #e0f2fe; color: #0284c7; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; border: 1px solid #bae6fd; }

.content-container { flex: 1; overflow-y: auto; padding: 1.5rem; background: var(--bg-body); position: relative; }
.content-container.loading { opacity: 0.4; pointer-events: none; }

.app-footer { height: var(--footer-height); background: #ffffff; border-top: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; font-size: 0.775rem; color: var(--text-muted); flex-shrink: 0; }

/* UI Cards & Tables */
.card { background: #ffffff; border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,0.02); padding: 1.25rem; margin-bottom: 1rem; }
.card-error { border-left: 4px solid #ef4444; }
.card-header-flex { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 1rem; }
.page-title { font-size: 1.15rem; font-weight: 800; color: var(--text-dark); letter-spacing: -0.02em; }
.page-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.1rem; }
.text-danger { color: #dc2626 !important; }

.table-responsive { width: 100%; overflow-x: auto; border: 1px solid var(--border-light); border-radius: var(--radius); background: #ffffff; }
table.table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.825rem; }
table.table th { background: #f8fafc; padding: 0.75rem 1rem; font-weight: 700; color: #475569; border-bottom: 1px solid var(--border-light); text-transform: uppercase; font-size: 0.7rem; }
table.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-light); color: var(--text-main); }
table.table tbody tr:hover { background: #f8fafc; }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-weight: 700; margin-bottom: 0.4rem; color: var(--text-dark); font-size: 0.775rem; }
.form-control { width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.825rem; outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0.55rem 1.1rem; font-size: 0.8rem; font-weight: 700; border-radius: 6px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }
.btn-outline { background: #ffffff; border-color: var(--border-color); color: #334155; }
.btn-danger { background: #ef4444; color: #ffffff; }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.7rem; font-weight: 700; }
.badge-primary { background: #e0f2fe; color: #0369a1; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }

.pagination-wrapper { display: flex; justify-content: space-between; align-items: center; margin-top: 1.25rem; }
.pagination { display: flex; list-style: none; gap: 4px; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--border-light); background: #ffffff; color: #334155; text-decoration: none; font-weight: 600; font-size: 0.775rem; }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #ffffff; }

#spa-loader { position: fixed; top: 0; left: 0; width: 0%; height: 3px; background: #38bdf8; z-index: 9999; transition: width 0.2s ease; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 90; }

@media (max-width: 768px) {
    .mobile-toggle-btn { display: block; }
    .user-name, .system-title { display: none; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .grid-2, .grid-4 { grid-template-columns: 1fr; }
}