:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f4f5fb;
    --sidebar-bg: #111827;
    --sidebar-text: #cbd5e1;
    --success: #16a34a;
    --error: #dc2626;
    --muted: #9ca3af;
    --border: #e5e7eb;
    --text: #1f2937;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ---------- Auth pages ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5, #111827);
}
.auth-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 20px 40px rgba(0,0,0,.2);
    text-align: center;
}
.auth-logo { margin: 0 0 20px; font-size: 24px; }
.auth-logo span { color: var(--primary); }
.auth-box form { text-align: left; }
.auth-box label { display:block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; }
.auth-box input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px;
}
.auth-hint { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 230px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar-brand {
    font-size: 20px; font-weight: 700; color: #fff;
    padding: 0 20px 20px; border-bottom: 1px solid #1f2937;
}
.sidebar-brand span { color: var(--primary); }
.app-sidebar nav { display: flex; flex-direction: column; margin-top: 10px; }
.nav-section {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: #6b7280; padding: 16px 20px 6px;
}
.nav-item {
    padding: 10px 20px; color: var(--sidebar-text); text-decoration: none;
    font-size: 14px; cursor: pointer;
}
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item.disabled { color: #4b5563; cursor: not-allowed; }
.nav-item.disabled:hover { background: none; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 14px 24px; display: flex; justify-content: space-between; align-items: center;
}
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.app-content { padding: 24px; }

/* ---------- Components ---------- */
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: #fff; border-radius: 12px; padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; }

.panel {
    background: #fff; border-radius: 12px; padding: 20px 24px;
    margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.panel h3 { margin-top: 0; }

.btn {
    display: inline-block; background: var(--primary); color: #fff;
    padding: 10px 18px; border: none; border-radius: 8px; font-size: 14px;
    cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn-block { width: 100%; margin-top: 16px; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: underline; padding:0; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

.badge {
    font-size: 11px; padding: 3px 8px; border-radius: 999px;
    background: #e0e7ff; color: var(--primary-dark); font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: #f3f4f6; color: #6b7280; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-group-wide { grid-column: 1 / -1; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }
.form-group input, .form-group select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.form-actions { grid-column: 1 / -1; margin-top: 8px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 12px; text-transform: uppercase; color: var(--muted); }
.text-muted { color: var(--muted); font-size: 13px; }

@media (max-width: 768px) {
    .app-sidebar { display: none; }
    .app-content { padding: 16px; }
}
