:root {
  --bg: #070b14;
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf4;
  --muted: #8b95a8;
  --green: #22c55e;
  --red: #ef4444;
  --accent: #6366f1;
  --radius: 20px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* animierter Hintergrund */
body::before, body::after {
  content: "";
  position: fixed;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .35;
  z-index: -1;
  animation: float 22s ease-in-out infinite alternate;
}
body::before { background: #4f46e5; top: -25vmax; left: -15vmax; }
body::after  { background: #0891b2; bottom: -30vmax; right: -20vmax; animation-delay: -11s; }
@keyframes float { to { transform: translate(8vmax, 6vmax) scale(1.1); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 40px 32px;
  backdrop-filter: blur(24px);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.logo {
  width: 64px; height: 64px; margin: 0 auto 20px;
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  box-shadow: 0 10px 30px rgba(99,102,241,.45);
}
.login-card h1 { font-size: 24px; font-weight: 700; }
.login-card p { color: var(--muted); margin: 6px 0 28px; font-size: 14px; }
.pin-input {
  width: 100%;
  font-size: 28px; letter-spacing: 14px; text-align: center;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.3);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.pin-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99,102,241,.25); }
.btn {
  width: 100%; margin-top: 16px;
  padding: 14px; border: 0; border-radius: 14px;
  font-size: 15px; font-weight: 600; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  transition: transform .15s, filter .2s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.98); }
.error { color: #fca5a5; font-size: 14px; min-height: 20px; margin-top: 14px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

/* ---------- Header ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 40px 24px 64px; }
header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 36px; }
header .logo { margin: 0; width: 52px; height: 52px; font-size: 22px; border-radius: 15px; }
.title h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.title p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.header-right { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.summary {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  padding: 9px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
}
.search {
  padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: 14px; outline: none; width: 220px;
}
.search:focus { border-color: var(--accent); }
.ghost {
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--muted); font-size: 13px; text-decoration: none; cursor: pointer;
}
.ghost:hover { color: var(--text); }

h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin: 8px 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin-bottom: 40px; }

/* ---------- Kachel ---------- */
.tile {
  --c: var(--accent);
  position: relative;
  display: flex; flex-direction: column;
  min-height: 190px;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  color: inherit; text-decoration: none;
  backdrop-filter: blur(18px);
  overflow: hidden;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), background .25s, border-color .25s, box-shadow .25s;
  animation: pop .5s backwards;
}
.tile::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px circle at 0% 0%, color-mix(in srgb, var(--c) 22%, transparent), transparent 60%);
  opacity: .6; transition: opacity .25s; pointer-events: none;
}
.tile:hover {
  transform: translateY(-6px);
  background: var(--card-hover);
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
  box-shadow: 0 20px 50px rgba(0,0,0,.4), 0 0 0 1px color-mix(in srgb, var(--c) 20%, transparent);
}
.tile:hover::before { opacity: 1; }
@keyframes pop { from { opacity: 0; transform: translateY(14px); } }

