:root {
    --bg: #0c1210;
    --panel: #151d1a;
    --panel-2: #1b2622;
    --field: #0b110e;
    --border: #2a3832;
    --border-soft: rgba(138, 163, 152, .14);
    --text: #e8f3ee;
    --text-soft: #c4d9cf;
    --muted: #8aa398;
    --accent: #71e59a;
    --accent-strong: #43c77a;
    --accent-glow: rgba(113, 229, 154, .18);
    --danger: #ff6b6b;
    --warn: #ffb84d;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 12px 40px rgba(0, 0, 0, .3);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background:
        radial-gradient(900px 500px at 85% -12%, rgba(67, 199, 122, .16), transparent 70%),
        radial-gradient(700px 400px at -10% 110%, rgba(67, 199, 122, .08), transparent 70%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: .88em;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 1px 6px;
    word-break: break-all;
}

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.shell-centered { grid-template-columns: 1fr; place-items: center; }

/* ===== Seitenleiste ===== */
.sidebar {
    background: rgba(10, 15, 13, .78);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    padding: 4px 10px 18px;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.5rem; }

.nav-group {
    margin: 18px 10px 6px;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-link.active {
    background: linear-gradient(90deg, rgba(113, 229, 154, .2), rgba(113, 229, 154, .02));
    color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon { width: 1.4em; text-align: center; }

.sidebar-foot {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 6px 10px;
    align-items: center;
}
.avatar { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 0 0 2px var(--border); }
.who { min-width: 0; overflow: hidden; }
.who strong, .who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-size: .75rem; }
.sidebar-foot form { grid-column: 1 / -1; }

/* ===== Inhalt ===== */
.content { padding: 36px clamp(16px, 4vw, 52px); max-width: 1200px; width: 100%; }
.page-head h1 { margin: 0 0 22px; font-size: 2rem; letter-spacing: -.02em; line-height: 1.2; }
.section-title {
    margin: 34px 0 14px;
    padding-top: 22px;
    border-top: 1px solid var(--border-soft);
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title::before {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 18px; }
.muted { color: var(--muted); }
.help { display: block; color: var(--muted); font-size: .85rem; margin-top: 6px; }
.nowrap { white-space: nowrap; }

.card {
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .03);
    margin-bottom: 20px;
}
.card h2 { margin: 0 0 8px; font-size: 1.2rem; }
.card-center { text-align: center; max-width: 480px; margin: 12vh auto; }
.card-center p { margin: 10px 0 20px; }

/* Einrichtung: eigene Breite und Kopf */
.card-setup { max-width: 820px; width: 100%; padding: 30px clamp(18px, 3vw, 34px); }

.hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 8px; }
.hero-icon { font-size: 2.6rem; margin-bottom: 6px; }

.notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: rgba(113, 229, 154, .07);
    border: 1px solid rgba(113, 229, 154, .25);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 18px 0 6px;
    font-size: .92rem;
}
.notice::before { content: "ℹ"; font-weight: 700; color: var(--accent); line-height: 1.5; }
.notice-warn {
    background: rgba(255, 184, 77, .07);
    border-color: rgba(255, 184, 77, .4);
}
.notice-warn::before { content: "⚠"; color: var(--warn); }
.notice a { color: var(--accent); font-weight: 600; margin-left: 6px; }
.notice code { background: rgba(0, 0, 0, .25); }

.log {
    max-height: 360px;
    overflow: auto;
    margin: 12px 0 0;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: #070b09;
    border: 1px solid var(--border);
    font-size: .8rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.status-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.status-list li { display: flex; align-items: center; gap: 10px; }

.changelog { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.changelog-entry { display: flex; gap: 12px; align-items: flex-start; }
.changelog-entry p { margin: 4px 0; }
.changelog-entry .badge { flex-shrink: 0; margin-top: 2px; min-width: 92px; text-align: center; }
.badge-added { color: var(--accent); border-color: rgba(113, 229, 154, .35); }
.badge-improved { color: #7fb8ff; border-color: rgba(127, 184, 255, .35); }
.badge-fixed { color: var(--warn); border-color: rgba(255, 184, 77, .4); }
.badge-technical { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 18px; }

.module-card { display: flex; flex-direction: column; gap: 10px; margin: 0; transition: transform .15s, border-color .15s, box-shadow .15s; }
.module-card:hover { transform: translateY(-2px); border-color: rgba(113, 229, 154, .4); box-shadow: 0 16px 40px rgba(0, 0, 0, .35); }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head h2 { margin: 0; flex: 1; }
.module-icon { font-size: 1.4rem; }
.card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }

/* ===== Badges & Flash ===== */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: var(--panel-2);
    border: 1px solid var(--border);
}
.badge-on { color: #0b1d13; background: var(--accent); border-color: var(--accent); }
.badge-off { color: var(--muted); }
.badge-system { color: var(--warn); border-color: rgba(255, 184, 77, .4); }
.badge-role { color: var(--accent); border-color: rgba(113, 229, 154, .35); margin: 2px 4px 2px 0; }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: var(--panel-2);
}
.flash-success { border-color: rgba(113, 229, 154, .5); background: rgba(113, 229, 154, .1); }
.flash-error { border-color: rgba(255, 107, 107, .5); background: rgba(255, 107, 107, .1); }

.id-box { display: inline-block; padding: 8px 14px; background: var(--bg); border: 1px dashed var(--accent); border-radius: var(--radius-sm); user-select: all; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s, transform .05s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    color: #0b1d13;
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(67, 199, 122, .25);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(67, 199, 122, .35); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255, 107, 107, .5); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 32px; padding: 5px 12px; font-size: .88rem; }
.btn-lg { min-height: 48px; padding: 12px 26px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* ===== Formulare ===== */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, legend { font-weight: 600; font-size: .9rem; color: var(--text-soft); }

/* Alle Texteingaben, auch ohne type-Attribut */
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"]),
textarea,
select {
    width: 100%;
    min-height: 42px;
    background: var(--field);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font: inherit;
    font-size: .95rem;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"])::placeholder,
textarea::placeholder {
    color: rgba(138, 163, 152, .55);
}
input[type="password"], input[name="install_token"], input[name="client_secret"] {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    letter-spacing: .02em;
}
input:hover:not(:disabled), textarea:hover:not(:disabled), select:hover:not(:disabled) {
    border-color: #3c5249;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    cursor: pointer;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}
select option { background: var(--panel); color: var(--text); }
input[type="color"] { padding: 3px; height: 42px; width: 80px; background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-sm); }
input[readonly] { opacity: .7; }
textarea { resize: vertical; min-height: 84px; font-family: inherit; }
input:disabled, textarea:disabled, select:disabled { opacity: .55; cursor: not-allowed; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card-setup .actions { margin-top: 10px; padding-top: 22px; border-top: 1px solid var(--border-soft); }
.reset-form { margin-top: 16px; }

/* Schalter */
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: var(--border);
    transition: background .2s;
    flex-shrink: 0;
}
.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    transition: transform .2s;
}
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(20px); background: #0b1d13; }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle input:disabled + .switch { opacity: .5; }

/* Checkboxen */
.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .92rem;
    transition: background .15s;
}
.check:hover { background: rgba(255, 255, 255, .03); }
.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; }
.check input:disabled { cursor: not-allowed; }
.check small { display: block; }

.matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px 12px;
    margin: 0;
    min-width: 0;
    background: rgba(0, 0, 0, .12);
}
fieldset legend { padding: 0 6px; }
.role-pick { display: grid; gap: 4px; }

details.role { padding: 0; overflow: hidden; }
details.role summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px;
    cursor: pointer;
    font-weight: 600;
    transition: background .15s;
}
details.role summary:hover { background: rgba(255, 255, 255, .02); }
details.role summary::-webkit-details-marker { display: none; }
details.role summary::before { content: "▸"; color: var(--accent); transition: transform .15s; }
details.role[open] summary::before { transform: rotate(90deg); }
details.role > form, details.role > .reset-form { padding: 0 22px; }
details.role > form:first-of-type { padding-top: 6px; }
details.role > .reset-form { padding-bottom: 22px; }
.role-name { font-size: 1.05rem; }
.role-count { margin-left: auto; font-weight: 400; font-size: .88rem; }

/* Tabellen */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.table tr:hover td { background: rgba(255, 255, 255, .015); }
.details { display: inline-block; max-width: 420px; white-space: pre-wrap; word-break: break-all; font-size: .8rem; }

/* ===== Einrichtung: Schritte ===== */
.setup-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.setup-hero h2 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: -.01em; }
.setup-hero p { margin: 0; }
.setup-hero-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(113, 229, 154, .25), rgba(67, 199, 122, .05));
    border: 1px solid rgba(113, 229, 154, .3);
}

.checklist-box {
    background: var(--field);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 18px;
}
.checklist { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.checklist li { position: relative; padding-left: 24px; color: var(--text-soft); font-size: .93rem; }
.checklist li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--accent);
    font-weight: 700;
}

.step {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, .14);
    padding: 20px 20px 6px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.step-head { display: flex; gap: 14px; align-items: flex-start; }
.step-head h3 { margin: 0 0 2px; font-size: 1.12rem; }
.step-head p { margin: 0; font-size: .92rem; }
.step-num {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    color: #0b1d13;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(67, 199, 122, .3);
}

.tip {
    background: rgba(127, 184, 255, .06);
    border: 1px solid rgba(127, 184, 255, .25);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .92rem;
}
.tip summary { cursor: pointer; font-weight: 600; color: #9fcbff; list-style: none; }
.tip summary::-webkit-details-marker { display: none; }
.tip summary::before { content: "💡 "; }
.tip ol { margin: 10px 0 2px; padding-left: 20px; display: grid; gap: 6px; color: var(--text-soft); }
.tip em { font-style: normal; color: var(--text); font-weight: 600; }

.setup-actions { align-items: center; padding: 8px 0 4px; }
.setup-actions .muted { font-size: .88rem; }

/* ===== Anmeldung ===== */
.auth-form { text-align: left; margin-top: 18px; }
.auth-switch { margin: 18px 0 0; font-size: .92rem; }
.avatar-initial {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0b1d13;
    font-weight: 800;
    box-shadow: 0 0 0 2px var(--border);
}

/* Scrollbars passend zum Thema */
* { scrollbar-width: thin; scrollbar-color: #2d3d36 transparent; }

/* ===== Schmale Bildschirme ===== */
@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .hero { flex-direction: column; align-items: flex-start; }
    .content { padding: 24px 16px; }
}
@media (max-width: 560px) {
    .grid-2 { grid-template-columns: 1fr; }
    .card { padding: 20px; }
    .page-head h1 { font-size: 1.6rem; }
}
