/* Gleiche Gestaltung wie die Steuerungs-App (apps/control/docs/STYLEGUIDE.md): dunkel, monochrom, weiche Flächen, Pillen-Buttons. */
:root {
  color-scheme: dark;
  --base: #0a0b0e;
  --fill-1: rgba(255, 255, 255, 0.06);
  --fill-2: rgba(255, 255, 255, 0.10);
  --fill-3: rgba(255, 255, 255, 0.16);
  --text: #f5f6f8;
  --text-2: rgba(245, 246, 248, 0.62);
  --text-3: rgba(245, 246, 248, 0.38);
  --danger: #ff5d4d;
  --ok: #4ade80;
  --amber: #fbbf24;
  --dialog: #15171c;
  --font: Inter, 'SF Pro Display', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--base); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid rgba(255, 255, 255, .7); outline-offset: 2px; }

/* ---------- Bausteine ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 11px 20px; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--fill-2); transition: background .15s, transform .1s;
}
.btn:hover:not(:disabled) { background: var(--fill-3); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary { background: #fff; color: #0a0b0e; }
.btn-primary:hover:not(:disabled) { background: #e4e6ea; }
.btn-danger { background: rgba(255, 93, 77, .14); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 93, 77, .26); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: #ff7566; }
.btn-ghost { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--fill-3); }
.btn-ghost:hover:not(:disabled) { background: var(--fill-1); color: var(--text); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-icon { padding: 10px; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-sm .icon { width: 16px; height: 16px; }

.card { background: var(--fill-1); border-radius: 28px; }
.input {
  width: 100%; border: 0; border-radius: 16px; padding: 12px 16px; font-size: 15px; background: var(--fill-1); color: var(--text); transition: background .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; background: var(--fill-2); box-shadow: 0 0 0 2px rgba(255, 255, 255, .55); }
.input.invalid { box-shadow: 0 0 0 2px rgba(255, 93, 77, .7); }
.input:disabled { opacity: .45; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.field { display: grid; gap: 6px; }
.field-label { padding-left: 4px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.field-hint { padding-left: 4px; font-size: 12px; color: var(--text-3); }
.field-hint.error { color: var(--danger); }
.field-hint.ok { color: var(--ok); }

.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--fill-2); color: var(--text-2); white-space: nowrap; }
.chip-ok { background: rgba(74, 222, 128, .16); color: var(--ok); }
.chip-danger { background: rgba(255, 93, 77, .16); color: var(--danger); }
.chip-live { background: #fff; color: #0a0b0e; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.breathe { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--fill-1); }
.segmented button { flex: 1; border: 0; border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--text-2); background: transparent; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: #fff; color: #0a0b0e; }

/* Schalter-Zeile */
.switch-row { display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 16px; border: 0; border-radius: 20px; background: var(--fill-1); text-align: left; cursor: pointer; transition: background .15s; }
.switch-row:hover { background: var(--fill-2); }
.switch-row .text { flex: 1; min-width: 0; }
.switch-row .title { font-weight: 600; }
.switch-row .desc { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.switch { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--fill-3); transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-row[aria-checked='true'] .switch { background: var(--ok); }
.switch-row[aria-checked='true'] .switch::after { transform: translateX(18px); }

/* ---------- Anmeldung ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(26rem, 100%); padding: 32px; display: grid; gap: 20px; background: var(--dialog); border-radius: 32px; box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .06); }
.login h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.login p { margin: 0; color: var(--text-2); font-size: 14px; }

/* ---------- Rahmen ---------- */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat { display: flex; align-items: baseline; gap: 6px; border-radius: 999px; padding: 6px 14px; background: var(--fill-1); font-size: 13px; color: var(--text-2); white-space: nowrap; }
.stat b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

.layout { display: grid; grid-template-columns: minmax(20rem, 26rem) 1fr; gap: 16px; padding: 0 16px 16px; min-height: 0; }
.pane { min-height: 0; overflow-y: auto; border-radius: 32px; }
.pane-list { background: var(--fill-1); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pane-detail { background: #16181d; padding: 28px; }

/* ---------- Liste ---------- */
.list-head { display: grid; gap: 10px; }
.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 42px; background: var(--fill-1); }
.tenant-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tenant { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; width: 100%; padding: 12px 14px; border: 0; border-radius: 20px; background: transparent; text-align: left; cursor: pointer; transition: background .15s; }
.tenant:hover { background: var(--fill-1); }
.tenant.active { background: #fff; color: #0a0b0e; }
.tenant .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant .meta { grid-column: 1 / -1; font-size: 12px; color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; }
.tenant.active .meta { color: rgba(10, 11, 14, .6); }
.tenant .badges { display: flex; gap: 6px; align-items: center; }
.empty { padding: 28px 12px; text-align: center; color: var(--text-2); display: grid; gap: 12px; justify-items: center; }

/* ---------- Detail ---------- */
.detail { display: grid; gap: 28px; max-width: 46rem; }
.detail-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.detail-head .titles { flex: 1; min-width: 12rem; }
.detail-head h2 { margin: 0; font-size: 26px; letter-spacing: -.015em; }
.detail-head .sub { margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-2); font-size: 14px; }
.back { display: none; }
.section { display: grid; gap: 12px; }
.section > h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.section .note { margin: -4px 0 0; font-size: 13px; color: var(--text-3); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.links { display: grid; gap: 6px; }
.link-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 20px; background: var(--fill-1); }
.link-row .what { width: 9.5rem; flex: none; font-size: 13px; font-weight: 600; }
.link-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details.card-inset { border-radius: 20px; background: var(--fill-1); }
details.card-inset > summary { cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
details.card-inset > summary::-webkit-details-marker { display: none; }
details.card-inset > summary::after { content: '›'; margin-left: auto; font-size: 20px; color: var(--text-2); transition: transform .15s; }
details.card-inset[open] > summary::after { transform: rotate(90deg); }
details.card-inset > .body { padding: 4px 16px 16px; display: grid; gap: 12px; }
.savebar { position: sticky; bottom: -12px; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px; border-radius: 999px; background: #fff; color: #0a0b0e; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.savebar span { flex: 1; font-weight: 600; }
.savebar .btn-ghost { color: rgba(10, 11, 14, .65); box-shadow: inset 0 0 0 1px rgba(10, 11, 14, .2); }
.savebar .btn-ghost:hover:not(:disabled) { background: rgba(10, 11, 14, .06); color: #0a0b0e; }
.savebar .btn-primary { background: #0a0b0e; color: #fff; }
.danger-zone { display: grid; gap: 10px; padding: 16px; border-radius: 20px; background: rgba(255, 93, 77, .08); }
.danger-zone .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.danger-zone .row .text { flex: 1; min-width: 12rem; }
.danger-zone .row .text b { display: block; }
.danger-zone .row .text span { font-size: 13px; color: var(--text-2); }
.placeholder { height: 100%; display: grid; place-items: center; text-align: center; color: var(--text-2); }

/* ---------- Dialoge ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 8, .7); backdrop-filter: blur(16px) saturate(.8); -webkit-backdrop-filter: blur(16px) saturate(.8); }
.dialog { width: min(32rem, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 28px; border-radius: 32px; background: var(--dialog); box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .06); display: grid; gap: 18px; }
.dialog h2 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.dialog p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.secret { display: grid; gap: 10px; padding: 16px; border-radius: 20px; background: rgba(74, 222, 128, .08); }
.secret .key { display: flex; gap: 8px; align-items: center; }
.secret .key code { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 14px; background: rgba(0, 0, 0, .3); color: var(--ok); font-size: 14px; word-break: break-all; }
.warn { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--amber); }

/* ---------- Hinweise ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { padding: 11px 20px; border-radius: 999px; background: #fff; color: #0a0b0e; font-weight: 600; font-size: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); animation: toast-in .2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Schmale Bildschirme: Liste und Detail nacheinander ---------- */
@media (max-width: 899px) {
  .layout { grid-template-columns: 1fr; }
  .shell[data-view='detail'] .pane-list { display: none; }
  .shell[data-view='list'] .pane-detail { display: none; }
  .pane-detail { padding: 20px 16px; }
  .back { display: inline-flex; }
  .grid2 { grid-template-columns: 1fr; }
  .link-row .what { width: auto; }
  .link-row code { display: none; }
  .link-row .what { flex: 1; }
  .topbar .stats { flex-wrap: nowrap; overflow: hidden; }
  .topbar .stats .stat:nth-child(n+3) { display: none; }
  .shell[data-view='detail'] .stats { display: none; }
}
