:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --primary: #3b82f6;
  --up: #22c55e;
  --down: #ef4444;
  --warn: #f59e0b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.container-wide { max-width: 1280px; }
.nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.nav .brand { font-weight: 700; color: var(--text); margin-right: auto; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--down); }
input, select, textarea {
  width: 100%;
  padding: 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.75rem;
}
label { display: block; margin-bottom: 0.25rem; color: var(--muted); font-size: 0.9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-up { background: rgba(34,197,94,0.2); color: var(--up); }
.badge-down { background: rgba(239,68,68,0.2); color: var(--down); }
.badge-unknown { background: rgba(139,156,179,0.2); color: var(--muted); }
.status-banner {
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
.status-operational { background: rgba(34,197,94,0.15); color: var(--up); }
.status-major { background: rgba(239,68,68,0.15); color: var(--down); }
.uptime-bar {
  display: flex;
  gap: 2px;
  height: 28px;
  margin-top: 0.5rem;
}
.uptime-bar span {
  flex: 1;
  border-radius: 2px;
  min-width: 3px;
}
.uptime-bar .up { background: var(--up); }
.uptime-bar .mid { background: var(--warn); }
.uptime-bar .down { background: var(--down); }
.uptime-bar .empty { background: var(--border); }
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-error { background: rgba(239,68,68,0.15); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.15); color: #86efac; }
.alert-info { background: rgba(59,130,246,0.15); color: #93c5fd; }
.hero { text-align: center; padding: 4rem 1.5rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.hero p { color: var(--muted); max-width: 520px; margin: 0 auto 2rem; }
.tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.tabs a {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}
.tabs a.active { background: var(--primary); color: #fff; text-decoration: none; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--border); }
.dns-box {
  font-family: monospace;
  font-size: 0.85rem;
  background: var(--bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
}

/* Öffentliche Status-Seite */
.status-page { max-width: 800px; }
.section-title { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; color: var(--text); }
.meta-line { color: var(--muted); font-size: 0.85rem; margin: 0.35rem 0 0; display: block; }
.owner-message { border-left: 4px solid var(--primary); }
.owner-message.owner-maintenance { border-left-color: var(--warn); }
.owner-message.owner-major { border-left-color: var(--down); }
.owner-title { margin: 0 0 0.5rem; font-size: 1.15rem; }
.owner-body { color: var(--text); line-height: 1.6; }
.service-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.uptime-section { margin-top: 0.5rem; }
.uptime-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--muted); }
.uptime-pct { color: var(--up); font-size: 1rem; }
.uptime-grid {
  display: flex;
  gap: 2px;
  height: 34px;
  align-items: stretch;
}
.uptime-day {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  cursor: help;
  transition: transform 0.1s;
}
.uptime-day:hover { transform: scaleY(1.15); }
.uptime-up { background: var(--up); }
.uptime-mid { background: var(--warn); }
.uptime-down { background: var(--down); }
.uptime-none { background: var(--border); opacity: 0.45; }
.uptime-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.uptime-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.uptime-legend .dot.up { background: var(--up); }
.uptime-legend .dot.mid { background: var(--warn); }
.uptime-legend .dot.down { background: var(--down); }
.uptime-legend .dot.none { background: var(--border); }
.uptime-range { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }
.incident-card { border-left: 4px solid var(--warn); }
.incident-msg { margin: 0.5rem 0 0; line-height: 1.55; }
.badge-incident { background: rgba(245,158,11,0.2); color: var(--warn); }
.update-card { border-left: 3px solid var(--border); }
.update-maintenance { border-left-color: var(--warn); }
.update-investigating { border-left-color: var(--warn); }
.update-resolved { border-left-color: var(--up); }
.update-info { border-left-color: var(--primary); }
.badge-update { background: rgba(139,156,179,0.2); color: var(--muted); text-transform: capitalize; }
.update-body { margin: 0.5rem 0; line-height: 1.55; }
.powered-by { text-align: center; color: var(--muted); margin-top: 2.5rem; font-size: 0.85rem; }

/* Monitor-Reihenfolge (Drag + Positionsnummer) */
.monitor-sort-hint { margin-bottom: 1rem; }
.monitor-row { transition: background 0.15s; }
.monitor-row.dragging { opacity: 0.45; background: rgba(59, 130, 246, 0.08); }
.monitor-row.drag-over-top td { box-shadow: inset 0 2px 0 var(--primary); }
.monitor-row.drag-over-bottom td { box-shadow: inset 0 -2px 0 var(--primary); }
.sort-cell { white-space: nowrap; vertical-align: middle; }
.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  color: var(--muted);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  font-size: 1rem;
  line-height: 1;
  letter-spacing: -2px;
  touch-action: none;
}
.drag-handle:hover { background: var(--border); color: var(--text); }
.drag-handle:active { cursor: grabbing; }
.monitor-sort-list.drag-active { cursor: grabbing; }
.monitor-row[draggable="true"] .drag-handle { cursor: grab; }
.pos-input {
  width: 3.25rem;
  margin: 0;
  padding: 0.35rem 0.4rem;
  text-align: center;
  font-size: 0.9rem;
}
.pos-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
#sort-toast[hidden] { display: none !important; }

/* Bereiche (Monitor-Gruppen) */
.bereiche-panel { margin-bottom: 1.25rem; }
.bereiche-panel h3 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.bereiche-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.bereiche-form input { flex: 1; min-width: 180px; margin-bottom: 0; }
.bereiche-form .btn { margin-bottom: 0; white-space: nowrap; }
.group-list { list-style: none; margin: 0; padding: 0; }
.group-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.group-list-item:last-child { border-bottom: none; }
.group-name-form { display: flex; gap: 0.5rem; flex: 1; min-width: 200px; align-items: center; }
.group-name-form input { margin: 0; flex: 1; }
.group-pos-input { width: 3rem; margin: 0; padding: 0.35rem; text-align: center; }
.monitor-bereich { padding: 0; overflow: visible; margin-bottom: 1.25rem; }
.monitor-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 0.25rem;
}
.monitor-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}
.monitor-table th,
.monitor-table td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.monitor-table th { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.monitor-table .col-target {
  max-width: 220px;
}
.monitor-table .col-target code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}
.monitor-table .col-actions {
  min-width: 200px;
  white-space: nowrap;
  position: sticky;
  right: 0;
  background: var(--surface);
  box-shadow: -8px 0 12px rgba(15, 20, 25, 0.35);
}
.monitor-table thead .col-actions {
  background: rgba(59, 130, 246, 0.06);
}
.monitor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.monitor-actions .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  margin: 0;
}
.monitor-group-select {
  width: 100%;
  min-width: 130px;
  max-width: 180px;
  margin: 0;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .container-wide { padding: 1rem; }
  .monitor-table-scroll { overflow: visible; }
  .monitor-table {
    min-width: 0;
    display: block;
  }
  .monitor-table thead { display: none; }
  .monitor-table tbody { display: block; }
  .monitor-table .monitor-row {
    display: block;
    margin: 0 0.75rem 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
  }
  .monitor-table .monitor-row td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border: none;
    border-bottom: 1px solid rgba(45, 58, 79, 0.5);
  }
  .monitor-table .monitor-row td:last-child { border-bottom: none; }
  .monitor-table .monitor-row td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
    min-width: 4.5rem;
  }
  .monitor-table .col-target { max-width: none; }
  .monitor-table .col-target code {
    white-space: normal;
    word-break: break-all;
    text-align: right;
  }
  .monitor-table .col-actions {
    min-width: 0;
    position: static;
    box-shadow: none;
    background: transparent;
    flex-direction: column;
    align-items: stretch;
  }
  .monitor-table .col-actions::before { display: none; }
  .monitor-actions {
    width: 100%;
    flex-direction: column;
  }
  .monitor-actions .btn,
  .monitor-actions form { width: 100%; }
  .monitor-actions form button { width: 100%; }
  .monitor-group-select { max-width: none; width: 100%; }
  .sort-controls { justify-content: flex-end; }
}
.monitor-bereich-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: rgba(59, 130, 246, 0.06);
  border-bottom: 1px solid var(--border);
}
.monitor-bereich-head h3 { margin: 0; font-size: 1.1rem; }
.monitor-bereich-meta { color: var(--muted); font-size: 0.85rem; }
.monitor-bereich-empty {
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}
.status-group { margin-bottom: 2rem; }
.status-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}
.status-group-head .section-title { margin: 0; font-size: 1.25rem; }
.status-group .service-card { margin-bottom: 0.75rem; }
.status-group .service-card:last-child { margin-bottom: 0; }
