/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e1e4e8;
    --text: #24292e;
    --text-muted: #586069;
    --primary: #0366d6;
    --primary-hover: #0256b9;
    --danger: #d73a49;
    --success: #28a745;
    --warning: #f0ad4e;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}
html, body { font-family: -apple-system, BlazorWebAssembly, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #1b1f23; color: #c9d1d9; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { padding: 20px; font-size: 18px; font-weight: 700; color: #fff; border-bottom: 1px solid #30363d; }
.sidebar-brand span { color: var(--primary); }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar a, .sidebar .nav-section { display: block; padding: 8px 20px; color: #c9d1d9; font-size: 13px; transition: background 0.15s; }
.sidebar a:hover, .sidebar a.active { background: #30363d; color: #fff; text-decoration: none; }
.sidebar a.active { border-left: 3px solid var(--primary); padding-left: 17px; }
.sidebar .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #8b949e; margin-top: 16px; cursor: default; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid #30363d; font-size: 12px; }
.sidebar-footer button { background: none; border: none; color: #c9d1d9; cursor: pointer; font-size: 12px; }
.sidebar-footer button:hover { color: #fff; }

.main-content { flex: 1; padding: 24px 32px; overflow-y: auto; }

/* ── Page Header ─────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-header p { color: var(--text-muted); margin-top: 4px; }

/* ── Cards ────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { font-size: 16px; font-weight: 600; }

/* ── Tables ───────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); background: #fafbfc; }
tr:hover td { background: #f6f8fa; }

/* ── Forms ────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; background: var(--surface); color: var(--text);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(3,102,214,0.15); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ── Buttons ──────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; background: var(--surface); color: var(--text); }
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn + .btn { margin-left: 6px; }

/* ── Badges ───────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-success { background: #dcffe4; color: #22863a; }
.badge-warning { background: #fff8c5; color: #856d0a; }
.badge-danger { background: #ffeef0; color: #d73a49; }
.badge-info { background: #dbedff; color: #0366d6; }
.badge-muted { background: #f1f3f5; color: var(--text-muted); }

/* ── Alerts ───────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: #ffeef0; color: #d73a49; border: 1px solid #fdaeb7; }
.alert-success { background: #dcffe4; color: #22863a; border: 1px solid #a3f5b8; }
.alert-info { background: #dbedff; color: #0366d6; border: 1px solid #79b8ff; }

/* ── Login Page ───────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-box { width: 360px; }
.login-box h1 { text-align: center; margin-bottom: 24px; font-size: 24px; }
.login-box h1 span { color: var(--primary); }

/* ── Loading ──────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; min-height: 100vh; color: var(--text-muted); font-size: 16px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stats Grid ───────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

/* ── Empty State ──────────────────────────────── */
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Modal/Dialog ─────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--surface); border-radius: 8px; padding: 24px; width: 520px; max-width: 90vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,0.12); }
.modal h2 { margin-bottom: 16px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .main-content { padding: 16px; }
    .form-row { flex-direction: column; }
}
