:root {
  --bg: #f4f5f7; --surface: #fff; --text: #1d2433; --muted: #667085; --border: #e3e6ea;
  --red: #d92d20; --red-dark: #a8190f; --orange: #f79009; --orange-bg: #fff6e8; --green: #12b76a; --green-bg: #ecfdf3;
  --blue: #2563eb; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --surface: #1a1f26; --text: #e6e9ee; --muted: #98a2b3; --border: #2b323c;
          --orange-bg: #2a2012; --green-bg: #0f2a1d; --blue: #6ea0ff; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blue); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-right { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text); }
.brand span, .login h1 span { color: var(--muted); font-weight: 400; }

.btn { font: inherit; border: 1px solid transparent; border-radius: 8px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-light { background: #fff; color: var(--red-dark); font-weight: 600; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn:hover { filter: brightness(0.95); }

.flash { background: var(--surface); border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash-error { border-color: var(--red); }

.login { max-width: 380px; margin: 12vh auto; text-align: center; background: var(--surface); padding: 40px 28px; border-radius: var(--radius); border: 1px solid var(--border); }
.login h1 { margin: 0 0 4px; }

.statusbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.statusbar strong { color: var(--text); }
.statusbar .err { color: var(--red); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.dot-ok { background: var(--green); } .dot-bad { background: var(--red); }

.all-good { display: flex; gap: 18px; align-items: center; background: var(--green-bg); border: 2px solid var(--green); border-radius: var(--radius); padding: 22px 26px; margin-bottom: 28px; }
.all-good h2 { margin: 0; } .all-good p { margin: 2px 0 0; color: var(--muted); }
.all-good-icon { font-size: 34px; width: 56px; height: 56px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; }

/* Alarm-Karten */
.alert { border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); }
.alert-critical { background: var(--red); color: #fff; border: 0; box-shadow: 0 0 0 0 rgba(217, 45, 32, .6); animation: pulse 2s infinite; }
.alert-critical a { color: #fff; }
.alert-warning { border-left: 6px solid var(--orange); }
.alert-info { border-left: 6px solid var(--blue); }
.alert-resolved { border-left: 6px solid var(--green); }
.alert-unknown { border-left: 6px solid var(--orange); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(217,45,32,.55); } 70% { box-shadow: 0 0 0 14px rgba(217,45,32,0); } 100% { box-shadow: 0 0 0 0 rgba(217,45,32,0); } }
@media (prefers-reduced-motion: reduce) { .alert-critical { animation: none; } }
.alert-head { display: flex; justify-content: space-between; gap: 16px; }
.alert-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; opacity: .85; }
.alert h2 { margin: 4px 0 6px; font-size: 22px; line-height: 1.25; }
.alert h2 a { text-decoration: none; }
.alert h2 a:hover { text-decoration: underline; }
.alert p { margin: 0; }
.alert-count { font-size: 36px; font-weight: 800; line-height: 1; text-align: center; min-width: 64px; }
.alert-count small { display: block; font-size: 11px; font-weight: 600; opacity: .8; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 14px 0; font-size: 14px; }
.meta dt { opacity: .75; } .meta dd { margin: 0; word-break: break-all; }

.lines { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 14px; }
.lines th { text-align: left; font-size: 12px; opacity: .75; font-weight: 600; padding: 4px 8px; }
.lines td { padding: 6px 8px; border-top: 1px solid rgba(127,127,127,.25); vertical-align: top; }
.alert-critical .lines td { border-color: rgba(255,255,255,.25); }
.alert-critical .lines { background: rgba(0,0,0,.12); border-radius: 6px; }
.ref { font-weight: 700; font-size: 15px; background: rgba(127,127,127,.15); padding: 1px 6px; border-radius: 4px; }
.alert-critical .ref { background: #fff; color: var(--red-dark); }
.level { font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: rgba(127,127,127,.2); }
.warn-note { font-size: 13px; background: rgba(0,0,0,.15); padding: 6px 10px; border-radius: 6px; }

.resolve { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.resolve input[type=text] { flex: 1 1 260px; font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.alert-critical .resolve input[type=text] { border: 0; }

.unknown { background: var(--orange-bg); border: 2px dashed var(--orange); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 28px; }
.unknown h2 { margin: 0 0 4px; font-size: 18px; }
.badge { background: var(--orange); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 13px; }
.unknown-item { background: var(--surface); border-radius: 8px; margin-top: 10px; padding: 10px 14px; border: 1px solid var(--border); }
.unknown-item summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.u-subject { font-weight: 600; } .u-meta { color: var(--muted); font-size: 13px; }
.u-actions { display: flex; flex-direction: column; gap: 8px; }

.mailbody { white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 12px; border-radius: 6px; font-size: 13px; max-height: 480px; overflow: auto; }
.mailbody.small { font-size: 11px; }

.panel, .history { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }
.panel h2, .history h2 { margin: 0 0 10px; font-size: 18px; }
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter select { font: inherit; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.table-scroll { overflow-x: auto; }
.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.hist td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.events { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.events li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.mail { border-top: 1px solid var(--border); padding: 10px 0; }
.mail summary { cursor: pointer; }
.headers { margin-top: 6px; font-size: 13px; }

@media (max-width: 640px) {
  .alert h2 { font-size: 18px; }
  .lines thead { display: none; }
  .lines tr { display: block; padding: 6px 0; }
  .lines td { display: inline-block; border: 0; padding: 2px 6px; }
  .lines td:last-child { display: block; }
}

.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.login-form input[type=email] { font: inherit; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

.update-banner { position: sticky; top: 8px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); border: 2px solid var(--blue); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.update-banner[hidden], #fetch-stale[hidden] { display: none; }
