:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1f2328; --muted: #6b7280; --line: #e5e7eb; --line2: #f0f1f3;
  --accent: #2563eb; --accent-text: #fff;
  --ok: #1f8f4e; --warn: #c27c0e; --err: #d1342f; --unk: #6b7280; --pend: #c9ced6; --none: #eef0f3;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1a1e24; --text: #e6e8eb; --muted: #9aa3ae; --line: #2b313a; --line2: #232830;
    --accent: #4f8bff; --ok: #2fae66; --warn: #e0a028; --err: #ef5350; --unk: #8a94a3; --pend: #4a515c; --none: #232830;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono, pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: var(--line2); padding: 1px 4px; border-radius: 4px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Kopfzeile */
.top { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.top .wrap { display: flex; align-items: center; gap: 24px; min-height: 54px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; font-size: 15px; }
.logo { width: 18px; height: 18px; border-radius: 5px; display: inline-block;
  background: linear-gradient(135deg, var(--ok) 0 50%, var(--accent) 50% 100%); }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
nav a:hover { background: var(--line2); text-decoration: none; color: var(--text); }
nav a.active { color: var(--text); background: var(--line2); font-weight: 600; }
nav .logout { margin-left: auto; }
.foot { color: var(--muted); font-size: 12px; padding: 24px 16px 32px; }

/* Bausteine */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.stack form { margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.right { margin-left: auto; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.flash-ok { background: color-mix(in srgb, var(--ok) 12%, var(--card)); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.flash-warn { background: color-mix(in srgb, var(--warn) 14%, var(--card)); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.flash-err { background: color-mix(in srgb, var(--err) 12%, var(--card)); border-color: color-mix(in srgb, var(--err) 40%, transparent); }

/* Status */
.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; color: #fff; background: var(--unk); white-space: nowrap; }
.st-success { --c: var(--ok); } .st-warning { --c: var(--warn); } .st-failed, .st-missing { --c: var(--err); }
.st-unknown, .st-unassigned { --c: var(--unk); } .st-pending { --c: var(--pend); } .st-none { --c: var(--none); }
.badge[class*="st-"] { background: var(--c); }
.badge.st-none, .badge.st-pending { color: var(--text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: middle; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--radius); padding: 10px 14px; color: var(--text); }
.tile b { display: block; font-size: 24px; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 12.5px; }
a.tile:hover { text-decoration: none; border-color: var(--muted); }
.tile.st-none, .tile.st-pending { border-left-color: var(--pend); }

/* Tabellen */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--line2); }
tr.inactive td { opacity: .55; }
.sysname { font-weight: 600; color: var(--text); }
.patterns code { display: inline-block; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.checks td { padding: 6px 12px; }

/* Tagesraster */
.daygrid { display: grid; grid-template-columns: repeat(14, 18px); gap: 3px; }
.daygrid.head span { font-size: 10px; line-height: 1.15; text-align: center; color: var(--muted); font-weight: 400; }
.cell { display: block; width: 18px; height: 18px; border-radius: 4px; background: var(--c); }
.cell.st-missing { background: repeating-linear-gradient(135deg, var(--err) 0 3px, color-mix(in srgb, var(--err) 45%, var(--card)) 3px 6px); }
.cell.st-pending { background: transparent; border: 2px dashed var(--pend); }
.cell.unplanned:not(.st-none) { opacity: .45; }
a.cell:hover { outline: 2px solid var(--text); outline-offset: 1px; }
td.days, th.days { width: 1%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: -4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { width: 12px; height: 12px; border-radius: 3px; }

/* Formulare */
.form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.form label small { font-weight: 400; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; font-weight: 400; gap: 6px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 220px; }
.w-sm { width: 140px; } .w-md { width: 220px; max-width: 100%; }
.weekdays { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.filters input[type=search] { flex: 1; min-width: 200px; }

/* Mailansicht */
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-word; }
.mailbody { white-space: pre-wrap; word-break: break-word; tab-size: 4; background: var(--line2); padding: 12px; border-radius: 6px; max-height: 600px; overflow: auto; margin: 0; }
.mailhtml, .mailpreview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tab { font: inherit; background: none; border: 0; padding: 6px 10px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--line2); color: var(--text); font-weight: 600; }
pre.copy { background: var(--line2); padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; word-break: break-all; user-select: all; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-bottom: 16px; }
.empty { text-align: center; padding: 32px; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { width: 380px; max-width: 100%; }
.login-box h1 { display: flex; gap: 8px; align-items: center; font-size: 18px; margin-bottom: 16px; }
.login-box form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }

@media (max-width: 700px) {
  .ellipsis { max-width: 140px; }
  td, th { padding: 8px; }
}
