:root {
  --bg: #0d1117;
  --bg-2: #131a23;
  --panel: #161e29;
  --panel-2: #1c2633;
  --border: #263241;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #22c55e;
  --accent-2: #16a34a;
  --accent-text: #052e16;
  --danger: #ef4444;
  --warn: #f59e0b;
  --info: #3b82f6;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, pre { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem; font-weight: 700; font-size: 1.1rem; }
.brand-logo { width: 28px; height: 28px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; color: var(--accent-text); font-weight: 900; }
.nav { display: flex; flex-direction: column; padding: .5rem; gap: 2px; flex: 1; }
.nav a { color: var(--muted); padding: .55rem .8rem; border-radius: 8px; display: flex; gap: .6rem; align-items: center; }
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--panel-2); color: var(--text); }
.nav .section { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: .9rem .8rem .3rem; }
.sidebar-footer { border-top: 1px solid var(--border); padding: .9rem 1.2rem; display: flex; align-items: center; gap: .5rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; }
.main { flex: 1; min-width: 0; padding: 1.5rem 2rem 3rem; }
.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.menu-toggle { display: none; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .section { display: none; }
  .main { padding: 1rem; }
}

/* ---------- Komponenten ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.card + .card { margin-top: 1rem; }
.card-title { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.card-title h2, .card-title h3 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: #3a4a5e; background: #223040; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: transparent; border-color: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: #451a1a; border-color: var(--danger); }
.btn-warn { background: transparent; border-color: #78350f; color: #fcd34d; }
.btn-warn:hover { background: #3b2a10; }
.btn-sm { padding: .3rem .6rem; font-size: 13px; }
.btn-icon { padding: .3rem .5rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); border-color: var(--border); }

label { display: block; font-weight: 500; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: .55rem .7rem; border-radius: 8px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 197, 94, .15); }
input:disabled, select:disabled { opacity: .55; }
textarea { font-family: var(--mono); resize: vertical; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
td.actions { text-align: right; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.online { color: var(--accent); background: rgba(34, 197, 94, .12); }
.pill.starting, .pill.stopping, .pill.installing { color: var(--warn); background: rgba(245, 158, 11, .12); }
.pill.offline { color: var(--muted); }
.pill.failed { color: var(--danger); background: rgba(239, 68, 68, .12); }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: 12px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.badge.admin { color: #fcd34d; border-color: #78350f; }

.alert { padding: .7rem .9rem; border-radius: 8px; border: 1px solid; margin-bottom: 1rem; }
.alert-error { border-color: #7f1d1d; background: rgba(239, 68, 68, .08); color: #fca5a5; }
.alert-warn { border-color: #78350f; background: rgba(245, 158, 11, .08); color: #fcd34d; }
.alert-info { border-color: #1e3a8a; background: rgba(59, 130, 246, .08); color: #93c5fd; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.loading { padding: 2rem; color: var(--muted); text-align: center; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; padding: 0 0 1.25rem; font-size: 1.4rem; }

/* ---------- Dashboard ---------- */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.server-card { display: flex; flex-direction: column; gap: .7rem; cursor: pointer; transition: border-color .15s; }
.server-card:hover { border-color: #3a4a5e; }
.server-card .name { font-weight: 600; font-size: 1.05rem; }
.server-meta { display: flex; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.meter { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); transition: width .4s; }
.sys-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font-size: 1.3rem; font-weight: 600; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: 12px; }

/* ---------- Server-Ansicht ---------- */
.server-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.server-head .title { flex: 1; min-width: 240px; }
.server-head .title h1 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

.console { background: #0a0e14; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.console-out {
  height: 52vh; min-height: 300px; overflow-y: auto; padding: .8rem 1rem; font: 13px/1.45 var(--mono);
  white-space: pre-wrap; word-break: break-word;
}
.console-out .l-warn { color: #fcd34d; }
.console-out .l-error { color: #f87171; }
.console-out .l-panel { color: #4ade80; }
.console-out .l-cmd { color: #93c5fd; }
.console-form { display: flex; border-top: 1px solid var(--border); }
.console-form span { padding: .6rem .2rem .6rem 1rem; color: var(--accent); font-family: var(--mono); }
.console-form input { border: none; border-radius: 0; background: transparent; font-family: var(--mono); box-shadow: none !important; }
.console-form .btn { border-radius: 0; border: none; border-left: 1px solid var(--border); }

.breadcrumb { display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.breadcrumb a { padding: .15rem .3rem; border-radius: 4px; }
.breadcrumb a:hover { background: var(--panel-2); text-decoration: none; }
.file-table td.name a { color: var(--text); display: inline-flex; align-items: center; gap: .5rem; }
.file-table td.name a:hover { color: var(--accent); }
.file-table .ico { width: 18px; text-align: center; }
.file-table tr.selected { background: rgba(34, 197, 94, .06); }
.drop-zone { position: relative; }
.drop-zone.dragging::after {
  content: "Dateien hier ablegen zum Hochladen"; position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(13, 17, 23, .85); border: 2px dashed var(--accent); border-radius: var(--radius); color: var(--accent); font-weight: 600; font-size: 1.1rem;
}
.upload-progress { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; margin-top: .5rem; }
.upload-progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.editor-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
#editor, .editor-fallback { height: 65vh; min-height: 320px; width: 100%; font-size: 13px; }
.editor-fallback { border: none; border-radius: 0; background: #0a0e14; }

.props-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .25rem 1.25rem; }
.props-grid .field { margin-bottom: .6rem; }
.props-grid label { font-family: var(--mono); font-size: 12.5px; font-weight: 400; color: var(--muted); }

.danger-zone { border-color: #7f1d1d; }

.pack-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem; max-height: 380px; overflow-y: auto; margin-bottom: 1rem; }
.pack-item {
  display: flex; gap: .7rem; align-items: flex-start; text-align: left; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .55rem; color: var(--text); cursor: pointer; font: inherit;
}
.pack-item:hover { border-color: #3a4a5e; }
.pack-item.selected { border-color: var(--accent); background: rgba(34, 197, 94, .08); }
.pack-item img, .pack-item .pack-icon { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--panel-2); }
.pack-item > span { display: flex; flex-direction: column; gap: .1rem; }
.pack-item .name { font-weight: 600; }
.pack-item .summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Modal & Toasts ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 50; padding: 1rem; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.modal.wide { max-width: 720px; }
.modal-head { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 1.2rem; }
.modal-foot { padding: .9rem 1.2rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }
@keyframes fade { from { opacity: 0; } }

#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--info); padding: .7rem 1rem; border-radius: 8px; min-width: 240px; max-width: 380px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: slide .2s; }
.toast.success { border-left-color: var(--accent); }
.toast.error { border-left-color: var(--danger); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }
