:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #17212b;
  --muted: #6b7785;
  --line: #e2e7ee;
  --navy: #16324f;
  --ok: #1f9d55;
  --ok-bg: #eaf7ef;
  --ok-line: #bfe6cd;
  --warn: #e07a00;
  --warn-bg: #fff3e2;
  --warn-line: #ffd29a;
  --err: #d12b2b;
  --err-bg: #fdecec;
  --err-line: #f4b4b4;
  --grey: #8a96a3;
  --grey-bg: #f1f3f6;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
a { color: #1d5fa8; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 7px 12px; color: var(--ink); }
button:hover { border-color: #c5cdd8; }
button.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
button.primary:hover { background: #1f4570; }
button.ghost { background: transparent; border-color: transparent; color: #dfe8f2; }
button.ghost:hover { background: rgba(255,255,255,.1); }
button.danger { color: var(--err); border-color: var(--err-line); }
button.link { border: none; background: none; padding: 0; color: #1d5fa8; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #ccd4de; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ec; border-color: #6ea6dd; }
input[type=checkbox] { width: auto; }

/* Kopfzeile */
.top { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: .2px; }
.brand.big { font-size: 22px; color: var(--navy); }
.logo { width: 22px; height: 22px; border-radius: 6px; background: url("/favicon.svg") center/contain no-repeat; display: inline-block; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { color: #c9d6e4; text-decoration: none; padding: 8px 12px; border-radius: 8px; }
nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.top-right { display: flex; align-items: center; gap: 6px; }
.top-right .muted { color: #a9bccf; }
.banner { background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); color: #7a4300; padding: 10px 20px; }
.banner.err { background: var(--err-bg); border-color: var(--err-line); color: #8a1616; }
main { padding: 20px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* Zusammenfassung */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; background: #fff; border: 1px solid var(--line); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--grey); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.error, .dot.down { background: var(--err); }
.dot.down { animation: blinkdot 1s steps(2, start) infinite; }

/* Kacheln */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; align-items: start; }
.tile { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px 10px; box-shadow: 0 1px 2px rgba(20,40,60,.05); transition: box-shadow .15s; position: relative; }
.tile:hover { box-shadow: 0 4px 14px rgba(20,40,60,.08); }
.tile.lv-ok { background: var(--ok-bg); border-color: var(--ok-line); }
.tile.lv-warn { background: var(--warn-bg); border-color: var(--warn); }
.tile.lv-error { background: var(--err-bg); border-color: var(--err); }
.tile.lv-down { background: var(--err-bg); border-color: var(--err); animation: blinktile 1.2s ease-in-out infinite; }
.tile.lv-unknown, .tile.lv-off { background: var(--grey-bg); border-color: var(--line); }
.tile.dragging { opacity: .45; }
.tile.server-tile { border-style: dashed; }
@keyframes blinktile { 0%, 100% { background: #fde3e3; box-shadow: 0 0 0 0 rgba(209,43,43,.0); } 50% { background: #f6b3b3; box-shadow: 0 0 0 4px rgba(209,43,43,.25); } }
@keyframes blinkdot { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .tile.lv-down { animation-duration: 3s; } }

.t-head { display: flex; align-items: flex-start; gap: 8px; }
.t-title { flex: 1; min-width: 0; }
.t-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.handle { cursor: grab; color: #a4afbb; padding: 2px 2px; user-select: none; font-size: 16px; line-height: 1; }
.handle:active { cursor: grabbing; }
.star { border: none; background: none; padding: 0 2px; font-size: 18px; color: #c4ccd6; line-height: 1; }
.star.on { color: #f2b01e; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: #d2f0dd; color: #146c3b; }
.pill.warn { background: #ffe1b8; color: #8a4a00; }
.pill.error, .pill.down { background: #f8caca; color: #8f1616; }
.pill.unknown, .pill.off { background: #e3e8ee; color: #55616e; }

.reasons { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.reasons li { display: flex; gap: 6px; align-items: baseline; margin: 2px 0; }
.reasons li .dot { width: 8px; height: 8px; position: relative; top: 1px; }

.gauges { display: flex; gap: 6px; margin: 10px 0 4px; }
.gauge { flex: 1; text-align: center; position: relative; }
.gauge svg { width: 100%; max-width: 120px; height: auto; display: block; margin: 0 auto; }
.g-bg { fill: none; stroke: #dfe5ec; stroke-width: 8; stroke-linecap: round; }
.g-val { fill: none; stroke-width: 8; stroke-linecap: round; }
.g-ok { stroke: var(--ok); }
.g-warn { stroke: var(--warn); }
.g-err { stroke: var(--err); }
.g-num { font-weight: 600; font-size: 15px; margin-top: -22px; }
.g-num small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 2px; }
.g-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 8px; font-size: 13px; }
.fact .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.fact .v { font-weight: 500; }
.fact .v.warn { color: var(--warn); }
.fact .v.error { color: var(--err); }

.toggle { display: block; width: 100%; margin-top: 8px; border: none; background: transparent; color: var(--muted); padding: 4px; font-size: 16px; border-top: 1px solid rgba(0,0,0,.06); border-radius: 0; }
.toggle:hover { color: var(--ink); }
.details { margin-top: 6px; font-size: 13px; border-top: 1px solid rgba(0,0,0,.06); padding-top: 8px; }
.details h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 3px 10px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }
.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 4px; border-bottom: 1px solid rgba(0,0,0,.08); }
.mini td { padding: 3px 4px; border-bottom: 1px solid rgba(0,0,0,.04); vertical-align: top; }
pre.log { background: #1d2733; color: #e4ebf2; padding: 8px; border-radius: 8px; font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 160px; overflow: auto; margin: 4px 0 0; }

/* Leere Hinweise */
.empty { background: #fff; border: 1px dashed #c9d2dc; border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }

/* Tabellen */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 8px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
table.list tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; }

/* Formular */
.settings { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .settings { grid-template-columns: 1fr; } }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
.form .help { font-weight: 400; color: var(--muted); font-size: 12px; }
.form .checks { display: flex; gap: 20px; flex-wrap: wrap; }
.form .checks label { flex-direction: row; align-items: center; gap: 8px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.form-actions .spacer { flex: 1; }
.disc-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid #eef1f5; }
.disc-item:last-child { border-bottom: none; }
.disc-item .t { min-width: 0; }
.disc-item .t div:last-child { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disc-item button { padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.msg { min-height: 18px; font-size: 13px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

/* Server-Seite */
.server-top { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
@media (max-width: 900px) { .server-top { grid-template-columns: 1fr; } }
.bar { height: 10px; background: #e5eaf0; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar > span.warn { background: var(--warn); }
.bar > span.error { background: var(--err); }
.disk { margin-bottom: 12px; }
.disk .row { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 13px; }

/* Anmeldung */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 340px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 30px rgba(20,40,60,.08); }
.login-box p { margin: -8px 0 4px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 50; }
.toast.err { background: var(--err); }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 14px; }
  .form { grid-template-columns: 1fr; }
}
