/* IT-Betriebsportal – dunkles Design nach docs/ui-entwuerfe-dunkel (Farben aus dem Entwurfs-README, Auftrag 0012).
   Status nie nur über Farbe: jeder Status hat Text (Pflichtenheft §21). Keine externen Schriften (CSP 'self'). */
:root {
  /* Dunkles Design (docs/ui-entwuerfe-dunkel/README.md) – Standard, unabhängig von prefers-color-scheme */
  --bg: #0A0D12; --header: #10151C; --surface: #151B24; --surface-top: #1A212C; --surface-line: #33404F;
  --surface-2: #0F141B; --raised: #1C2430; --hover: #232C39; --line: #2C3644; --line-soft: #2C3644; --line-strong: #3A4555;
  --field: #5E6D82; --text: #E8ECF2; --muted: #A7B1BF; --quiet: #8A95A5; --nav-active: #1C2430;
  --accent: #7CC4FF; --accent-hover: #A9D8FF; --accent-fill: #5AAEFF; --accent-text: #06111F; --accent-soft: #13253A;
  --ok: #5BD69A; --ok-dot: #5BD69A; --ok-bg: #12291F; --ok-trend: #2E7D56;
  --warn: #F2B64C; --warn-dot: #F2B64C; --warn-bg: #2E2410;
  --crit: #FF7A70; --crit-dot: #FF7A70; --crit-bg: #33171A; --crit-line: #6B3434; --crit-border: #FF7A70;
  --unknown: #AEB6C2; --unknown-dot: #AEB6C2; --unknown-bg: #1F252E;
  --approve: #2FA86B; --approve-text: #04140B;
  --shadow: 0 14px 34px rgba(0, 0, 0, .5); --inner: inset 0 1px 0 rgba(255, 255, 255, .06);
  --radius: 12px; --gap: 16px; --target: 40px;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px; line-height: 1.45; font-variant-numeric: tabular-nums; color-scheme: dark;
}
@media print {
  /* Ausdrucke hell (wie die PDF-Berichte) */
  :root {
    --bg: #ffffff; --header: #ffffff; --surface: #ffffff; --surface-top: #ffffff; --surface-line: #c9ced6; --surface-2: #f4f5f7;
    --raised: #f4f5f7; --hover: #f4f5f7; --line: #c9ced6; --line-soft: #e3e6ea; --line-strong: #9aa2af; --field: #6b7484;
    --text: #111827; --muted: #3f4754; --quiet: #4a5363; --accent: #1f5fbf; --accent-fill: #1f5fbf; --accent-text: #ffffff;
    --accent-soft: #e8effa; --ok: #1e6b40; --ok-dot: #1e6b40; --ok-bg: #e6f4ec; --warn: #6b4600; --warn-dot: #6b4600;
    --warn-bg: #fdf3e1; --crit: #8f1d14; --crit-dot: #8f1d14; --crit-bg: #fdecea; --crit-line: #e3a8a1; --unknown: #4a5363;
    --unknown-dot: #4a5363; --unknown-bg: #eef0f3; --shadow: none; --inner: none; color-scheme: light;
  }
  .topbar, .tabs, form, button, .button { display: none !important; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1 { font-size: 26px; font-weight: 600; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }
code, .mono { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: .92em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Kopfzeile */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding: 12px 32px;
  background: var(--header); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 16px; text-decoration: none; color: var(--text); }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a { padding: 8px 12px; min-height: var(--target); display: inline-flex; align-items: center; border-radius: 8px;
  text-decoration: none; color: var(--muted); }
.mainnav a:hover { background: var(--hover); color: var(--text); }
.mainnav a[aria-current] { background: var(--nav-active); color: var(--text); font-weight: 600; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent);
  color: var(--accent-text); font-size: 12px; text-align: center; }
.search { flex: 1 1 220px; max-width: 360px; display: flex; margin: 0; }
.search input { width: 100%; background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 12px; margin-left: auto; color: var(--muted); }
.who form { margin: 0; }

/* Seitenaufbau */
.page { max-width: 1376px; margin: 0 auto; padding: 24px 32px 48px; }
.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .main-col { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.split > .side-col { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); }

.card { background: linear-gradient(180deg, var(--surface-top) 0%, var(--surface) 100%); border: 1px solid var(--surface-line);
  border-radius: var(--radius); padding: 20px; margin-bottom: var(--gap); box-shadow: var(--inner), var(--shadow); }
.split .card, .columns .card { margin-bottom: 0; }
.card.crit { border-color: var(--crit-line); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-sub { margin: -8px 0 12px; font-size: 12px; color: var(--muted); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card form { display: grid; gap: 12px; }
.qr { display: block; margin: 12px auto; background: #fff; padding: 8px; border-radius: 6px; }
.secret { word-break: break-all; }
.note { border-style: dashed; }
.empty { text-align: center; }

/* Kundenkopf mit Reitern */
.customer-head { background: var(--header); border-bottom: 1px solid var(--line); }
.customer-head-inner { max-width: 1376px; margin: 0 auto; padding: 20px 32px 0; }
.customer-head .crumbs { margin: 0; font-size: 13px; color: var(--muted); }
.customer-head .title { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 6px 0; }
.customer-head .meta { margin: 0; color: var(--muted); }
.head-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-start; }
.tabs { display: flex; gap: 4px; margin-top: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; min-height: var(--target); display: inline-flex; align-items: center; color: var(--muted);
  text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a[aria-current] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.tabs span.later { padding: 10px 14px; color: var(--unknown-dot); white-space: nowrap; }

/* Formulare und Schaltflächen */
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
h2 label.check { display: inline-flex; vertical-align: middle; margin-right: 6px; }
input[type=checkbox] { min-height: 0; width: 20px; height: 20px; accent-color: var(--accent-fill); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--field);
  border-radius: 8px; padding: 8px 12px; min-height: var(--target); }
textarea { min-height: 80px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.tile:focus-visible, .kpi:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
button, .button { font: inherit; cursor: pointer; border: 1px solid var(--line-strong); background: var(--raised); color: var(--text);
  padding: 8px 16px; min-height: var(--target); border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .button:hover { background: var(--hover); }
button.small, .button.small { padding: 6px 12px; min-height: var(--target); font-size: 13px; }
button.primary, .button.primary { background: var(--accent-fill); color: var(--accent-text); border-color: var(--accent-fill); font-weight: 600; }
button.approve, .button.approve { background: var(--approve); color: var(--approve-text); border-color: var(--approve); font-weight: 700; }
button.danger, .button.danger { background: transparent; color: var(--crit); border: 1px solid var(--crit-border); font-weight: 600; }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; }
details > summary { cursor: pointer; color: var(--accent); margin: 8px 0; }

.alert { border: 1px solid var(--crit-line); background: var(--crit-bg); color: var(--crit); border-radius: 6px; padding: 8px 12px; margin: 0 0 12px; }
.alert p { margin: 0; }
.flash { border: 1px solid var(--line); background: var(--accent-soft); border-radius: 6px; padding: 8px 12px; margin: 0 0 16px; }
.hint, .muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; }
.right { text-align: right; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
.card > table.list, .page > table.list { background: var(--surface); }
.page > table.list { border: 1px solid var(--line); border-radius: var(--radius); }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 500; border-bottom-color: var(--line); padding-top: 8px; padding-bottom: 8px; }
table.list tr:last-child td { border-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; align-items: center; }
.filters a { padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.filters a[aria-current] { background: var(--nav-active); font-weight: 600; }
.pager { display: flex; gap: 16px; margin-top: 12px; }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } /* lange Hashes umbrechen statt seitlich scrollen */
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
ul.plain li { display: flex; flex-direction: column; gap: 2px; }
ul.plain.divided li { padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
ul.plain.divided li:last-child { border-bottom: 0; padding-bottom: 0; }
ul.rows li { flex-direction: row; justify-content: space-between; gap: 12px; font-size: 13px; }

/* Status: immer Form + Wort (Haken, Dreieck, Achteck, gestrichelter Kreis). SVG-Makro in templates/_ui.html; die
   kleinen .dot-Zeichen erhalten dieselben Formen per clip-path, damit kein Status nur über Farbe erkennbar ist. */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.si { flex: none; width: 1.05em; height: 1.05em; }
.dot { width: 10px; height: 10px; background: var(--unknown-dot); flex: none; display: inline-block;
  border-radius: 50%; background: transparent; border: 1.5px dashed var(--unknown-dot); }
.s-ok .dot, .dot.s-ok { border: 0; border-radius: 0; background: var(--ok-dot);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%); }
.s-warn .dot, .dot.s-warn { border: 0; border-radius: 0; background: var(--warn-dot); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.s-crit .dot, .dot.s-crit { border: 0; border-radius: 0; background: var(--crit-dot);
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.s-ok { color: var(--ok); } .s-warn { color: var(--warn); } .s-crit { color: var(--crit); }
.s-unknown, .s-muted { color: var(--unknown); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 16px; font-weight: 600;
  background: var(--unknown-bg); color: var(--unknown); text-decoration: none; }
.pill.s-ok { background: var(--ok-bg); } .pill.s-warn { background: var(--warn-bg); } .pill.s-crit { background: var(--crit-bg); }
.pill.accent { background: var(--accent-soft); color: var(--accent-hover); }
.badge { padding: 4px 10px; border-radius: 14px; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.tile { display: flex; flex-direction: column; gap: 14px; padding: 20px 18px 16px; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-top) 0%, var(--surface) 100%); border: 1px solid var(--surface-line);
  border-radius: 16px; text-decoration: none; color: var(--text); box-shadow: var(--inner), var(--shadow); --tone: var(--unknown-dot); }
.tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--tone); }
.tile.tone-ok { --tone: var(--ok-dot); } .tile.tone-warn { --tone: var(--warn-dot); }
.tile.tone-crit { --tone: var(--crit-dot); border-color: var(--crit-line); }
.tile:hover { border-color: #4A5A6E; color: var(--text); background: linear-gradient(180deg, var(--hover) 0%, var(--surface) 100%); }
.tile-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tile-head strong { font-size: 15px; }
.tile .badge { align-self: flex-start; }
.areas { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; font-size: 13px; }
.areas li { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; min-width: 0; }
.areas li .dot, .areas li .si { margin-top: 3px; }
.area-l { display: block; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--quiet); line-height: 1.3; }
.area-v { display: block; font-size: 13px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
/* Zähler-Karten der Übersicht */
.kpis { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 150px; padding: 14px 18px 14px 16px; border-radius: 14px;
  text-decoration: none; border: 1px solid var(--line-strong); background: var(--raised); color: var(--text); box-shadow: var(--inner), var(--shadow); }
.kpi-n { display: flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 700; line-height: 1.1; }
.kpi-l { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi.k-crit { background: linear-gradient(160deg, #3A1A1D, #22151A); border-color: #6B3434; color: var(--crit); }
.kpi.k-crit .kpi-l { color: #FFB3AC; }
.kpi.k-warn { background: linear-gradient(160deg, #352914, #211C14); border-color: #5C4719; color: var(--warn); }
.kpi.k-warn .kpi-l { color: #F7D394; }
.kpi.k-accent { background: linear-gradient(160deg, #15304D, #141E2C); border-color: #2A5683; color: var(--accent); }
.kpi.k-accent .kpi-l { color: #B5DCFF; }
.greeting { font-size: 28px; font-weight: 600; }
.areas .state { margin-left: auto; font-weight: 400; }
.tile .agent { margin: 0; font-size: 12px; color: var(--muted); }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 16px; }
.spark span { width: 3px; height: 14px; border-radius: 1px; background: var(--line); }
.spark .t-ok { background: var(--ok-trend); } .spark .t-warn { background: var(--warn-dot); }
.spark .t-crit { background: var(--crit-dot); } .spark .t-unknown { background: var(--unknown-dot); }
.code-box { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: 2px;
  padding: 12px 16px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 6px; display: inline-block; }
.markdown { line-height: 1.6; }
.markdown pre { background: var(--surface-2); padding: 12px; border-radius: 6px; overflow-x: auto; }

@media (max-width: 720px) {
  :root { --target: 48px; }
  .kpi { min-width: calc(50% - 6px); flex: 1 1 calc(50% - 6px); }
  .areas { grid-template-columns: minmax(0, 1fr); }
  .greeting { font-size: 22px; }
  .topbar, .customer-head-inner { padding-left: 16px; padding-right: 16px; }
  .page { padding: 16px 16px 40px; }
  .who span { display: none; }
  h1 { font-size: 22px; }
}
.status.plain { font-weight: 400; }
.tile .agent { display: flex; align-items: center; gap: 6px; }
.filters label { display: flex; align-items: center; gap: 6px; }
.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.event-list li { border-left: 2px solid var(--line); padding-left: 10px; }
.areas .state { white-space: nowrap; }
/* Versteckte Screenreader-Texte bleiben im Rahmen (sonst waagerechter Bildlauf am Smartphone) */
.table-wrap, .card, .tile { position: relative; }
.diff { white-space: pre-wrap; margin: 0; }
.diff .d-neu { background: var(--ok-bg); color: var(--ok); display: block; }
.diff .d-alt { background: var(--crit-bg); color: var(--crit); display: block; text-decoration: line-through; }
.diff .d-info { color: var(--muted); display: block; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 4px 8px; }
