:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --border: #dde1e6;
    --text: #1c1f24;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
    font-size: 15px;
}

* { box-sizing: border-box; }

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

[hidden] { display: none !important; }

.center-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 320px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.login-card h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.login-card p.subtitle {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 20px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 12px 0 4px;
}

input, select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}

button {
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 8px 14px;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    margin-top: 18px;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
    margin-right: 6px;
    margin-bottom: 4px;
}
.btn-ghost { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: #f0f1f3; }
.btn-danger { background: #fff; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-success { background: #fff; border: 1px solid var(--success); color: var(--success); }
.btn-success:hover { background: #f0fdf4; }

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
    min-height: 16px;
}

.app-shell { display: none; min-height: 100vh; }
.app-shell.visible { display: flex; }

.sidebar {
    width: 220px;
    background: #111827;
    color: #e5e7eb;
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar .brand {
    font-weight: 700;
    padding: 0 20px 16px;
    border-bottom: 1px solid #1f2937;
    margin-bottom: 12px;
}
.sidebar .role-badge {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    display: block;
    margin-top: 2px;
}
.nav-item {
    display: block;
    padding: 10px 20px;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: #1f2937; }
.nav-item.active {
    background: #1f2937;
    color: #fff;
    border-left-color: var(--primary);
}
.nav-item.logout { margin-top: 20px; color: #f87171; }

.main {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
}
.main h2 { margin-top: 0; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}
.panel h3 {
    margin-top: 0;
    font-size: 15px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}
.inline-form .field { flex: 1; min-width: 140px; }
.inline-form label { margin: 0 0 4px; }
.inline-form button { height: 37px; }

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

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge.active, .badge.approved { background: #ecfdf5; color: var(--success); }
.badge.disabled, .badge.rejected { background: #fef2f2; color: var(--danger); }
.badge.pending, .badge.pending_deletion { background: #fffbeb; color: var(--warn); }
.badge.admin { background: #eef2ff; color: #4338ca; }
.badge.user { background: #f1f5f9; color: #334155; }

.empty-row td { color: var(--muted); text-align: center; padding: 20px; }

.toast {
    position: fixed;
    top: 16px;
    right: 16px;
    background: #111827;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 50;
}
.toast.error { background: var(--danger); }

dialog {
    border: none;
    border-radius: 10px;
    padding: 0;
    width: 340px;
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
.dialog-body { padding: 20px; }
.dialog-body h3 { margin-top: 0; }
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
