/* ==========================================================================
   Server-Monitor - Design-System
   Dark Mode ist Standard; [data-theme="light"] am <html> schaltet um.
   Alle Farben laufen ueber Custom Properties, damit der Themewechsel
   ohne Neuzeichnen der Komponenten funktioniert.
   ========================================================================== */

:root {
  /* Flaechen */
  --bg: #080b12;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #16203a 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #14243a 0%, transparent 55%);
  --surface: #0f1520;
  --surface-2: #131a28;
  --surface-3: #182132;
  --border: #1e2839;
  --border-strong: #2b3850;

  /* Text */
  --text: #e8eef8;
  --text-dim: #93a1b8;
  --text-faint: #64748b;

  /* Akzente */
  --accent: #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --ok: #22c58b;
  --ok-soft: rgba(34, 197, 139, 0.14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --danger: #f4506b;
  --danger-soft: rgba(244, 80, 107, 0.14);
  --purple: #a279f5;
  --cyan: #35c6e5;

  /* Metrik-Farben (konsistent ueber Charts und Cards) */
  --c-cpu: #4c8dff;
  --c-mem: #a279f5;
  --c-temp: #f5a524;
  --c-net-rx: #22c58b;
  --c-net-tx: #35c6e5;
  --c-disk: #f4506b;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.22);
  --sidebar-w: 236px;
  --header-h: 60px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #f2f5fa;
  --bg-grad: radial-gradient(1100px 550px at 12% -12%, #dfe9fb 0%, transparent 60%),
             radial-gradient(900px 460px at 100% 0%, #e4f0f7 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eef2f9;
  --border: #dde4ef;
  --border-strong: #c6d1e2;

  --text: #101828;
  --text-dim: #566175;
  --text-faint: #8994a6;

  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --ok: #0f9d63;
  --ok-soft: rgba(15, 157, 99, 0.12);
  --warn: #c77700;
  --warn-soft: rgba(199, 119, 0, 0.12);
  --danger: #d92d4f;
  --danger-soft: rgba(217, 45, 79, 0.1);
  --purple: #7c4ddb;
  --cyan: #0f8ba8;

  --c-cpu: #2563eb;
  --c-mem: #7c4ddb;
  --c-temp: #c77700;
  --c-net-rx: #0f9d63;
  --c-net-tx: #0f8ba8;
  --c-disk: #d92d4f;

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 22px rgba(16, 24, 40, 0.07);
  color-scheme: light;
}

/* --------------------------------------------------------------- Basis -- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.011em;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------- Layout -- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar ---------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  /* Deckend statt transluzent mit backdrop-filter: hinter der Sidebar
     scrollt nichts, der Weichzeichner braeuchte also nur Rechenzeit - und
     Chrome zeichnet die Backdrop-Ebene beim Themewechsel nicht zuverlaessig
     neu, wodurch die Sidebar im hellen Design dunkel stehen bleibt. */
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--header-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent), var(--purple));
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(76, 141, 255, 0.35);
}

.brand-mark svg {
  width: 17px;
  height: 17px;
  color: #fff;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.13s ease, color 0.13s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-badge {
  margin-left: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}

.nav-badge.warn {
  background: var(--warn);
  color: #1a1206;
}

.nav-badge[hidden] {
  display: none;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.conn-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
  animation: pulse 1.4s ease-in-out infinite;
}

.conn-dot.connecting {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

.conn-text {
  font-size: 11.5px;
  color: var(--text-faint);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hauptbereich ----------------------------------------------------------- */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 16px;
  font-weight: 650;
}

.page-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: -1px;
}

.topbar-spacer {
  flex: 1;
}

.topbar-clock {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  transition: all 0.13s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.menu-btn {
  display: none;
}

.content {
  flex: 1;
  padding: 22px;
  max-width: 1700px;
  width: 100%;
}

/* ------------------------------------------------------------ Bausteine -- */

.grid {
  display: grid;
  gap: 14px;
}

/* 196px als Mindestbreite gewaehlt, damit auf einem 1440er-Bildschirm alle
   sechs KPI-Cards in eine Reihe passen und darunter keine halbleere Zeile
   entsteht. */
.grid-kpi {
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s ease;
}

.card-pad {
  padding: 16px 18px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h3 {
  font-size: 13px;
  font-weight: 620;
  letter-spacing: -0.005em;
}

.card-head .spacer {
  flex: 1;
}

.card-title-icon {
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  flex-shrink: 0;
}

/* Alarmzustand einer Card */
.card.is-warn {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--border));
}
.card.is-warn::after,
.card.is-crit::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius);
}
.card.is-warn::after {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent),
              inset 0 24px 44px -30px var(--warn);
}
.card.is-crit {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--border));
  animation: critGlow 2.4s ease-in-out infinite;
}
.card.is-crit::after {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 40%, transparent),
              inset 0 24px 44px -30px var(--danger);
}

