:root {
    /* Color Palette */
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    /* Semantic Colors */
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Layout Sizes */
    --sidebar-width: 280px;
    --topbar-height: 72px;
}

/* Base Reset */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, -apple-system, sans-serif; }
body { background-color: var(--bg); color: var(--text-main); line-height: 1.6; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.main-viewport { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow-y: auto; }

/* Top Bar */
.top-bar { height: var(--topbar-height); background: white; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 2.5rem; flex-shrink: 0; position: sticky; top: 0; z-index: 50; }
.breadcrumb { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.875rem; }
.breadcrumb .active { color: var(--text-main); font-weight: 600; }
.top-bar-actions { display: flex; align-items: center; gap: 1.5rem; }
.user-profile { display: flex; align-items: center; gap: 0.75rem; padding-left: 1.5rem; border-left: 1px solid var(--border); }
.user-info { text-align: right; }
.user-name { font-size: 0.875rem; font-weight: 700; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }
.avatar { width: 40px; height: 40px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; }

/* Sidebar */
.sidebar { width: 280px; background-color: var(--primary); color: white; padding: 2rem 1.25rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-logo-container { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2.5rem; padding-left: 0.5rem; }
.sidebar-logo { width: 32px; height: 32px; padding: 2px; background: #fff; }
.sidebar-brand { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.025em; }
.nav-group-label { color: #64748b; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; margin: 2rem 0 1rem; padding-left: 1rem; }
.nav-group-label:first-of-type { margin-top: 0; }
.nav-link { display: flex; align-items: center; gap: 0.875rem; padding: 0.75rem 1rem; color: #94a3b8; text-decoration: none; border-radius: 0.5rem; font-size: 0.9375rem; font-weight: 500; transition: var(--transition); }
.nav-link:hover, .nav-link.active { background-color: rgba(255, 255, 255, 0.05); color: white; }
.nav-link i { width: 20px; height: 20px; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.05); padding-top: 1.5rem; margin-top: auto; }

/* Grid & Cards */
.content-area { padding: 1rem; flex: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-bottom: 2.5rem; }
.card { 
    background: var(--card-bg); 
    border-radius: 1rem; 
    padding: 2rem; 
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); 
    border: 1px solid var(--border); 
    transition: var(--transition); 
}
.card:hover { 
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); 
}
.card-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 2rem; 
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}
.card-title { 
    font-size: 1.125rem; 
    font-weight: 700; 
    color: var(--text-main);
    letter-spacing: -0.025em;
}

/* Stat Components */
.stat-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.stat-badge { font-size: 0.75rem; font-weight: 700; padding: 0.25rem 0.5rem; border-radius: 20px; }
.stat-label { color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }
.stat-value { font-size: 1.875rem; font-weight: 800; color: var(--text-main); }

/* Activity Items */
.activity-list { display: flex; flex-direction: column; gap: 1rem; }
.activity-item { display: flex; align-items: center; gap: 1rem; padding: 1rem; border-radius: 0.75rem; background: #f8fafc; border: 1px solid transparent; transition: var(--transition); cursor: pointer; }
.activity-item:hover { border-color: var(--border); background: white; }
.activity-icon-box { width: 40px; height: 40px; background: white; border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.activity-content { flex: 1; font-size: 0.875rem; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); }

/* Split-Screen Auth Layout */
.auth-split-container {
    display: flex;
    min-height: 100vh;
    background: white;
}

.auth-branding-panel {
    flex: 1.2;
    background: url('../img/login_bg.png') center/cover no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4rem;
    position: relative;
    color: white;
}

.auth-branding-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.4), rgba(15, 23, 42, 0.8));
}

.auth-branding-content {
    position: relative;
    z-index: 1;
}

.auth-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
}

.auth-form-container {
    width: 100%;
    max-width: 400px;
}

@media (max-width: 1024px) {
    .auth-branding-panel { display: none; }
}

/* Form Components */
.input-group { margin-bottom: 1.5rem; }
.label { 
    display: block; 
    font-size: 0.75rem; 
    font-weight: 700; 
    margin-bottom: 0.625rem; 
    color: var(--text-muted); 
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.input { 
    width: 100%; 
    padding: 0.75rem 1rem; 
    border: 1px solid #e2e8f0; 
    border-radius: 0.75rem; 
    font-size: 0.9375rem; 
    transition: var(--transition); 
    background: #fff;
    color: var(--text-main);
}
.input:focus { 
    outline: none; 
    border-color: var(--accent); 
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1); 
    background: #fff;
}
.auth-input { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); color: white; }
.btn { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    padding: 0.75rem 1.5rem; 
    border-radius: 0.75rem; 
    font-weight: 700; 
    cursor: pointer; 
    transition: var(--transition); 
    gap: 0.75rem; 
    border: none;
    font-size: 0.875rem;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.message { margin-top: 1.5rem; padding: 1rem; border-radius: 0.5rem; font-size: 0.875rem; }

/* Utilities & Spacing */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.mt-auto { margin-top: auto; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mt-10 { margin-top: 2.5rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Page Headers */
.page-header { margin-bottom: 1rem; }
.page-subtitle { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    color: var(--accent); 
    font-weight: 700; 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 0.1em; 
    margin-bottom: 0.5rem; 
}
.page-title-lg { font-size: 1.75rem; margin-bottom: 0.5rem; letter-spacing: -0.025em; }

/* Identifier Badge */
.id-badge { 
    font-family: monospace; 
    font-weight: 700; 
    color: var(--accent); 
    background: rgba(99, 102, 241, 0.1); 
    padding: 0.2rem 0.5rem; 
    border-radius: 0.4rem; 
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}


/* Photo Management */
.photo-upload-box {
    width: 160px;
    height: 160px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 1.5rem;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    transition: var(--transition);
}
.photo-upload-box img { width: 100%; height: 100%; object-fit: cover; }

/* Filter Bar */
.filter-card {
    display: grid;
    grid-template-columns: 1.5fr 1fr auto;
    gap: 1.5rem;
    align-items: flex-end;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0; /* Align with input-group mb-0 */
}

/* Layout Elements */
.dashboard-grid { display: block; }
.responsive-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.col-stack { display: flex; flex-direction: column; gap: 2rem; }

/* Form Actions */
.form-actions {
    margin-top: 3rem;
    display: flex;
    justify-content: flex-end;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
}

.btn-lg { padding: 1rem 3rem; font-size: 1rem; }
.btn-white { background: white; border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text-main); }
.btn-white:hover { background: #f8fafc; }

/* Responsive Table */
.table-container { 
    width: 100%; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .responsive-table thead { display: none; }
    .responsive-table tr { 
        display: block; 
        padding: 1.25rem; 
        border-bottom: 8px solid var(--bg) !important; 
    }
    .responsive-table td { 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        padding: 0.75rem 0 !important; 
        border: none !important;
        text-align: right !important;
    }
    .responsive-table td::before { 
        content: attr(data-label); 
        font-weight: 700; 
        color: var(--text-muted); 
        font-size: 0.75rem; 
        text-transform: uppercase;
        text-align: left;
    }
    .responsive-table td:first-child { 
        flex-direction: column; 
        align-items: flex-start; 
        padding-top: 0 !important;
    }
    .responsive-table td:first-child::before { margin-bottom: 0.5rem; }
    .responsive-table td .btn { width: auto; }
}

/* Responsive Overrides */
@media (max-width: 992px) {
    .sidebar {
        width: var(--sidebar-width);
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        z-index: 1000;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0,0,0,0.2);
    }
    body.sidebar-open .sidebar { transform: translateX(var(--sidebar-width)); }
    body.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        z-index: 999;
    }

    .top-bar { padding: 0 1rem; height: 64px; }
    .breadcrumb, .user-info { display: none; }
    .content-area { padding: 0.5rem; }
    
    .dashboard-grid, .responsive-grid, .filter-card { grid-template-columns: 1fr !important; gap: 1rem; }
    .col-stack { gap: 1rem; }
    
    .page-header { flex-direction: column; align-items: stretch; gap: 1rem; }
    .page-header .btn { width: 100%; }
    .page-title-lg { font-size: 1.5rem; }
    
    .card { padding: 1.25rem; border-radius: 0.75rem; }
    .card-header { flex-direction: row; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; padding-bottom: 0.75rem; }
    
    .filter-card .label:empty, .filter-card .label:has(br) { display: none; }
    .filter-card .input-group:last-child .label { display: none; }

    .form-actions, .filter-actions { flex-direction: column; gap: 0.75rem; margin-top: 2rem; }
    .form-actions .btn, .filter-actions .btn { width: 100%; }
    .btn { width: 100%; justify-content: center; }
    
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
    .stat-value { font-size: 1.5rem; }
    .stat-icon { width: 40px; height: 40px; }
    
    .activity-item { padding: 0.75rem; }
    .activity-time { font-size: 0.65rem; }
    
    .sidebar { padding: 1.5rem 1rem; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .auth-form-panel { padding: 1.5rem; }
    .page-title-lg { font-size: 1.25rem; }
}

/* Pagination */
.pagination { 
    display: flex; 
    justify-content: center; 
    gap: 0.5rem; 
    margin-top: 2.5rem; 
}
.page-link { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 40px; 
    height: 40px; 
    border-radius: 0.5rem; 
    background: white; 
    border: 1px solid var(--border); 
    color: var(--text-main); 
    text-decoration: none; 
    font-weight: 600; 
    transition: var(--transition); 
}
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-link.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-link.disabled { opacity: 0.5; pointer-events: none; background: #f8fafc; }

@media (max-width: 992px) {
    .pagination { gap: 0.25rem; }
    .page-link { width: 32px; height: 32px; font-size: 0.75rem; }
}

/* Hamburger Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 0.5rem;
    margin-right: 1rem;
}

@media (max-width: 992px) {
    .menu-toggle { display: block; }
}

.close-sidebar-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    margin-left: auto;
}

@media (max-width: 992px) {
    .close-sidebar-btn { display: block; }
}
