:root {
    --primary: #1e3a8a;
    --primary-dark: #0f172a;
    --primary-light: #3b82f6;
    --accent: #2563eb;
    --bg-body: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --sidebar-w: 260px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
    --transition: all 0.25s ease-in-out;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
}

.app-wrapper { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background-color: var(--primary-dark);
    color: #f8fafc;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo i { color: var(--primary-light); }

.sidebar-nav {
    list-style: none;
    padding: 1.25rem 0.75rem;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-item { margin-bottom: 0.25rem; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link i { font-size: 1.1rem; width: 20px; }

.nav-link:hover, .nav-link.active {
    background-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.nav-link.active { background-color: var(--accent); color: #ffffff; }

.main-wrapper {
    flex-grow: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: var(--transition);
}

.topbar {
    height: 70px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.menu-toggle {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
    display: none;
}

.user-badge { display: flex; align-items: center; gap: 0.75rem; }

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-meta { font-size: 0.875rem; }
.user-meta .name { font-weight: 600; color: var(--text-main); }
.user-meta .role { font-size: 0.75rem; color: var(--text-muted); }

.content-area { padding: 2rem; flex-grow: 1; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 1px solid var(--border);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background-color: #eff6ff; color: var(--accent); }
.stat-icon.green { background-color: #ecfdf5; color: var(--success); }
.stat-icon.amber { background-color: #fffbeb; color: var(--warning); }
.stat-icon.purple { background-color: #faf5ff; color: #8b5cf6; }

.stat-info h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.stat-info .count {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.25rem;
}

.card {
    background-color: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title { font-size: 1.1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }

.filter-card {
    background-color: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1 1 200px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
    background-color: #fff;
    width: 100%;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-control { min-height: 120px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.btn-primary { background-color: var(--accent); color: #fff; }
.btn-primary:hover { background-color: #1d4ed8; }
.btn-secondary { background-color: #e2e8f0; color: var(--text-main); }
.btn-secondary:hover { background-color: #cbd5e1; }
.btn-danger { background-color: var(--danger); color: #fff; }
.btn-danger:hover { background-color: #dc2626; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.table-responsive { width: 100%; overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; text-align: left; }

.data-table th, .data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table th {
    background-color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover { background-color: #f8fafc; }

.img-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: #fff;
}

.badge {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px;
    display: inline-block;
}

.badge-active { background-color: #dcfce7; color: #15803d; }
.badge-inactive { background-color: #fee2e2; color: #b91c1c; }

.image-preview-wrapper {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preview-box {
    width: 140px;
    height: 140px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    overflow: hidden;
}

.preview-box img { width: 100%; height: 100%; object-fit: cover; display: none; }

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
}

.pagination-links { display: flex; gap: 0.4rem; }

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}

.page-link:hover, .page-link.active {
    background-color: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.toast-container { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 1000; }

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    background-color: #fff;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out forwards;
}

.toast.success { border-left-color: var(--success); color: #065f46; }
.toast.error { border-left-color: var(--danger); color: #991b1b; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: #fff;
    width: 90%;
    max-width: 440px;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.modal-header { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.5rem; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.auth-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    padding: 1.5rem;
}

.auth-card {
    background: #fff;
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.auth-card .brand {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: block; }
}

@media (max-width: 640px) {
    .content-area { padding: 1rem; }
    .filter-form { flex-direction: column; }
    .form-group { width: 100%; }
}