/* Server-Leitstand - schlicht, handytauglich, hell/dunkel. Keine Inline-Styles (CSP). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e6;
  --text: #1b1f24;
  --muted: #5d6673;
  --accent: #2459d6;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e3f4ea;
  --warn: #9a6200;
  --warn-bg: #fdf1d8;
  --bad: #c22d2d;
  --bad-bg: #fbe5e5;
  --idle: #5d6673;
  --idle-bg: #eceef1;
  --log-bg: #11151a;
  --log-text: #d7dde4;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2b323c; --text: #e6e9ee; --muted: #9aa4b1;
    --accent: #6b9bff; --accent-text: #0b1020; --ok: #4cc685; --ok-bg: #133222; --warn: #f0b44a; --warn-bg: #352812;
    --bad: #ff7676; --bad-bg: #3a1717; --idle: #9aa4b1; --idle-bg: #232932; --log-bg: #0a0d10; --log-text: #cfd6de;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2b323c; --text: #e6e9ee; --muted: #9aa4b1;
  --accent: #6b9bff; --accent-text: #0b1020; --ok: #4cc685; --ok-bg: #133222; --warn: #f0b44a; --warn-bg: #352812;
  --bad: #ff7676; --bad-bg: #3a1717; --idle: #9aa4b1; --idle-bg: #232932; --log-bg: #0a0d10; --log-text: #cfd6de;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.08rem; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 1.02rem; min-width: 0; }
.brand { overflow: hidden; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img, .brand .tag { flex-shrink: 0; }
.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#who { font-size: .9rem; margin-right: 4px; }

main { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

/* Knoepfe */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 560; padding: 8px 14px; border-radius: 9px; min-height: 40px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn.primary:disabled { opacity: .55; cursor: not-allowed; background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.icon { width: 40px; padding: 0; font-size: 1.1rem; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: .9rem; }

/* Host-Kennzahlen */
.host { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.tile .label { font-size: .8rem; color: var(--muted); }
.tile .value { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .hint, .login .hint { font-size: .8rem; color: var(--muted); font-weight: normal; }
.meter { height: 5px; background: var(--surface-2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.meter.hot > i { background: var(--warn); }
.meter.crit > i { background: var(--bad); }
.w0 { width: 0 } .w5 { width: 5% } .w10 { width: 10% } .w15 { width: 15% } .w20 { width: 20% } .w25 { width: 25% }
.w30 { width: 30% } .w35 { width: 35% } .w40 { width: 40% } .w45 { width: 45% } .w50 { width: 50% } .w55 { width: 55% }
.w60 { width: 60% } .w65 { width: 65% } .w70 { width: 70% } .w75 { width: 75% } .w80 { width: 80% } .w85 { width: 85% }
.w90 { width: 90% } .w95 { width: 95% } .w100 { width: 100% }

/* Hinweise */
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--border); }
.tag { font-size: .75rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }

/* Server-Karten */
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head .sub { font-size: .85rem; margin-top: 2px; overflow-wrap: anywhere; }
.state { font-size: .82rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.running { background: var(--ok-bg); color: var(--ok); }
.state.starting, .state.stopping { background: var(--warn-bg); color: var(--warn); }
.state.crashed, .state.failed { background: var(--bad-bg); color: var(--bad); }
.state.stopped, .state.missing, .state.unknown { background: var(--idle-bg); color: var(--idle); }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: .76rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts dd small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.facts .wide { grid-column: span 3; }
.yes { color: var(--ok); }
.no { color: var(--bad); }

.busy { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-weight: 600; display: flex; gap: 8px; align-items: center; }
.busy::before { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.last { margin: 0; font-size: .85rem; }
.last.err { color: var(--bad); }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }

/* Panels (Log, Protokoll) */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 10px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.panel-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select, input[type="text"], input[type="password"] {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 10px; min-height: 38px;
}
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: .92rem; cursor: pointer; }
pre.log {
  margin: 0; background: var(--log-bg); color: var(--log-text); border-radius: 9px; padding: 10px 12px; max-height: 60vh; min-height: 120px;
  overflow: auto; font: 12.5px/1.45 ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.audit { list-style: none; margin: 0; padding: 0; display: grid; }
.audit li { display: grid; grid-template-columns: 9.5em 1fr; gap: 2px 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: .88rem; }
.audit li:first-child { border-top: 0; }
.audit .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.audit .what b { font-weight: 650; }
.audit .bad { color: var(--bad); }
.audit .det { grid-column: 2; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }

/* Dialog + Meldung */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 18px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog p { color: var(--muted); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); color: #fff; }

/* Anmeldung */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(100%, 380px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login .brand { font-size: 1.2rem; }
.login label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.login input { width: 100%; font-size: 16px; }
.login .error { color: var(--bad); margin: 0; min-height: 1.4em; font-size: .92rem; }
.login .foot { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }

@media (max-width: 560px) {
  main { padding: 12px 16px 24px; gap: 12px; }
  .host { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts .wide { grid-column: span 2; }
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn { min-height: 44px; }
  #who { display: none; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: .95rem; gap: 6px; }
  .tag { font-size: .68rem; padding: 2px 6px; }
  .top-actions .btn { min-height: 40px; }
  #logoutBtn { padding: 6px 8px; }
  .audit li { grid-template-columns: 1fr; }
  .audit .det { grid-column: 1; }
}
