:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f0f2ed;
  --surface-3: #e6e9e2;
  --border: #e0e3db;
  --text: #1b1f19;
  --muted: #687064;
  --faint: #8d9489;
  --accent: #3d8b3d;
  --accent-strong: #2e7330;
  --accent-soft: #e5f1e3;
  --accent-ink: #ffffff;
  --ok: #2f8a3a;
  --warn: #a86b00;
  --danger: #c0392b;
  --info: #2a6fb0;
  --term-bg: #10140f;
  --term-text: #d6dfd0;
  --shadow: 0 1px 2px rgb(0 0 0 / 5%), 0 6px 20px rgb(0 0 0 / 4%);
  --radius: 12px;
  --sidebar: 236px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111410;
    --surface: #181c17;
    --surface-2: #1f241d;
    --surface-3: #283026;
    --border: #2a3028;
    --text: #e5eae0;
    --muted: #9aa392;
    --faint: #737c6c;
    --accent: #5cb85c;
    --accent-strong: #78cb78;
    --accent-soft: #1f3320;
    --accent-ink: #0c130b;
    --ok: #66c56e;
    --warn: #e2a63c;
    --danger: #ef6b5b;
    --info: #6aa9e6;
    --term-bg: #0a0d09;
    --shadow: 0 1px 2px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111410;
  --surface: #181c17;
  --surface-2: #1f241d;
  --surface-3: #283026;
  --border: #2a3028;
  --text: #e5eae0;
  --muted: #9aa392;
  --faint: #737c6c;
  --accent: #5cb85c;
  --accent-strong: #78cb78;
  --accent-soft: #1f3320;
  --accent-ink: #0c130b;
  --ok: #66c56e;
  --warn: #e2a63c;
  --danger: #ef6b5b;
  --info: #6aa9e6;
  --term-bg: #0a0d09;
  --shadow: 0 1px 2px rgb(0 0 0 / 35%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .86em; }
img { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.text-bad { color: var(--danger); font-weight: 600; }

/* ================= Shell ================= */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.05rem; white-space: nowrap; padding: 0 8px; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent-strong); }
.brand-lg { font-size: 1.35rem; justify-content: center; margin-bottom: 8px; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background:
    linear-gradient(#4caf50 0 38%, transparent 38%),
    linear-gradient(90deg, #8a6440 0 20%, #6b4a2b 20% 60%, #57391f 60%);
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 18%);
}
.side-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side-group { margin: 16px 10px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 550;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.side-nav svg { width: 18px; height: 18px; flex: none; }
.side-nav .sub { margin-left: auto; font-size: .75rem; color: var(--faint); font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; margin: 0 4.5px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 6px 0; border-top: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 550; }
.who span:last-child { overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: .85rem;
}
.main { min-width: 0; }
.mobilebar { display: none; }
.view { max-width: 1180px; margin: 0 auto; padding: 32px 36px 96px; }

/* ================= Seitenkopf ================= */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 28px; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-title h2 { flex: 1; }

.meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: -8px 0 22px; color: var(--muted); font-size: .9rem; }
.meta b { color: var(--text); font-weight: 600; }
.copy { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .85rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; cursor: pointer; }
.copy:hover { border-color: var(--accent); }

/* ================= Karten ================= */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.grid > *, .grid-2 > * { min-width: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head h2 { flex: 1; }
.card-desc { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label, .kpi .label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .hint { color: var(--faint); font-size: .82rem; }

.big { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 14px; }
.big .num { font-size: 1.9rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big .num small { font-size: 1rem; font-weight: 600; color: var(--faint); }
.big .lbl { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--danger); }

.meter { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); }
.meter .bar { flex: 1; margin: 0; }
.meter b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }
.bar > span.warn { background: var(--warn); }
.bar > span.bad { background: var(--danger); }

details.more { margin-top: 12px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: .85rem; font-weight: 600; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.more summary::before { content: "▸"; transition: transform .15s; }
details.more[open] summary::before { transform: rotate(90deg); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; margin-top: 12px; }
.kpi .value { font-weight: 600; font-variant-numeric: tabular-nums; }

.proxy-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.proxy-row .grow { flex: 1; min-width: 200px; }

/* ================= Pills / Chips / Badges ================= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 650;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.pill.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 9px; border-radius: 6px; background: var(--surface-2); font-size: .85rem; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: .7rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; vertical-align: middle; white-space: nowrap; }
.badge.java { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.bedrock, .badge.info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.badge.safe, .badge.new { background: var(--accent-soft); color: var(--accent-strong); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.badge.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

/* ================= Buttons / Formulare ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible, .copy:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: 5px; font-weight: 550; font-size: .9rem; }
label.check, label.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.form-error { color: var(--danger); min-height: 1.2em; font-size: .9rem; }
.input-search { width: 100%; padding-left: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23889080' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center / 16px; }

/* Dropdown-Menü */
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgb(0 0 0 / 15%);
  padding: 6px; display: grid;
}
.menu-list button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; }
.menu-list button:hover { background: var(--surface-2); }
.menu-list .mono { color: var(--faint); margin-left: 6px; }

