:root {
    --primary:       #4f46e5;
    --primary-dark:  #4338ca;
    --sidebar-bg:    #1e293b;
    --sidebar-text:  #94a3b8;
    --sidebar-hover: #334155;
    --bg:            #f1f5f9;
    --white:         #ffffff;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --border:        #e2e8f0;
    --danger:        #ef4444;
    --danger-dark:   #dc2626;
    --success:       #22c55e;
    --radius:        8px;
}

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

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

/* ── Login page ── */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.login-card .subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.75rem;
}

/* ── App layout ── */
body.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: .05em;
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid #334155;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid #334155;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    display: block;
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: background .15s, color .15s;
}

.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-user { color: var(--sidebar-text); font-size: 0.8125rem; padding: 0 0.75rem; }
.nav-logout { color: #f87171; }
.nav-logout:hover { background: #450a0a; color: #fca5a5; }

.content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 960px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    background: var(--white);
    color: var(--text);
    transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.125rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: var(--danger-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8125rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* ── Table ── */
.table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }
th {
    background: var(--bg);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9375rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.actions { display: flex; gap: 0.5rem; }

/* ── Badge ── */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-user  { background: #e0f2fe; color: #0369a1; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* ── Card ── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ── App grid ── */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.app-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    font-size: .9375rem;
    transition: box-shadow .15s, transform .15s;
}

.app-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    transform: translateY(-2px);
}

.app-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    font-weight: 700;
    color: #fff;
}

.app-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Toolbar ── */
.toolbar {
