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

:root {
    --primary: #1f4e78;
    --primary-dark: #163a5c;
    --primary-light: #e8f0f7;
    --accent: #2e75b6;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1a202c;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --success-bg: #d1fae5;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 12px rgba(0,0,0,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.brand-logo {
    width: 40px; height: 40px;
    background: #fff;
    color: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 20px;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; opacity: 0.7; }

.nav { padding: 16px 12px; flex: 1; }
.nav-section {
    padding: 16px 12px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.6;
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 2px;
    transition: all 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 600; }
.ico { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-card {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 10px;
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; opacity: 0.7; }
.logout-btn {
    display: block; text-align: center;
    padding: 8px; color: #fff;
    background: rgba(255,255,255,0.1);
    border-radius: 6px; text-decoration: none;
    font-size: 13px;
}
.logout-btn:hover { background: rgba(255,255,255,0.2); }

.main { margin-left: 260px; flex: 1; min-width: 0; }

.topbar {
    background: var(--surface);
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.content { padding: 24px 32px; }

/* ===== COMPONENTS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: var(--success-bg); color: #065f46; border-left: 3px solid var(--success); }
.alert-error { background: var(--error-bg); color: #991b1b; border-left: 3px solid var(--error); }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--error); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; background: #fff; border-radius: 10px; border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: #fafbfc; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1/-1; }
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    transition: border 0.15s, box-shadow 0.15s;
    background: #fff;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(46,117,182,0.1);
}
.form-textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-error { background: var(--error-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-default { background: #f1f5f9; color: #475569; }

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo {
    width: 60px; height: 60px;
    background: var(--primary);
    color: #fff;
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 800;
    margin-bottom: 12px;
}
.login-title { font-size: 22px; font-weight: 700; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-box .btn { width: 100%; padding: 11px; font-size: 14px; }

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 48px; opacity: 0.3; margin-bottom: 12px; }

.page-action .btn + .btn { margin-left: 8px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.search-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    min-width: 240px;
}

.actions-cell { white-space: nowrap; }
.actions-cell a { margin-right: 8px; color: var(--accent); text-decoration: none; font-size: 13px; }
.actions-cell a:hover { text-decoration: underline; }
.actions-cell a.del { color: var(--error); }

@media (max-width: 768px) {
    .sidebar { width: 220px; }
    .main { margin-left: 220px; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .topbar { padding: 16px; }
}
