/* Alarm-Relay Verwaltung - bewusst schlicht, ohne JavaScript, ohne externe Ressourcen */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5d6677;
  --line: #dfe3ea;
  --accent: #0f5fd8;
  --accent-text: #ffffff;
  --accent-soft: #e6effd;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --bad: #a31b1b;
  --bad-bg: #fde3e1;
  --ok: #17663a;
  --ok-bg: #dcf3e4;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1b2029;
    --text: #e6e9ef;
    --muted: #9aa3b2;
    --line: #2d3442;
    --accent: #5b9bff;
    --accent-text: #08111f;
    --accent-soft: #1d2a42;
    --warn: #f0c35a;
    --warn-bg: #3a2f12;
    --bad: #ff8d86;
    --bad-bg: #3d1b1b;
    --ok: #6fd596;
    --ok-bg: #16301f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; color: var(--muted); }
code, pre { font-family: var(--mono); font-size: .9em; }
code { background: var(--accent-soft); padding: .1em .4em; border-radius: 4px; }
.muted { color: var(--muted); font-weight: 400; }
.hint { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; font-weight: 400; }
.small-note { font-size: .85rem; margin-top: .75rem; }

/* ---- Kopfleiste ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .01em; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--text); text-decoration: none; padding: .35rem .7rem; border-radius: 6px; }
.nav a:hover { background: var(--accent-soft); }
.logout { display: flex; align-items: center; gap: .6rem; margin: 0; }
.who { color: var(--muted); font-size: .9rem; }

.container { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.crumbs { margin: 0 0 .75rem; font-size: .9rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---- Meldungen ---- */
.flashes { margin-bottom: 1rem; display: grid; gap: .5rem; }
.flash { padding: .65rem .9rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.flash.success { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* ---- Buttons / Formulare ---- */
.btn {
  display: inline-block; font: inherit; cursor: pointer; text-decoration: none;
  padding: .5rem .95rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); line-height: 1.2;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }

.stack { display: grid; gap: 1rem; }
label { display: block; font-weight: 600; }
input[type=text], input[type=password], input[type=search], input[type=number], textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; font-weight: 400;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
}
textarea { resize: vertical; font-family: var(--mono); font-size: .9rem; }
input:focus, textarea:focus { border-color: var(--accent); }
.field-static { display: grid; gap: .25rem; }
.field-label { font-weight: 600; }
.advanced { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; }
.advanced summary { cursor: pointer; font-weight: 600; }
.advanced .stack { margin-top: .9rem; }

/* ---- Karten / Kacheln ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 560px; }
.card.narrow-form { max-width: 640px; }
.card.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 1rem; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; display: grid; gap: .1rem; }
.tile-label { color: var(--muted); font-size: .8rem; }
.tile-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.warn { background: var(--warn-bg); border-color: transparent; }
.tile.warn .tile-value { color: var(--warn); }
.tile.bad { background: var(--bad-bg); border-color: transparent; }
.tile.bad .tile-value { color: var(--bad); }

/* ---- Tabellen ---- */
.search { display: flex; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.search input[type=search] { margin: 0; max-width: 380px; flex: 1 1 220px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; background: var(--surface); }
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--accent); }
.arrow { font-size: .7rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.rowlink { font-weight: 600; text-decoration: none; }
.rowlink:hover { text-decoration: underline; }
.sub { color: var(--muted); font-size: .8rem; }
.err { color: var(--bad); font-size: .85rem; word-break: break-word; max-width: 360px; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin: 0 .25rem 0 0; }
.card .table-wrap { border: 0; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* ---- Detailseite ---- */
.facts { display: grid; grid-template-columns: 10rem 1fr; gap: .6rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; word-break: break-word; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; gap: .1rem; } .facts dd { margin-bottom: .6rem; } }
.secret { font-size: .95rem; user-select: all; }
ul.plain { list-style: none; padding: 0; margin: 0; }

.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.zero { fill: var(--line); }
.chart .axis-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }

.maillist { list-style: none; margin: 0; padding: 0; }
.maillist li { border-top: 1px solid var(--line); }
.maillist li:first-child { border-top: 0; }
.maillist summary { cursor: pointer; padding: .55rem 0; display: flex; gap: .9rem; align-items: baseline; flex-wrap: wrap; }
.maillist .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.maillist .subj { font-weight: 600; flex: 1 1 200px; min-width: 0; word-break: break-word; }
.body { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .7rem .9rem; margin: 0 0 .75rem; max-height: 22rem; overflow: auto; }

/* ---- Login ---- */
.login-box { max-width: 380px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; }
.login-box h1 { margin-bottom: .1rem; }
.login-box p { margin: 0 0 1.25rem; }
.login-box .btn { width: 100%; padding: .65rem; }
