/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #2563eb;
    --primary-dk: #1d4ed8;
    --danger:     #dc2626;
    --warning:    #d97706;
    --success:    #16a34a;
    --muted:      #6b7280;
    --border:     #e5e7eb;
    --bg:         #f9fafb;
    --surface:    #ffffff;
    --text:       #111827;
    --text-sm:    #374151;
    --nav-bg:     #1e293b;
    --nav-text:   #cbd5e1;
    --nav-active: #ffffff;
    --radius:     6px;
    --shadow:     0 1px 3px rgba(0,0,0,.1);
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-nav { flex: 1; padding: .5rem 0; }

.sidebar-nav a {
    display: block;
    padding: .55rem 1rem;
    color: var(--nav-text);
    font-size: .875rem;
    border-radius: 0;
    transition: background .15s;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.1);
    color: var(--nav-active);
    text-decoration: none;
}
.sidebar-nav .nav-section {
    padding: .75rem 1rem .25rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
}

.sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8rem;
}
.sidebar-footer a { color: var(--nav-text); }

.main-area {
    margin-left: 220px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

.topbar h1 { font-size: 1.1rem; font-weight: 600; }

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}
.stat-card .stat-label {
    font-size: .8rem;
    color: var(--muted);
    margin-top: .25rem;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    padding: .5rem .75rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
tbody td {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:hover { background: #f1f5f9; }

/* ── Badges / Pills ───────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.4;
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-muted    { background: #f1f5f9; color: #475569; }
.badge-primary  { background: #dbeafe; color: #1e40af; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .9rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); text-decoration: none; color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-outline  { background: transparent; color: var(--text-sm); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); text-decoration: none; }
.btn-sm       { padding: .3rem .65rem; font-size: .8rem; }
.btn-xs       { padding: .2rem .5rem; font-size: .75rem; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .3rem;
}
.form-control {
    width: 100%;
    padding: .45rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea.form-control { resize: vertical; min-height: 120px; }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    border-left: 4px solid transparent;
}
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-error   { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: var(--warning);  color: #92400e; }
.alert-info    { background: #eff6ff; border-color: var(--primary);  color: #1e40af; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: .25rem; align-items: center; margin-top: 1rem; }
.pagination a, .pagination span {
    padding: .3rem .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .8rem;
    color: var(--text-sm);
}
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Login page ───────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}
.login-box h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* ── Misc ─────────────────────────────────────────────────── */
.actions { display: flex; gap: .4rem; align-items: center; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.tag-pill {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    margin: .1rem;
}
