:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --text: #1d2420;
  --muted: #5d6762;
  --border: #d9ddd8;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --ok: #1f7a45;
  --warn: #9a5b00;
  --bad: #b3261e;
  --bar: #e3e7e2;
  --row-off: #f7f3ee;
  --code: #eef1ed;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1d2320;
    --text: #e6ebe7;
    --muted: #9ba6a0;
    --border: #333c37;
    --accent: #5fb58a;
    --accent-text: #0e1411;
    --ok: #6fcf97;
    --warn: #f2b84b;
    --bad: #ff8a80;
    --bar: #2b332f;
    --row-off: #262420;
    --code: #262d29;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
code { background: var(--code); padding: 0 .3em; border-radius: 3px; font-size: .9em; }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); min-height: 1.5em; margin: .5rem 0 0; }

button, input, select {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .7rem;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: .1rem .3rem; color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.card-head { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.card-head h2 { margin-bottom: .5rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: .5rem; }
.check { display: flex; gap: .4rem; align-items: center; font-size: .9rem; }

/* Kopfzeile */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .75rem 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { font-weight: 650; }
.topbar-right { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.badge { border: 1px solid var(--border); border-radius: 999px; padding: .1rem .6rem; font-size: .85rem; }
.badge.admin { border-color: var(--accent); color: var(--accent); }

main { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 3rem; }

/* Kennzahlen */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; }
.tile .label { color: var(--muted); font-size: .8rem; }
.tile .value { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: .8rem; }
.meter { height: 6px; background: var(--bar); border-radius: 3px; margin-top: .4rem; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }

.health { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.health li::before { content: "●"; margin-right: .4rem; }
.health .ok::before { color: var(--ok); }
.health .bad::before { color: var(--bad); }

/* Rate-Diagramm */
.rate svg { width: 100%; height: 90px; display: block; }
.rate .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.rate .area { fill: var(--accent); opacity: .12; }
.rate-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }

/* Tabs */
.tabs { display: flex; gap: .25rem; margin-bottom: -1px; overflow-x: auto; }
.tabs button { border-radius: 8px 8px 0 0; border-bottom-color: transparent; background: transparent; }
.tabs button[aria-selected="true"] { background: var(--surface); border-color: var(--border); border-bottom-color: var(--surface); font-weight: 600; }
.tab { border-top-left-radius: 0; }

.hint { color: var(--muted); font-size: .9rem; margin: 0 0 .75rem; }
.add, .filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.add input[name="host"] { flex: 2 1 220px; }
.add input[name="note"] { flex: 3 1 220px; }
.add input[name="owner"] { flex: 1 1 120px; }
.filters input { flex: 1 1 220px; }
.actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.host { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; word-break: break-all; }
td.actions-cell { white-space: nowrap; text-align: right; }
tr.off td { background: var(--row-off); }
tr.off td.host { text-decoration: line-through; color: var(--muted); }
.state { font-size: .8rem; padding: .05rem .5rem; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.state.on { color: var(--ok); }
.state.off { color: var(--warn); }
.note-input { width: 100%; min-width: 160px; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; }
.bar-cell { min-width: 110px; }
.hitbar { height: 6px; background: var(--bar); border-radius: 3px; overflow: hidden; }
.hitbar > span { display: block; height: 100%; background: var(--ok); }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast.err { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  th.opt, td.opt { display: none; }
  /* Domain- und Referer-Listen als Karten statt Tabelle */
  .list-table thead { display: none; }
  .list-table, .list-table tbody, .list-table tr, .list-table td { display: block; width: 100%; }
  .list-table tr { border-bottom: 1px solid var(--border); padding: .5rem 0; }
  .list-table td { border: 0; padding: .2rem 0; }
  .list-table td.host { word-break: normal; overflow-wrap: anywhere; font-weight: 600; }
  .list-table td.actions-cell { text-align: left; }
  .list-table td.opt { display: none; }
  .list-table td.actions-cell button.link:first-child { padding-left: 0; }
  .tile .value { font-size: 1.2rem; }
}
