:root {
  --bg: #f4f6fa; --card: #fff; --ink: #1b2233; --muted: #6b7489; --line: #e3e7ef;
  --nav: #14213d; --nav-ink: #c9d2e6; --accent: #2f6fed;
  --crit: #d93a3a; --warn: #e8890c; --info: #2f6fed; --ok: #22a06b; --off: #8a93a6; --pend: #b0b7c6;
  --crit-bg: #fdecec; --warn-bg: #fff4e3; --info-bg: #eaf1fe; --ok-bg: #e6f6ee; --off-bg: #eef0f4;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--crit); min-height: 1.2em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--nav); }
.login-box { background: #fff; padding: 32px; border-radius: 14px; width: 320px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: #fff; padding: 18px 18px 22px; }
.brand img { width: 28px; height: 28px; }
.brand.big { color: var(--ink); font-size: 22px; padding: 0 0 8px; justify-content: center; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c5d6fb; border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; }
textarea { min-height: 80px; resize: vertical; }

/* Buttons */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f0f3f8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #255fd6; }
.btn.danger { color: var(--crit); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }

/* Layout */
#app { display: flex; min-height: 100vh; }
#side { width: 220px; background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 20; }
#side nav { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; flex: 1; }
#side nav a { color: var(--nav-ink); padding: 9px 12px; border-radius: 7px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
#side nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
#side nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.side-foot { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid rgba(255,255,255,.1); }
.side-foot .btn { color: var(--nav-ink); }
.pill { background: var(--crit); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.pill:empty { display: none; }
#main { flex: 1; margin-left: 220px; min-width: 0; }
#top { display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
#top h1 { font-size: 18px; margin: 0; flex: 1; }
#menuBtn { display: none; font-size: 18px; }
#view { padding: 24px 28px 60px; max-width: 1500px; }

/* Karten & Raster */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; cursor: pointer; border-left: 4px solid var(--line); }
.kpi:hover { box-shadow: 0 2px 10px rgba(20,33,61,.08); }
.kpi .n { font-size: 28px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi.crit { border-left-color: var(--crit); } .kpi.crit .n { color: var(--crit); }
.kpi.warn { border-left-color: var(--warn); } .kpi.warn .n { color: var(--warn); }
.kpi.ok { border-left-color: var(--ok); } .kpi.ok .n { color: var(--ok); }
.kpi.off { border-left-color: var(--off); } .kpi.off .n { color: var(--off); }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1; min-width: 180px; max-width: 320px; }

/* Gerätekacheln */
.cust-group { margin-bottom: 22px; }
.cust-group h3 { display: flex; gap: 8px; align-items: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--ok); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; color: var(--ink); display: block; }
.tile:hover { box-shadow: 0 2px 12px rgba(20,33,61,.1); text-decoration: none; }
.tile .t-name { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.tile .t-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .t-sub { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.tile .t-bars { display: grid; grid-template-columns: 34px 1fr 38px; gap: 3px 6px; align-items: center; font-size: 11px; color: var(--muted); }
.st-critical { border-left-color: var(--crit) !important; } .st-warning { border-left-color: var(--warn) !important; }
.st-info { border-left-color: var(--info) !important; } .st-offline { border-left-color: var(--off) !important; } .st-pending { border-left-color: var(--pend) !important; }

/* Balken */
.bar { height: 7px; background: #edf0f5; border-radius: 4px; overflow: hidden; min-width: 50px; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.bar.w > i { background: var(--warn); } .bar.c > i { background: var(--crit); }
.bar.big { height: 10px; }

/* Status-Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.badge.critical, .badge.failed { background: var(--crit-bg); color: var(--crit); }
.badge.warning, .badge.partial { background: var(--warn-bg); color: #b86a00; }
.badge.info, .badge.running { background: var(--info-bg); color: var(--info); }
.badge.ok, .badge.success, .badge.normal { background: var(--ok-bg); color: var(--ok); }
.badge.offline, .badge.unknown, .badge.pending, .badge.resolved { background: var(--off-bg); color: var(--muted); }
.badge.acked { background: #efe9fb; color: #6a43c9; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ok); flex: none; }
.dot.critical { background: var(--crit); } .dot.warning { background: var(--warn); } .dot.info { background: var(--info); }
.dot.offline { background: var(--off); } .dot.pending { background: var(--pend); }

/* Tabellen */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #fafbfd; white-space: nowrap; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--ink); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f9fc; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }
.actions.nowrap { flex-wrap: nowrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Gerätedetail */
.host-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.host-head .meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 24px; flex: 1; }
.meta .k { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.meta .v { font-weight: 600; margin-top: 2px; word-break: break-word; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.ranges { display: flex; gap: 4px; }
.ranges .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.charts { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.chart { position: relative; }
.chart svg { width: 100%; height: 190px; display: block; }
.chart .legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.tip { position: fixed; pointer-events: none; background: #14213d; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; z-index: 100; white-space: nowrap; }
.gauges { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.gauge .n { font-size: 24px; font-weight: 700; }
.gauge .l { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
pre.raw { background: #0f1729; color: #d5def0; padding: 14px; border-radius: 8px; overflow: auto; max-height: 420px; font-size: 12px; }

/* Formulare */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 18px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: 13px; }
.cmd { display: flex; gap: 8px; align-items: stretch; }
.cmd code { flex: 1; background: #0f1729; color: #d5def0; padding: 10px 12px; border-radius: 8px; font-size: 12px; word-break: break-all; }
ol.steps { padding-left: 20px; line-height: 1.7; margin: 8px 0; }
.notice { background: var(--info-bg); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 10px 0; }
.notice.warn { background: var(--warn-bg); }

/* Modal & Toast */
.modal { position: fixed; inset: 0; background: rgba(15,23,41,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: #fff; border-radius: 12px; padding: 22px; width: 440px; max-width: 100%; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-box .btns { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #14213d; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; box-shadow: 0 4px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--crit); }

/* Bericht */
.report-host { break-inside: avoid; }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 10px; }

@media (max-width: 900px) {
  #side { transform: translateX(-100%); transition: transform .2s; }
  #side.open { transform: none; box-shadow: 4px 0 30px rgba(0,0,0,.3); }
  #main { margin-left: 0; }
  #menuBtn { display: inline-block; }
  #view { padding: 16px 14px 60px; }
  #top { padding: 12px 14px; }
  .two, .charts { grid-template-columns: minmax(0, 1fr); }
  .hide-m { display: none; }
}

@media print {
  #side, #top, .no-print, .toolbar { display: none !important; }
  #main { margin: 0; }
  #view { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: 1px solid #ccc; }
}