@keyframes critGlow {
  50% { border-color: color-mix(in srgb, var(--danger) 90%, var(--border)); }
}

/* KPI-Card --------------------------------------------------------------- */

.kpi {
  padding: 15px 17px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 126px;
}

.kpi-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.kpi-icon {
  width: 14px;
  height: 14px;
  color: var(--text-faint);
}

.kpi-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}

.kpi-badge.ok { background: var(--ok-soft); color: var(--ok); }
.kpi-badge.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-badge.danger { background: var(--danger-soft); color: var(--danger); }

.kpi-value {
  font-size: 29px;
  font-weight: 640;
  line-height: 1.05;
  letter-spacing: -0.028em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.kpi-unit {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0;
}

.kpi-meta {
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.kpi-spark {
  height: 34px;
  margin: -2px -3px -4px;
}

/* Fortschrittsbalken ----------------------------------------------------- */

.bar {
  height: 6px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  width: 0%;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

.bar-fill.ok { background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }

.bar.thin { height: 4px; }

/* Segmentierter Balken (CPU-Kerne) --------------------------------------- */

.cores {
  display: grid;
  gap: 7px;
}

.core-row {
  display: grid;
  grid-template-columns: 30px 1fr 42px;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* Charts ----------------------------------------------------------------- */

.chart-box {
  position: relative;
  width: 100%;
}

.chart-box canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  padding: 0 18px 13px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11.5px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.1s ease;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip.visible {
  opacity: 1;
}

.chart-tooltip .tt-time {
  color: var(--text-faint);
  font-size: 10.5px;
  margin-bottom: 3px;
}

.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Tabellen --------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 2;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text-dim);
}

th.sortable::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
  vertical-align: middle;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  opacity: 0;
}

th.sort-asc::after {
  opacity: 1;
  border-bottom: 4.5px solid var(--accent);
}

th.sort-desc::after {
  opacity: 1;
  border-top: 4.5px solid var(--accent);
}

tbody td {
  padding: 8px 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: var(--surface-2);
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 12.5px;
}

td.grow {
  min-width: 220px;
  max-width: 520px;
  width: 100%;
}

/* Kommandozeilen koennen sehr lang sein. Einzeilig mit Ellipse halten die
   Tabellenzeilen kompakt; der vollstaendige Text steht im title-Attribut. */
.truncate {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-strong {
  font-weight: 550;
}

.cell-dim {
  color: var(--text-faint);
  font-size: 12px;
}

/* Status-Punkte und Pills ------------------------------------------------ */

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: baseline;
  background: var(--text-faint);
  flex-shrink: 0;
}

.dot.ok { background: var(--ok); box-shadow: 0 0 6px color-mix(in srgb, var(--ok) 60%, transparent); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }
.dot.idle { background: var(--text-faint); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}

.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--accent-soft); color: var(--accent); }

/* Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  transition: all 0.13s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 85%, #fff);
  border-color: color-mix(in srgb, var(--accent) 85%, #fff);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.btn-group {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.btn-group button {
  padding: 4px 11px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-dim);
  transition: all 0.13s ease;
}

.btn-group button:hover {
  color: var(--text);
}

.btn-group button.active {
  background: var(--accent);
  color: #fff;
}

/* Formulare -------------------------------------------------------------- */

.input,
select.input {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder {
  color: var(--text-faint);
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 150px;
  max-width: 330px;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-wrap .input {
  padding-left: 31px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-dim);
}

.field .hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background 0.18s ease;
  pointer-events: none;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(17px);
  background: #fff;
}

/* Toolbar ---------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* Modal ------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.68);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fadeIn 0.14s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  width: min(460px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 0;
}

.modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-icon.warn { background: var(--warn-soft); color: var(--warn); }
.modal-icon.info { background: var(--accent-soft); color: var(--accent); }

.modal-icon svg {
  width: 19px;
  height: 19px;
}

.modal h3 {
  font-size: 15.5px;
  margin-bottom: 3px;
}

.modal-body {
  padding: 12px 20px 0;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}

.modal-detail {
  margin-top: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 12.5px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 2.5px 0;
}

.detail-row .k {
  color: var(--text-faint);
  flex-shrink: 0;
}

.detail-row .v {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-align: right;
  word-break: break-all;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 18px 20px;
}

/* Toasts ----------------------------------------------------------------- */

.toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  animation: toastIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.closing {
  animation: toastOut 0.18s ease forwards;
}

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
}

@keyframes toastOut {
  to { transform: translateX(20px); opacity: 0; }
}

.toast-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast.ok { border-left: 3px solid var(--ok); }
.toast.ok .toast-icon { color: var(--ok); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.info .toast-icon { color: var(--accent); }

/* Listen und Detailblöcke ------------------------------------------------ */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 26px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  font-size: 13px;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .k {
  color: var(--text-faint);
  font-size: 12.5px;
  flex-shrink: 0;
}

.info-row .v {
  text-align: right;
  font-weight: 500;
  word-break: break-word;
  min-width: 0;
}

.mount-list {
  display: flex;
  flex-direction: column;
}

.mount-item {
  padding: 13px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.mount-item:last-child {
  border-bottom: none;
}

.mount-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.mount-name {
  font-weight: 600;
  font-size: 13.5px;
  font-family: var(--mono);
}

.mount-stats {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

.empty svg {
  width: 34px;
  height: 34px;
  margin-bottom: 11px;
  opacity: 0.4;
}

.error-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 14px;
}

.error-box svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.notice-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
  margin-bottom: 14px;
}

.notice-box svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--text-faint);
}

/* Skeleton beim ersten Laden --------------------------------------------- */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
  color: transparent !important;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* Alert-Liste ------------------------------------------------------------ */

.alert-item {
  display: flex;
  gap: 13px;
  padding: 13px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  align-items: flex-start;
}

.alert-item:last-child {
  border-bottom: none;
}

.alert-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.alert-mark svg {
  width: 16px;
  height: 16px;
}

.alert-mark.critical { background: var(--danger-soft); color: var(--danger); }
.alert-mark.warning { background: var(--warn-soft); color: var(--warn); }
.alert-mark.resolved { background: var(--surface-3); color: var(--text-faint); }

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: 550;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.alert-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Login ------------------------------------------------------------------ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  padding: 32px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  margin-bottom: 26px;
}

.login-brand .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}

.login-brand .brand-mark svg {
  width: 25px;
  height: 25px;
}

.login-brand h1 {
  font-size: 19px;
  text-align: center;
}

.login-brand p {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-form .btn {
  padding: 10px;
  font-size: 14px;
  margin-top: 4px;
}

.login-error {
  display: none;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 12.5px;
}

.login-error.visible {
  display: block;
}

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* Verbindungsbanner ------------------------------------------------------ */

.offline-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 22px;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  animation: slideDown 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { transform: translate(-50%, -18px); opacity: 0; }
}

.offline-banner svg {
  width: 15px;
  height: 15px;
}

.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* -------------------------------------------------------------- Responsive */

.backdrop {
  display: none;
}

@media (max-width: 1000px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 268px;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
    background: var(--surface);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .backdrop.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 12, 0.6);
    z-index: 35;
    animation: fadeIn 0.16s ease;
  }

  .menu-btn {
    display: grid;
  }

  .content {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
    gap: 11px;
  }
}

@media (max-width: 700px) {
  .grid-kpi {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 25px;
  }

  .topbar-clock {
    display: none;
  }

  .content {
    padding: 13px;
  }

  .card-head,
  .card-pad {
    padding-left: 14px;
    padding-right: 14px;
  }

  .toolbar {
    gap: 8px;
  }

  .search-wrap {
    max-width: none;
    flex-basis: 100%;
  }
}

@media (max-width: 460px) {
  .grid-kpi {
    grid-template-columns: 1fr;
  }

  .page-sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .sidebar, .topbar, .toolbar, .backdrop, .toasts { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { break-inside: avoid; }
}
