:root {
    --bg: #14121a;
    --surface: #1d1a26;
    --surface-2: #262234;
    --ink: #ece9f2;
    --ink-dim: #9b95ad;
    --ink-faint: #6c6780;
    --line: #332e42;
    --accent: #b5179e;
    --accent-hi: #e85bd0;
    --danger: #e5484d;
    --ok: #46a758;
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--accent-hi); }
button { font: inherit; }
input, select { font: inherit; }
@media (max-width: 720px) { input, select, button { font-size: 16px; } }   /* iOS-Zoom vermeiden */

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: var(--accent); color: #fff; border: none;
    padding: 0.5rem 0.9rem; border-radius: var(--radius-sm);
    cursor: pointer; font-weight: 600;
    transition: background 0.12s, opacity 0.12s;
}
.btn:hover { background: var(--accent-hi); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: rgba(229,72,77,0.12); }
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.82rem; }

/* ---------- Inputs ---------- */
label { display: block; font-size: 0.85rem; color: var(--ink-dim); margin-bottom: 0.25rem; }
.field { margin-bottom: 0.9rem; }
input[type=text], input[type=password], input[type=email], select {
    width: 100%; background: var(--bg); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 0.5rem 0.7rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
    width: 100%; max-width: 360px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.8rem;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.login-card h1 { margin: 0 0 0.2rem; font-size: 1.3rem; }
.login-card .sub { margin: 0 0 1.4rem; color: var(--ink-dim); font-size: 0.9rem; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 0.4rem; }

.alert { color: var(--danger); font-size: 0.86rem; min-height: 1.2em; margin-top: 0.6rem; }
.alert.ok { color: var(--ok); }

/* ---------- Admin layout ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.8rem 1.4rem; background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 800; letter-spacing: 0.02em; }
.topbar .who { color: var(--ink-dim); font-size: 0.88rem; margin-right: 0.8rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1.4rem; }
section.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.4rem;
}
section.card > h2 { margin: 0 0 1rem; font-size: 1.05rem; }

/* ---------- Tabelle ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(255,255,255,0.02); }
.muted { color: var(--ink-faint); }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ---------- Chips (Rollen + Gruppen) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 999px; padding: 0.12rem 0.55rem; font-size: 0.78rem;
}
.chip.role { border-color: var(--accent); color: var(--accent-hi); }
.chip.locked { color: var(--danger); border-color: var(--danger); }
.chip.bit { color: var(--ink-faint); font-size: 0.7rem; }

/* ---------- Inline-Form (neuer User / Gruppen) ---------- */
.row { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-end; }
.row .field { margin-bottom: 0; flex: 1 1 160px; }
.checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.checks label { display: flex; align-items: center; gap: 0.4rem; color: var(--ink); margin: 0; cursor: pointer; }
.checks input { width: auto; }

/* ---------- Gruppen-Editor pro User (aufklappbar) ---------- */
.group-editor { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.8rem; margin-top: 0.5rem; }
.group-editor .hint { color: var(--ink-faint); font-size: 0.78rem; margin: 0 0 0.5rem; }
.hidden { display: none !important; }

/* ---------- Toast ---------- */
#toast {
    position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
    padding: 0.6rem 1rem; border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.err { border-color: var(--danger); color: var(--danger); }