/* ================= Tabs ================= */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ================= Tabellen / Listen ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-item .desc { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .side { display: flex; align-items: center; gap: 6px; flex: none; }
.list-item.removed .title, .list-item.removed .desc { text-decoration: line-through; opacity: .55; }
.list-item.added { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.mod-icon { width: 40px; height: 40px; border-radius: 9px; flex: none; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.list-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.list-head h2 { flex: 1; }

/* Job-Fortschritt */
.job { border-left: 4px solid var(--info); }
.job.ok { border-left-color: var(--ok); }
.job.failed { border-left-color: var(--danger); }
.job.rolled_back { border-left-color: var(--warn); }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 8px; }
.step { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); font-size: .82rem; font-weight: 600; color: var(--muted); }
.step.running { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); }
.step.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.step.failed { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.changebar {
  position: fixed; left: calc(var(--sidebar) + 24px); right: 24px; bottom: 20px; z-index: 30;
  max-width: 1108px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 16px; box-shadow: 0 10px 40px rgb(0 0 0 / 25%);
}
.changebar .grow { flex: 1; min-width: 200px; }
.changebar .btn.ghost { color: var(--bg); }
.changebar .btn.ghost:hover { background: rgb(255 255 255 / 12%); }

.mapframe { width: 100%; height: calc(100vh - 320px); min-height: 460px; border: 1px solid var(--border); border-radius: var(--radius); background: #000; display: block; }

/* ================= Konsole ================= */
.console { display: flex; flex-direction: column; height: calc(100vh - 330px); min-height: 400px; }
.console-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.console-tools .input-search { width: 240px; }
.term {
  flex: 1; overflow: auto; background: var(--term-bg); color: var(--term-text);
  border-radius: var(--radius) var(--radius) 0 0; padding: 14px 16px;
  font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word;
}
.term .l-warn { color: #e6c06a; }
.term .l-err { color: #ff8a7a; }
.term .l-join { color: #8fd48f; }
.term .l-leave { color: #8e9a88; }
.term .l-cmd { color: #8cc4ff; }
.term .l-out { color: #ffffff; }
.cmdline { display: flex; background: var(--term-bg); border-radius: 0 0 var(--radius) var(--radius); border-top: 1px solid #253023; }
.cmdline span { padding: 11px 0 11px 16px; color: #5cb85c; font-family: var(--mono); }
.cmdline input { flex: 1; background: transparent; border: 0; color: var(--term-text); font-family: var(--mono); padding: 11px 12px; }
.cmdline input:focus { outline: none; }
.pre {
  background: var(--term-bg); color: var(--term-text); border-radius: var(--radius); padding: 14px 16px;
  font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 65vh; overflow: auto;
}

/* ================= Login ================= */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px; box-shadow: var(--shadow);
}
.code-input { font: 600 1.6rem/1 var(--mono); letter-spacing: .4em; text-align: center; padding: 10px; }

/* ================= Modal / Toasts ================= */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgb(0 0 0 / 45%); padding: 16px; }
.modal-card { background: var(--surface); border-radius: 16px; padding: 24px; width: min(460px, 100%); box-shadow: 0 10px 40px rgb(0 0 0 / 30%); }
.modal-card p { color: var(--muted); margin-top: 8px; white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toasts { position: fixed; right: 16px; top: 16px; z-index: 60; display: grid; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; }
.toast.bad { background: var(--danger); color: #fff; }

.empty { color: var(--muted); padding: 28px; text-align: center; }
.note { background: var(--surface-2); border-radius: 10px; padding: 12px 16px; color: var(--muted); font-size: .9rem; }
.note b { color: var(--text); }

/* ================= Mobil ================= */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); z-index: 40;
    transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgb(0 0 0 / 25%);
  }
  .sidebar.open { transform: none; }
  .mobilebar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .view { padding: 20px 16px 110px; }
  .grid, .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .console { height: 70vh; }
  .console-tools .input-search { width: 100%; }
  .changebar { left: 12px; right: 12px; bottom: 12px; }
}
