/* VPS Dashboard – Handy zuerst, Dark Mode über System oder Umschalter */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #dde2ea;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --crit: #dc2626;
  --ok-bg: #dcfce7;
  --warn-bg: #fef3c7;
  --crit-bg: #fee2e2;
  --none: #cbd5e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #18233b; --border: #24314d;
    --text: #e5e7eb; --muted: #94a3b8; --accent: #60a5fa;
    --ok: #22c55e; --warn: #f59e0b; --crit: #f87171;
    --ok-bg: #052e1a; --warn-bg: #3a2604; --crit-bg: #3b0d0d; --none: #334155;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #18233b; --border: #24314d;
  --text: #e5e7eb; --muted: #94a3b8; --accent: #60a5fa;
  --ok: #22c55e; --warn: #f59e0b; --crit: #f87171;
  --ok-bg: #052e1a; --warn-bg: #3a2604; --crit-bg: #3b0d0d; --none: #334155;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 24px 0 10px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* Kopfzeile + Navigation */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px;
  padding: 6px 9px; cursor: pointer; font-size: .9rem; line-height: 1;
}
.nav { display: none; }
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
  color: var(--muted); font-size: .68rem; position: relative;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav svg, .nav svg { width: 22px; height: 22px; }
.badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 9px; font-size: .72rem;
  font-weight: 600; background: var(--crit); color: #fff; text-align: center;
}
.bottom-nav .badge { position: absolute; top: 3px; left: 54%; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav a { display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 8px; color: var(--muted); }
  .nav a.active, .nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
  .nav svg { width: 18px; height: 18px; }
  main { padding: 24px; }
}

/* Karten, Kacheln */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.tile .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 1.6rem; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: .8rem; }
a.tile { color: inherit; }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.meter { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.meter > span.warn { background: var(--warn); }
.meter > span.crit { background: var(--crit); }

/* Ampel */
.status-hero {
  display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 14px;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.status-hero.ok { background: var(--ok-bg); }
.status-hero.warning { background: var(--warn-bg); }
.status-hero.critical { background: var(--crit-bg); }
.light { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px rgba(0,0,0,.06); }
.light.ok { background: var(--ok); } .light.warning { background: var(--warn); } .light.critical { background: var(--crit); }
.status-hero .title { font-weight: 700; font-size: 1.1rem; }

/* Status-Pillen */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.crit { background: var(--crit-bg); color: var(--crit); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.tag { font-size: .7rem; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.tag.new { background: var(--accent); color: #fff; }

/* Listen / Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr.dim td { opacity: .55; }
@media (max-width: 699px) {
  table.stack, table.stack tbody { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.stack td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: none; padding: 3px 2px; text-align: right; min-width: 0;
  }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; flex: none; text-align: left; }
  table.stack td.head { display: block; font-weight: 600; text-align: left; overflow-wrap: anywhere; }
  table.stack td.head::before { content: none; }
  table.stack td:empty, table.stack td.right:not([data-label]) { justify-content: flex-start; }
  table.stack .ubar { min-width: 0; flex: 1; max-width: 220px; }
}

.alert-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert-item:last-child { border-bottom: none; }
.alert-item .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.dot.critical { background: var(--crit); } .dot.warning { background: var(--warn); } .dot.resolved { background: var(--ok); }
.alert-item pre { margin: 2px 0 0; white-space: pre-wrap; font: inherit; color: var(--muted); font-size: .85rem; }

/* Uptime-Balken */
.ubar { display: flex; gap: 2px; height: 22px; align-items: stretch; min-width: 160px; }
.ubar span { flex: 1; border-radius: 2px; background: var(--none); }
.ubar span.ok { background: var(--ok); } .ubar span.warn { background: var(--warn); } .ubar span.crit { background: var(--crit); }

/* Formulare */
form.inline { display: inline; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=url], select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.fields { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .fields { grid-template-columns: repeat(3, 1fr); } .fields.two { grid-template-columns: repeat(2, 1fr); } }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; margin: 0; }
.check input { width: 18px; height: 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; border-color: var(--crit); color: var(--crit); }
.btn.small { padding: 4px 9px; font-size: .8rem; font-weight: 500; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.ok { color: var(--ok); } .err { color: var(--crit); } .warn-text { color: var(--warn); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--crit-bg); color: var(--crit); }
.hint { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--text); margin-bottom: 12px; }
.hint.error { background: var(--crit-bg); }

.section-nav { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; padding-bottom: 4px; }
.section-nav a { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  white-space: nowrap; color: var(--text); font-size: .85rem; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented a { padding: 6px 14px; color: var(--text); }
.segmented a.active { background: var(--accent); color: #fff; }
.segmented a:hover { text-decoration: none; }

.chart-box { position: relative; height: 220px; }
pre.logs {
  background: #0b1120; color: #d1d5db; padding: 12px; border-radius: var(--radius); overflow: auto;
  max-height: 75vh; font-size: .78rem; line-height: 1.4; white-space: pre-wrap; word-break: break-all;
}

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 1.2rem; }
.auth-card .brand img { width: 40px; height: 40px; border-radius: 10px; }
.auth-card form > * + * { margin-top: 12px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
