:root {
    --bg: #08131a;
    --bg2: #0d2029;
    --surface: #112a34;
    --surface2: #173641;
    --border: #2c5360;
    --text: #e6f0f2;
    --muted: #91a9b1;
    --accent: #32a7ca;
    --accent2: #55c4e3;
    --ok: #4fb77b;
    --warn: #d4a246;
    --err: #d8656d;
    --shadow: 0 18px 50px rgba(0, 0, 0, .28);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(145deg, var(--bg), #0b1d25 55%, #071016); color: var(--text); }
body { font-size: 15px; }
a { color: var(--accent2); text-decoration: none; }
code, .mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.break { overflow-wrap: anywhere; word-break: break-word; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); width: 100%; height: 100vh; overflow: hidden; }
.sidebar { min-height: 0; display: flex; flex-direction: column; padding: 18px 14px; border-right: 1px solid var(--border); background: rgba(7, 18, 24, .95); }
.brand, .auth-brand { display: flex; gap: 12px; align-items: center; }
.brand { flex: 0 0 auto; padding: 0 8px 18px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(145deg, var(--accent), #176f8a); font-weight: 800; box-shadow: 0 8px 24px rgba(50, 167, 202, .25); }
.brand strong, .brand small, .auth-brand strong, .auth-brand small { display: block; }
.brand small, .auth-brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.sidebar nav { min-height: 0; flex: 1 1 auto; overflow: auto; display: grid; align-content: start; gap: 16px; padding: 2px 2px 12px; scrollbar-gutter: stable; }
.nav-group { overflow: hidden; border: 1px solid rgba(44, 83, 96, .66); border-radius: 11px; background: rgba(11, 29, 37, .72); }
.nav-group__header { display: grid; gap: 2px; padding: 9px 11px 8px; border-bottom: 1px solid rgba(44, 83, 96, .58); background: rgba(23, 54, 65, .58); }
.nav-group__header strong { color: var(--text); font-size: 13px; letter-spacing: .025em; }
.nav-group__items { display: grid; gap: 3px; padding: 6px; }
.sidebar nav a { min-height: 38px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); }
.nav-item__marker { flex: 0 0 auto; width: 6px; height: 6px; border: 1px solid currentColor; border-radius: 50%; opacity: .72; }
.sidebar nav a:hover { color: var(--text); background: rgba(17, 42, 52, .86); }
.sidebar nav a.active { color: #fff; border-color: rgba(50, 167, 202, .42); background: linear-gradient(90deg, rgba(50, 167, 202, .28), rgba(50, 167, 202, .1)); }
.sidebar nav a.active .nav-item__marker { border-color: var(--accent2); background: var(--accent2); box-shadow: 0 0 0 3px rgba(50, 167, 202, .14); opacity: 1; }
.logout-form { flex: 0 0 auto; margin-top: 10px; }

main { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 26px 14px; border-bottom: 1px solid rgba(44, 83, 96, .7); background: rgba(9, 25, 33, .76); backdrop-filter: blur(12px); }
.topbar h1 { margin: 2px 0 0; font-size: 22px; }
.eyebrow { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.content { min-width: 0; min-height: 0; overflow: auto; padding: 18px 24px; scrollbar-gutter: stable; }
.bottom-bar { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 9px 24px; border-top: 1px solid var(--border); color: var(--muted); background: rgba(9, 25, 33, .88); font-size: 12px; }

.panel, .toolbar, .auth-card, .stats article, .repair-card { border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(145deg, rgba(17, 42, 52, .96), rgba(12, 31, 39, .96)); box-shadow: var(--shadow); }
.panel { margin-bottom: 18px; padding: 17px; }
.panel h2 { margin: 0 0 13px; font-size: 18px; }
.panel h3 { margin: 17px 0 6px; color: var(--muted); font-size: 14px; }
.panel p { line-height: 1.45; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.panel-head h2 { margin-bottom: 4px; }
.panel-head p { margin: 0; }
.critical-panel { border-color: rgba(216, 101, 109, .75); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 15px 18px; }
.toolbar > div span { display: block; margin-top: 4px; color: var(--muted); }
.toolbar form { display: flex; align-items: center; gap: 10px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stats article { min-width: 0; padding: 15px; }
.stats article span, .stats article small { display: block; color: var(--muted); }
.stats article strong { display: block; margin: 7px 0; font-size: 23px; overflow-wrap: anywhere; }
.stats.compact article strong { font-size: 19px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.panels { align-items: start; }

.notice { margin-bottom: 16px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 10px; background: rgba(23, 54, 65, .7); line-height: 1.45; }
.notice.success { border-color: rgba(79, 183, 123, .6); background: rgba(79, 183, 123, .12); }
.notice.warning { border-color: rgba(212, 162, 70, .65); background: rgba(212, 162, 70, .12); }
.notice.error { border-color: rgba(216, 101, 109, .65); background: rgba(216, 101, 109, .12); }
.notice.info { border-color: rgba(50, 167, 202, .65); background: rgba(50, 167, 202, .12); }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.badge.success, .badge.ok { color: #8ee1ae; border-color: rgba(79, 183, 123, .55); }
.badge.warning { color: #f2c66c; border-color: rgba(212, 162, 70, .55); }
.badge.error { color: #ff9ca3; border-color: rgba(216, 101, 109, .55); }
.badge.info { color: #8edcf0; border-color: rgba(50, 167, 202, .55); }
.badge.muted-badge { color: var(--muted); }
.warning-text { color: #f2c66c !important; }

.button { min-height: 39px; appearance: none; display: inline-flex; align-items: center; justify-content: center; padding: 8px 13px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface2); font: inherit; font-weight: 700; cursor: pointer; }
.button:hover { filter: brightness(1.1); }
.button.primary { color: #fff; border-color: #4bc0df; background: linear-gradient(145deg, var(--accent), #1d829f); }
.button.secondary { background: #193640; }
.button.danger { color: #fff; border-color: rgba(216, 101, 109, .8); background: linear-gradient(145deg, #b94d56, #8b343b); }
.button.full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

label { display: block; margin-bottom: 13px; }
label span { display: block; margin-bottom: 6px; font-weight: 700; }
label small { display: block; margin-top: 5px; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; outline: none; color: var(--text); background: #0c2029; font: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(50, 167, 202, .15); }
input[type=file] { width: auto; max-width: 100%; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.danger-form { max-width: 760px; }

.muted { color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid rgba(44, 83, 96, .55); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 650; }
thead th { position: sticky; top: 0; z-index: 1; background: #102833; }
.table-scroll { max-height: 440px; overflow: auto; border: 1px solid rgba(44, 83, 96, .55); border-radius: 10px; scrollbar-gutter: stable; }
.table-scroll.tall { max-height: 590px; }
.table-note { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.empty { min-height: 200px; display: grid; place-items: center; padding: 24px; border: 1px dashed var(--border); border-radius: 14px; color: var(--muted); text-align: center; }
.empty.small { min-height: 110px; }
.path-list { max-height: 280px; overflow: auto; display: grid; gap: 6px; }
.path-list code { padding: 7px 9px; border: 1px solid rgba(44, 83, 96, .5); border-radius: 7px; background: #0b1d25; }
.count { color: var(--muted); font-size: 12px; font-weight: 400; }
.field-note { margin-bottom: 13px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; background: #0c2029; }
.field-note strong, .field-note span, .field-note small { display: block; }
.field-note span { margin-top: 6px; font-size: 18px; }
.field-note small { margin-top: 5px; color: var(--muted); }
.report-list { display: grid; gap: 9px; margin: 0; padding-left: 20px; }
.report-list li { line-height: 1.45; }

.repair-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.repair-card { min-width: 0; padding: 16px; }
.repair-card h3 { margin: 0 0 8px; color: var(--text); font-size: 16px; }
.repair-card.is-danger { border-color: rgba(216, 101, 109, .55); }
.connection-state { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.connection-state strong { font-size: 17px; }
.connection-comparison td:last-child { width: 100px; }
.connection-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 14px; align-items: start; }

.auth-page { min-height: 100vh; display: grid; place-items: center; overflow: auto; padding: 30px; }
.auth-wrap { width: min(980px, 100%); }
.auth-brand { justify-content: center; margin-bottom: 18px; }
.auth-card { width: min(450px, 100%); margin: 0 auto; padding: 24px; }
.auth-card.wide { width: min(980px, 100%); }
.auth-card h1 { margin: 0 0 8px; }
.auth-card h2 { margin: 24px 0 8px; font-size: 17px; }

@media (max-width: 1050px) {
    .app-shell { grid-template-columns: 225px minmax(0, 1fr); }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.two, .grid.three, .repair-grid, .connection-actions { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    html, body { height: auto; overflow: auto; }
    .app-shell { display: block; height: auto; min-height: 100vh; overflow: visible; }
    .sidebar { min-height: auto; }
    .sidebar nav { overflow: visible; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nav-group { align-content: start; }
    main { display: block; overflow: visible; }
    .content { overflow: visible; }
    .bottom-bar { flex-direction: column; align-items: flex-start; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar form { flex-wrap: wrap; }
}

@media (max-width: 520px) {
    .sidebar nav, .stats { grid-template-columns: 1fr; }
    .topbar, .content, .bottom-bar { padding-left: 14px; padding-right: 14px; }
    .topbar { align-items: flex-start; }
    .panel-head { flex-direction: column; }
    .auth-page { padding: 16px; }
}

.button:disabled,
button:disabled {
    cursor: not-allowed;
    opacity: .48;
    filter: saturate(.55);
}

.connection-comparison td, .connection-comparison th { vertical-align: middle; }

/* 0.3.1 – kompakter Gate-Notfallzugang */
.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    min-height: 40px;
    padding: 0 2px;
    cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    min-height: 18px;
    margin: 0;
    padding: 0;
    accent-color: var(--accent);
}
.checkbox-row span {
    display: inline;
    margin: 0;
    font-weight: 650;
}
.gate-break-glass-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gate-break-glass-form { margin: 0; }
.gate-break-glass-form--activate {
    display: grid;
    grid-template-columns: minmax(190px, 260px) minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
}
.gate-break-glass-form--activate .gate-break-glass-ttl { margin: 0; }
.gate-break-glass-form--activate .button { align-self: end; }

@media (max-width: 1050px) {
    .gate-break-glass-stats { grid-template-columns: 1fr; }
    .gate-break-glass-form--activate { grid-template-columns: 1fr; align-items: stretch; }
    .gate-break-glass-form--activate .button { justify-self: start; }
}


/* 0.3.2 – Recovery Auth v2 */
.mfa-secret, .mfa-uri { display: block; margin-top: 9px; padding: 10px 11px; border: 1px solid rgba(44,83,96,.55); border-radius: 8px; background: #081a22; user-select: all; }
.recovery-code-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 18px 0; }
.recovery-code-grid code { padding: 11px 12px; border: 1px solid rgba(50,167,202,.35); border-radius: 8px; background: #081a22; text-align: center; letter-spacing: .06em; user-select: all; }
.mfa-code-confirm { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.mfa-code-confirm .checkbox-row { flex: 1 1 520px; }
.auth-footnote { margin: 14px 0 0; font-size: 12px; }
@media (max-width: 760px) { .recovery-code-grid { grid-template-columns: 1fr; } .mfa-code-confirm { align-items: stretch; } }

/* 0.3.3 – lokale TOTP-QR-Einrichtung */
.mfa-setup-layout {
    display: grid;
    grid-template-columns: minmax(300px, .9fr) minmax(340px, 1.1fr);
    gap: 18px;
    margin: 18px 0;
    align-items: stretch;
}
.mfa-qr-card,
.mfa-manual-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(8, 26, 34, .72);
}
.mfa-qr-card h2,
.mfa-manual-card h2 { margin: 0 0 8px; }
.mfa-qr-frame {
    width: fit-content;
    max-width: 100%;
    margin: 16px auto;
    padding: 12px;
    border: 1px solid rgba(50, 167, 202, .45);
    border-radius: 12px;
    background: #fff;
    line-height: 0;
}
.recovery-totp-qr__image {
    display: block;
    width: 195px;
    max-width: 100%;
    height: auto;
}
.mfa-qr-privacy {
    display: block;
    color: var(--muted);
    line-height: 1.4;
}
.mfa-manual-card .field-note { margin: 14px 0 0; }
.mfa-uri-details {
    margin-top: 14px;
    padding: 11px 12px;
    border: 1px solid rgba(44, 83, 96, .55);
    border-radius: 9px;
    background: rgba(12, 32, 41, .72);
}
.mfa-uri-details summary { cursor: pointer; font-weight: 700; }
.mfa-uri-details small { display: block; margin-top: 7px; color: var(--muted); }
.mfa-confirm-form { margin-top: 18px; padding-top: 17px; border-top: 1px solid rgba(44, 83, 96, .55); }
.mfa-confirm-form > small { display: block; margin: -5px 0 13px; color: var(--muted); line-height: 1.4; }

@media (max-width: 760px) {
    .mfa-setup-layout { grid-template-columns: 1fr; }
    .mfa-qr-frame { margin-left: 0; }
}

/* 0.3.4 – Recovery-Benutzerverwaltung und MFA-Lifecycle */
.account-stats { margin-bottom: 14px; }
.account-security-note { margin: 0; }
.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}
.account-card { min-width: 0; margin-bottom: 0; }
.account-card form { margin-top: 14px; }
.account-card .field-note span { display: block; margin-top: 6px; }
.account-card .field-note small { display: block; margin-top: 5px; color: var(--muted); }
.account-flow-panel { max-width: 980px; margin-left: auto; margin-right: auto; }

@media (max-width: 980px) {
    .account-grid { grid-template-columns: 1fr; }
}