.tile-icon {
  width: 52px; height: 52px; border-radius: 15px;
  display: grid; place-items: center; font-size: 26px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  margin-bottom: 16px; position: relative;
}
.tile h3 { font-size: 18px; font-weight: 700; position: relative; }
.tile .desc { color: var(--muted); font-size: 13.5px; margin-top: 4px; position: relative; }
.tile .host { color: color-mix(in srgb, var(--c) 70%, #fff); font-size: 12px; margin-top: 6px; opacity: .8; position: relative; word-break: break-all; }
.tile .arrow { position: absolute; top: 22px; right: 22px; color: var(--muted); font-size: 18px; transition: transform .25s, color .25s; }
.tile:hover .arrow { transform: translate(3px, -3px); color: var(--text); }

.tile-footer { margin-top: auto; padding-top: 18px; display: flex; align-items: center; gap: 8px; position: relative; }

.status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: rgba(148,163,184,.12); color: var(--muted);
  border: 1px solid rgba(148,163,184,.2);
  cursor: default;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.online  { background: rgba(34,197,94,.14); color: #4ade80; border-color: rgba(34,197,94,.35); }
.status.offline { background: rgba(239,68,68,.14); color: #f87171; border-color: rgba(239,68,68,.4); }
.status.online .dot  { box-shadow: 0 0 0 0 rgba(34,197,94,.7); animation: pulse 2s infinite; }
.status.offline .dot { animation: blink 1s infinite; }
.status.checking .dot { animation: blink 1.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@keyframes blink { 50% { opacity: .3; } }

.info-btn {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: rgba(255,255,255,.06);
  color: var(--text); font: italic 700 14px Georgia, serif;
  cursor: pointer; transition: background .2s, transform .2s;
}
.info-btn:hover { background: rgba(255,255,255,.16); transform: scale(1.08); }
.ms { margin-left: auto; font-size: 11.5px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3,6,12,.7); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  --c: var(--accent);
  width: 100%; max-width: 640px; max-height: 88vh; overflow: auto;
  background: #0d1322; border: 1px solid var(--border);
  border-radius: 24px; padding: 28px;
  box-shadow: 0 40px 100px rgba(0,0,0,.6);
  animation: rise .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(20px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.modal-head .tile-icon { margin: 0; }
.modal-head h3 { font-size: 20px; }
.modal-head p { color: var(--muted); font-size: 13px; }
.close { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.close:hover { color: var(--text); }
.meta { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13px; margin-bottom: 22px; }
.meta dt { color: var(--muted); }
.meta dd { word-break: break-all; }
.meta code, .chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.chip { display: inline-block; padding: 2px 8px; margin: 0 4px 4px 0; border-radius: 6px; background: rgba(255,255,255,.07); }
.modal h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 0 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.ver { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: color-mix(in srgb, var(--c) 70%, #fff); white-space: nowrap; }
td.role { color: var(--muted); }

.empty { color: var(--muted); padding: 30px 0; }
footer { color: var(--muted); font-size: 12px; text-align: center; margin-top: 10px; }

@media (max-width: 640px) {
  .container { padding: 28px 16px 48px; }
  .header-right { margin-left: 0; width: 100%; }
  .search { flex: 1; width: auto; }
  .title h1 { font-size: 24px; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dd { margin-bottom: 8px; }
  td.ver { white-space: normal; }
}

.sum-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.sum-dot.online { background: var(--green); animation: pulse 2s infinite; box-shadow: 0 0 0 0 rgba(34,197,94,.7); }
.sum-dot.offline { background: var(--red); animation: blink 1s infinite; }

/* ---------- Logos ---------- */
.tile-icon img { width: 30px; height: 30px; object-fit: contain; }
.modal-head .tile-icon img { width: 30px; height: 30px; }
.soft { display: inline-flex; align-items: center; gap: 10px; }
.soft-logo { width: 18px; height: 18px; object-fit: contain; flex: none; }
.soft-logo-empty { display: inline-block; border-radius: 5px; background: rgba(255,255,255,.08); }

/* ---------- Bearbeiten ---------- */
.ghost.active { background: rgba(99,102,241,.25); border-color: var(--accent); color: var(--text); }
button.ghost { font-family: inherit; }
.edit-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 28px; border-radius: 16px;
  background: rgba(99,102,241,.12); border: 1px dashed rgba(99,102,241,.5);
  font-size: 13.5px; color: #c7d2fe;
}
.edit-banner span { flex: 1; min-width: 240px; }
.tile.editing { border-style: dashed; }
.tile.editing:hover { transform: none; }
.edit-bar { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; z-index: 2; }
.mini {
  padding: 5px 9px; border-radius: 9px; font: 600 12px inherit; font-family: inherit;
  border: 1px solid var(--border); background: rgba(13,19,34,.85); color: var(--text); cursor: pointer;
}
.mini:hover { background: rgba(255,255,255,.14); }
.mini.primary { background: rgba(99,102,241,.35); border-color: rgba(99,102,241,.6); }
.mini.danger:hover { background: rgba(239,68,68,.3); }
.add-tile {
  align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--border); background: transparent; color: var(--muted);
  font: 600 15px inherit; font-family: inherit; cursor: pointer;
}
.add-tile span { font-size: 34px; line-height: 1; }
.add-tile:hover { color: var(--text); border-color: var(--accent); transform: none; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.modal small { color: var(--muted); font-size: 11.5px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.modal input, .modal select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: rgba(0,0,0,.3); color: var(--text);
  font: 14px inherit; font-family: inherit; outline: none;
}
.modal input:focus, .modal select:focus { border-color: var(--accent); }
.modal input[type=color] { padding: 3px; height: 40px; cursor: pointer; }
.modal select option { background: #0d1322; }

.logo-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; max-height: 170px; overflow: auto; padding: 2px; }
.logo-opt {
  height: 46px; border-radius: 12px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border); background: rgba(255,255,255,.04); color: var(--muted); font: 600 11px inherit; font-family: inherit;
}
.logo-opt img { width: 26px; height: 26px; object-fit: contain; }
.logo-opt:hover { background: rgba(255,255,255,.12); }
.logo-opt.sel { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 60%, transparent); background: rgba(255,255,255,.1); }
.upload { display: inline-block; margin-top: 10px; }

.stack-row { display: grid; grid-template-columns: 24px 1.3fr 1fr 1.4fr 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.stack-row .row-logo { display: grid; place-items: center; }
.infra .stack-row { grid-template-columns: 24px 1fr 1.4fr 34px; }
.infra [data-f=version] { display: none; }
.stack-row + .ghost, #stack-rows + .ghost { margin-top: 4px; }

.form-error { color: #fca5a5; font-size: 13.5px; min-height: 18px; margin-top: 16px; }
.modal-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.btn.small { width: auto; margin: 0; padding: 10px 22px; font-size: 14px; }
.ghost.danger { color: #fca5a5; border-color: rgba(239,68,68,.4); }
.ghost.danger:hover { background: rgba(239,68,68,.2); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100;
  padding: 12px 20px; border-radius: 12px; font-size: 14px;
  background: #14532d; border: 1px solid #22c55e; color: #dcfce7;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: opacity .4s, transform .4s;
}
.toast.error { background: #450a0a; border-color: #ef4444; color: #fee2e2; }
.toast.hide { opacity: 0; transform: translate(-50%, 10px); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .stack-row, .infra .stack-row { grid-template-columns: 24px 1fr 34px; }
  .stack-row [data-f=version], .stack-row [data-f=role] { grid-column: 2 / 3; }
}
.form-grid label > span { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-height: 18px; }
.form-grid { align-items: end; }

.notes {
  white-space: pre-wrap; font-size: 13px; line-height: 1.55;
  padding: 14px 16px; border-radius: 12px;
  background: rgba(251,191,36,.07); border: 1px solid rgba(251,191,36,.25);
  max-height: 340px; overflow: auto;
}
.modal textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; resize: vertical;
  border: 1px solid var(--border); background: rgba(0,0,0,.3); color: var(--text);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; outline: none;
}
.modal textarea:focus { border-color: var(--accent); }
