/* SAPify-Solutions Design (analog SAP Patch Advisor): gleiche Variablen, Hell/Dunkel */
:root {
  --sap-blue: var(--sd-akzent, var(--sd-akzent, #0a6ed1));
  --sap-blue-dark: var(--sd-akzent-dunkel, var(--sd-akzent-dunkel, #0854a0));
  --sap-dark: #32363a;
  --sap-navy: #1c2b3a;
  --bg: #f5f6f7;
  --border: #d9d9d9;
  --hot: #bb0000;
  --high: #e9730c;
  --ok: #107e3e;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,0.06), 0 1px 6px rgba(0,0,0,0.04);
  --surface: #ffffff;
  --surface-alt: #fafcff;
  --surface-hover: #f0f2f4;
  --table-header-bg: #f7f8f9;
  --text: #1a1a1a;
  --text-muted: #6a6d70;
  --ok-bg: #e5f5e8; --ok-fg: #0d6b32;
  --nok-bg: #fde8e8; --nok-fg: #a30000;
  --na-bg: #ececec; --na-fg: #595959;
}
[data-theme="dark"] {
  --sap-dark: #e4e7ea;
  --bg: #14171a;
  --border: #3a4048;
  --surface: #20242a;
  --surface-alt: #262b32;
  --surface-hover: #2b313a;
  --table-header-bg: #262b32;
  --text: #e4e7ea;
  --text-muted: #9aa3ad;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 6px rgba(0,0,0,0.25);
  --ok-bg: #16331f; --ok-fg: #6fd48f;
  --nok-bg: #3b1b1d; --nok-fg: #ff8e8e;
  --na-bg: #2f343b; --na-fg: #aab2bb;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "72", "Segoe UI", Arial, sans-serif;
  margin: 0; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1 0 auto; padding: 32px 0 48px; }
.page-container { --seitenrand: clamp(16px, 2.2vw, 40px); width: 100%; max-width: 1760px; margin: 0 auto; padding: 0 var(--seitenrand); }
[hidden] { display: none !important; }

/* Header */
header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 20px; padding-top: 14px; padding-bottom: 14px; }
header .logo { height: 40px; width: auto; display: block; }
.wordmark { font-weight: 800; font-size: 24px; color: var(--sap-blue); letter-spacing: -0.01em; }
header .header-text { border-left: 1px solid var(--border); padding-left: 20px; }
header h1 { margin: 0; font-size: 19px; font-weight: 700; color: var(--sap-dark); }
.subtitle { margin: 2px 0 0; opacity: 0.65; font-size: 12.5px; }
.header-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--text-muted); white-space: nowrap; }

/* Tabs */
nav.tabs { background: var(--surface); border-bottom: 1px solid var(--border); }
.tabs-inner { display: flex; flex-wrap: wrap; }
.tab-btn { border: none; background: none; padding: 14px 22px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500; color: var(--sap-dark); border-bottom: 3px solid transparent; transition: color .15s ease, border-color .15s ease; }
.tab-btn:hover { color: var(--sap-blue); }
.tab-btn.active { border-bottom-color: var(--sap-blue); color: var(--sap-blue); font-weight: 700; }
.tab-btn:focus-visible { outline: 2px solid var(--sap-blue); outline-offset: -3px; border-radius: 2px; }
h2 { color: var(--sap-dark); font-size: 20px; font-weight: 700; margin: 0 0 16px; }
h3 { color: var(--sap-dark); font-size: 15px; margin: 0 0 10px; }
h4 { color: var(--sap-dark); font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.view { animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Buttons / Inputs */
button, .btn { font: inherit; }
.btn { background: var(--sap-blue); color: #fff; border: 1px solid var(--sap-blue); border-radius: 6px; padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--sap-blue-dark); border-color: var(--sap-blue-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border); }
.btn-danger { background: var(--surface); color: var(--hot); border: 1px solid var(--border); }
.btn-danger:hover { background: var(--nok-bg); border-color: var(--hot); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-icon { background: transparent; color: var(--sap-dark); border: none; font-size: 18px; line-height: 1; padding: 6px; cursor: pointer; border-radius: 6px; }
.btn-icon:hover { background: var(--surface-hover); }
.link { background: none; border: none; color: var(--sap-blue); cursor: pointer; padding: 0; font-size: 12.5px; }
.link:hover { text-decoration: underline; }
input, select, textarea { font: inherit; font-size: 13.5px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; width: 100%; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: var(--surface-alt); }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sap-blue); outline-offset: -1px; border-color: var(--sap-blue); }
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--sap-dark); margin-bottom: 5px; }
.req::after { content: " *"; color: var(--hot); }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.hint { color: var(--text-muted); font-size: 12.5px; }
.err { color: var(--hot); font-size: 13px; margin-top: 8px; }
details.phase { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
details.phase > summary { cursor: pointer; padding: 14px 18px; font-weight: 600; color: var(--sap-dark); list-style: none; display: flex; align-items: center; gap: 10px; user-select: none; }
details.phase > summary::-webkit-details-marker { display: none; }
details.phase > summary::before { content: "▶"; font-size: 10px; color: var(--sap-blue); transition: transform .15s ease; display: inline-block; }
details.phase[open] > summary::before { transform: rotate(90deg); }
details.phase > summary:hover { background: var(--surface-hover); }
.phase-count { margin-left: auto; font-weight: 500; font-size: 12.5px; color: var(--text-muted); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.tbl-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface); }
details.phase table { border-top: 1px solid var(--border); }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
th { background: var(--surface-hover); color: var(--sap-dark); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; user-select: none; }
tbody tr:last-child td { border-bottom: none; }
tr.chk { cursor: pointer; }
tr.chk:hover td { background: var(--surface-hover); }
tr.chk.open td { background: var(--surface-alt); }
td.nr { width: 46px; color: var(--text-muted); text-align: center; }
td.num, th.num { text-align: center; white-space: nowrap; }
.sub { display: block; color: var(--text-muted); font-size: 12px; margin-top: 3px; font-family: Consolas, "Courier New", monospace; }
.muted { color: var(--text-muted); }
tr.detail > td { padding: 0; background: var(--surface-alt); cursor: default; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; padding: 18px 20px 20px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: 13px; margin-bottom: 14px; }
.kv dt { color: var(--text-muted); font-weight: 600; }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* Status */
select.st { width: 86px; padding: 5px 8px; font-weight: 700; font-size: 12.5px; text-align: center; }
select.st.s-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
select.st.s-nok { background: var(--nok-bg); color: var(--nok-fg); border-color: transparent; }
select.st.s-na { background: var(--na-bg); color: var(--na-fg); border-color: transparent; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--surface-hover); color: var(--text-muted); border: 1px solid var(--border); }
.badge.eigen { background: rgba(var(--sd-akzent-rgb, 10,110,209),.12); color: var(--sap-blue); border-color: transparent; }
.ico { white-space: nowrap; color: var(--text-muted); font-size: 12.5px; }

/* Summary */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.tile .v { font-size: 26px; font-weight: 700; color: var(--sap-dark); }
.tile .l { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 700; }
.tile.t-ok .v { color: var(--ok-fg); } .tile.t-nok .v { color: var(--nok-fg); }
.bar { height: 8px; background: var(--surface-hover); border-radius: 4px; overflow: hidden; margin-top: 8px; border: 1px solid var(--border); }
.bar > span { display: block; height: 100%; background: var(--sap-blue); width: 0; transition: width .25s; }
.bar.sm { width: 120px; margin-top: 0; }

/* Bilder / Kommentare */
.dropzone { border: 1px dashed var(--border); border-radius: 6px; padding: 12px; text-align: center; color: var(--text-muted); font-size: 12.5px; cursor: pointer; background: var(--surface); }
.dropzone:hover, .dropzone:focus, .dropzone.over { border-color: var(--sap-blue); color: var(--sap-blue); outline: none; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.thumb { position: relative; width: 112px; height: 82px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; line-height: 18px; text-align: center; border-radius: 10px; background: rgba(0,0,0,.65); color: #fff; font-size: 13px; border: none; cursor: pointer; padding: 0; }
.thumb .x:hover { background: var(--hot); }
.comment { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 10px 12px; margin-bottom: 10px; }
.comment .meta { display: flex; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; align-items: center; }
.comment .meta b { color: var(--sap-dark); }
.comment .txt { white-space: pre-wrap; word-break: break-word; font-size: 13px; }

/* Modal / Toast / Lightbox */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.4); width: 100%; max-width: 640px; padding: 22px; }
.modal h3 { font-size: 17px; margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--sap-navy); color: #fff; padding: 11px 16px; border-radius: 6px; box-shadow: var(--shadow); z-index: 100; font-size: 13.5px; max-width: 420px; }
.toast.bad { background: var(--hot); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 120; display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; }

/* Footer */
footer.site-footer { flex-shrink: 0; background: var(--surface); border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); }
footer .footer-inner { display: flex; align-items: center; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
footer .wordmark { font-size: 16px; }
footer img { height: 22px; }

@media (max-width: 980px) {
  .detail-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .tbl-wrap, details.phase { overflow-x: auto; }
  .header-inner { flex-wrap: wrap; }
}

/* Cockpit */
.cockpit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 20px; margin-bottom: 32px; }
.cockpit-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; transition: border-color .15s, transform .15s; }
.cockpit-card:hover { border-color: var(--sap-blue); transform: translateY(-2px); }
.cc-icon { font-size: 34px; line-height: 1; margin-bottom: 12px; }
.cockpit-card h3 { font-size: 21px; margin-bottom: 8px; }
.cc-text { color: var(--text-muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 18px; min-height: 60px; }
.cc-stats { display: flex; gap: 28px; margin-bottom: 20px; }
.cc-stats b { display: block; font-size: 24px; color: var(--sap-dark); }
.cc-stats b.bad { color: var(--nok-fg); }
.cc-stats span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 700; }
.cc-lead { margin: -8px 0 20px; font-size: 14px; }

/* Hilfsklassen */
.flush { margin: 0 !important; }
.w150 { width: 150px; } .w200 { width: 200px; } .w300 { width: 300px; max-width: 100%; }
.filter-row { margin-bottom: 16px; }
.chk-lbl { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; cursor: pointer; }
.chk-lbl input { width: auto; }
.pad { padding: 16px 20px; }
.mt { margin-top: 18px; }
.narrow { max-width: 440px; }
.create-row { margin-top: 16px; }
.detail-actions { margin-bottom: 14px; }
.meta-panel { padding-top: 14px; }
.badge.nokb { background: var(--nok-bg); color: var(--nok-fg); border-color: transparent; }
/* Zahlungsstatus der Rechnungen aus dem Portal (ohne Beträge) */
.badge.re-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
ul.rechnungen { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
ul.rechnungen li { margin: 2px 0; white-space: nowrap; }
.badge.eigen { margin-left: 8px; }
.composer { margin-top: 12px; }
.composer textarea { margin-bottom: 6px; }

/* Portale / Bestätigung / Word-Vorlage */
.badge.done { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; margin-left: 8px; }
.badge.big { font-size: 12px; padding: 3px 10px; vertical-align: middle; }
.confirm-banner { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-fg); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.note-box { background: var(--surface-hover); border-left: 4px solid var(--sap-blue); border-radius: 4px; padding: 10px 14px; margin: 10px 0; font-size: 13.5px; }
.secret { display: block; font-size: 18px; letter-spacing: .04em; padding: 14px 16px; margin: 12px 0 16px; background: var(--surface-hover); border: 1px dashed var(--border); border-radius: 6px; user-select: all; word-break: break-all; }
.chip { display: inline-block; font-size: 12px; background: var(--surface-hover); border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; margin: 2px 4px 2px 0; }
ul.warn { margin: 10px 0 4px 18px; padding: 0; color: var(--nok-fg); font-size: 13px; }
.panel.flat { box-shadow: none; margin-top: 12px; }
.tiles.kpis { margin-bottom: 24px; }
details.hist { margin-top: 16px; }
details.hist table { width: 100%; }
.pad p { margin: 0 0 10px; font-size: 13.5px; }
@media (max-width: 900px) { .tiles.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Zweiter Faktor (Konto) */
.mfa-qr { display: flex; justify-content: center; margin: 10px 0; }
.mfa-qr svg { background: #fff; padding: 6px; border-radius: 6px; }
.codes-liste { font-family: Consolas, monospace; font-size: 14px; columns: 2; margin: 8px 0 14px; padding-left: 22px; }
.sub.plain { font-family: inherit; font-size: 12px; }

/* Neues Logo (helle Schrift, Fassung für dunklen Grund): steht auf einem dunkelblauen Feld,
   damit es im hellen wie im dunklen Design in den Originalfarben erscheint. */
header .logo { box-sizing: content-box; height: 24px; padding: 8px 12px; background: #1d2d3e; border-radius: 8px; }
.footer-logo { box-sizing: content-box; height: 16px; width: auto; display: block; padding: 5px 9px; background: #1d2d3e; border-radius: 6px; }

.konto-foto { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.auth-form a.btn { text-align: center; box-sizing: border-box; }

/* Rücksprung ins SAPify Portal (alle Apps) — in jeder App oben in der Kopfzeile */
.btn-portal { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn-portal:hover { background: var(--surface-hover); border-color: var(--sap-blue); color: var(--sap-blue); }

/* Hausschrift Montserrat (Regular / Semibold / Bold) — selbst gehostet (SIL Open Font License),
   weil die Content-Security-Policy keine fremden Quellen zulässt. */
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/montserrat-400.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/montserrat-600.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/montserrat-700.woff2") format("woff2"); }
body, button, input, select, textarea { font-family: "Montserrat", "Segoe UI", Arial, sans-serif; }

/* ============================================================================
   Einheitliches Erscheinungsbild aller SAPify-Apps (Vorbild: SAPify Portal):
   Kopf- und Fusszeile dunkelblau (hell: #354a5f, dunkel: #1d2d3e), helles Logo
   direkt auf der Leiste, weisse Schrift. Aufklappmenüs behalten die normalen Farben.
   ============================================================================ */
:root { --kopf-bg: #354a5f; --kopf-fg: #ffffff; }
[data-theme="dark"] { --kopf-bg: #1d2d3e; }
header { background: var(--kopf-bg); color: var(--kopf-fg); border-bottom: none; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.header-inner { padding-top: 9px; padding-bottom: 9px; min-height: 52px; gap: 16px; }
header .logo { box-sizing: border-box; height: 28px; padding: 0; background: none; border-radius: 0; }
header .wordmark { color: #fff; font-size: 19px; }
header .header-text { border-left: 1px solid rgba(255,255,255,.28); padding-left: 16px; }
header h1 { color: #fff; font-size: 16px; }
header .subtitle { color: rgba(255,255,255,.72); opacity: 1; font-size: 12px; }
.header-user { color: #fff; }
header .btn-icon { color: #fff; }
header .btn-icon:hover { background: rgba(255,255,255,.14); }
header .btn-portal, header .header-user > .btn-secondary, header .header-user > button.btn { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.38); }
header .btn-portal:hover, header .header-user > .btn-secondary:hover, header .header-user > button.btn:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.6); color: #fff; }
footer.site-footer, .site-footer { background: var(--kopf-bg); color: rgba(255,255,255,.78); border-top: none; }
.site-footer .footer-inner { padding-top: 13px; padding-bottom: 13px; }
.footer-logo { box-sizing: border-box; height: 22px; padding: 0; background: none; border-radius: 0; }
.site-footer a { color: #8fd3f4; }

/* ============================================================================
   Handy (Hochformat, bis 640 px): Die Seite wird nie breiter als der Bildschirm.
   Kopfzeile zweizeilig, Reiter als wischbare Leiste, Checks als gestapelte Karten,
   übrige Tabellen scrollen in ihrem Rahmen. Ab 641 px gilt unverändert das Bisherige.
   ============================================================================ */
.cockpit-grid { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
@media (max-width: 640px) {
  main { padding: 20px 0 32px; }
  h2 { font-size: 18px; overflow-wrap: break-word; }
  .panel, .comment, .confirm-banner, .note-box, td, dd { overflow-wrap: break-word; }

  /* Kopfzeile: oben Logo und Titel, darunter Portal-Link, Design, Name und Abmelden */
  .header-inner { gap: 8px 12px; min-height: 0; }
  header .logo { height: 22px; flex: 0 0 auto; }
  header .wordmark { font-size: 17px; }
  header .header-text { flex: 1 1 0; min-width: 0; padding-left: 12px; }
  header h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  header .subtitle { display: none; }
  .header-user { flex: 1 1 100%; margin-left: 0; gap: 8px; min-width: 0; }
  .header-user #who { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: right; }
  .header-user .btn-portal { margin-right: auto; }
  header .btn-portal, header .header-user > .btn-sm { padding: 7px 12px; }

  /* Reiter: eine Zeile, seitlich wischbar (statt vier umbrochener Zeilen) */
  .tabs-inner { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs-inner::-webkit-scrollbar { display: none; }
  .tab-btn { flex: 0 0 auto; padding: 12px 12px; font-size: 13.5px; white-space: nowrap; }

  /* Bedienelemente: fingertauglich; 16 px Schrift verhindert das Hineinzoomen beim Antippen */
  input, select, textarea { font-size: 16px; }
  .btn-sm { padding: 8px 12px; }
  .btn-icon { padding: 8px 10px; }
  .view > .row { margin-bottom: 10px; }
  .view > .row > div { min-width: 0; }
  .view > .row > .spacer { flex: 1 1 100%; height: 0; }
  .filter-row > input, .filter-row > select, .w150, .w200, .w300 { width: 100%; }
  .panel { padding: 14px; }
  .grid { gap: 10px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .grid-3 input { padding-left: 9px; padding-right: 9px; }
  .narrow { max-width: none; }
  .cockpit-card { padding: 18px; }
  .cc-text { min-height: 0; }
  .cc-stats { gap: 16px; }
  .tiles { gap: 10px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 8px; }
  ul.rechnungen li { white-space: normal; }

  /* Breite Tabellen scrollen in ihrem Rahmen, nicht die Seite */
  .tbl-wrap, details.phase { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 10px 12px; }
  .pad { padding: 14px; }
  .pad table { table-layout: fixed; }
  .pad th, .pad td { padding: 8px 6px; overflow-wrap: anywhere; }
  .chip { overflow-wrap: anywhere; }

  /* Checks einer Checkliste: je Check eine Karte statt sieben Spalten */
  details.phase:not(.hist) > table, details.phase:not(.hist) > table > tbody, details.phase:not(.hist) > table > tbody > tr > td { display: block; }
  details.phase:not(.hist) > table > thead { display: none; }
  details.phase:not(.hist) > table > tbody > tr.chk { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  details.phase:not(.hist) > table > tbody > tr.chk:last-child { border-bottom: none; }
  details.phase:not(.hist) > table > tbody > tr.chk.open { background: var(--surface-alt); }
  details.phase:not(.hist) > table > tbody > tr.chk > td { padding: 0; border: none; background: none; width: auto; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(1) { grid-area: 1 / 1 / 3 / 2; text-align: left; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(2) { grid-area: 1 / 2; align-self: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(5) { grid-area: 1 / 3; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(3) { grid-area: 2 / 2 / 3 / 4; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(4) { grid-area: 3 / 2 / 4 / 4; font-size: 12.5px; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(4):not(:empty)::before { content: "Erwartet: "; font-weight: 700; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(6) { grid-area: 4 / 2; white-space: normal; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(7) { grid-area: 4 / 3; text-align: right; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:empty { display: none; }
  details.phase:not(.hist) > table > tbody > tr.detail { display: block; border-bottom: 1px solid var(--border); }
  select.st { width: 92px; padding: 7px 8px; font-size: 14px; }
  .sub { overflow-wrap: break-word; }
  .detail-grid { gap: 18px; padding: 14px; }
  .thumb { width: 96px; height: 72px; }
  .comment .meta { flex-wrap: wrap; }

  /* Dialoge, Meldungen, Fusszeile */
  .overlay { padding: 12px; }
  .modal { padding: 16px; }
  .modal .row.end .btn { flex: 1 1 auto; text-align: center; }
  .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
  .lightbox { padding: 12px; }
  footer .footer-inner { flex-wrap: wrap; gap: 6px 12px; }
  .secret { font-size: 15px; }
}

/* ============================================================================
   Zentrale Inbox des SAPify Portals: Symbol «Mitteilungen» in der Kopfzeile (mit Zahl, wenn dort
   etwas ungelesen ist oder wartet) und «Frage an SAPify» bei einer Checkliste
   ============================================================================ */
.btn-mitteilungen { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid rgba(255,255,255,.38); border-radius: 6px; color: #fff; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn-mitteilungen:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.6); }
.btn-mitteilungen .mitteilungen-symbol { display: block; flex: 0 0 auto; }
.mitteilungen-zahl { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--hot, #bb0000); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-sizing: border-box; }
@media (max-width: 640px) {
  /* Zweite Zeile der Kopfzeile: Portal | Mitteilungen (nur Symbol + Zahl), Design, Name, Abmelden */
  .btn-mitteilungen .mitteilungen-text { display: none; }
  .header-user .btn-mitteilungen { padding: 7px 9px; gap: 4px; }
}
@media (max-width: 430px) {
  /* Neben Portal, Mitteilungen, Design und Abmelden blieben vom Namen nur ein, zwei Buchstaben – er steht unter «Konto» */
  .header-user #who { display: none; }
}

/* ---------- Checkliste: alle Abschnitte mit denselben Spaltenbreiten (lange Texte brechen um) ---------- */
table.checks { table-layout: fixed; }
table.checks col.c-nr { width: 76px; } table.checks col.c-bereich { width: 140px; } table.checks col.c-erw { width: 24%; }
table.checks col.c-st { width: 118px; } table.checks col.c-visum { width: 136px; } table.checks col.c-notiz { width: 92px; }
table.checks td, table.checks th { overflow-wrap: anywhere; }
table.checks td.nr { width: auto; text-align: left; }
.nr-box { display: inline-flex; align-items: center; gap: 8px; }
input.wahl { width: 16px; height: 16px; margin: 0; padding: 0; flex: none; cursor: pointer; accent-color: var(--sap-blue); }
@media (min-width: 641px) and (max-width: 980px) { table.checks { min-width: 880px; } }
/* Sammelstatus: erscheint, sobald Checks ausgewählt sind */
.sammel { position: sticky; top: 8px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--sap-blue); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(0,0,0,.14); font-size: 13px; }
.st-knopf { min-width: 62px; font-weight: 700; }
.st-knopf.s-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.st-knopf.s-nok { background: var(--nok-bg); color: var(--nok-fg); border-color: transparent; }
.st-knopf.s-na { background: var(--na-bg); color: var(--na-fg); border-color: transparent; }

/* ---------- Text mit Bildern (Ist / Befund, Bemerkungen) ---------- */
.editor-box { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
[data-theme="dark"] .editor-box { background: var(--surface-alt); }
.editor-box:focus-within { border-color: var(--sap-blue); outline: 2px solid var(--sap-blue); outline-offset: -1px; }
.editor-box.ro { background: none; }
.editor { min-height: 96px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; cursor: text; }
.editor-box.ro .editor { min-height: 0; cursor: default; }
.editor:empty::before { content: attr(data-ph); color: var(--text-muted); pointer-events: none; }
.editor.over { background: rgba(var(--sd-akzent-rgb, 10,110,209),.08); }
.editor-leiste { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px; border-top: 1px solid var(--border); }
.editor-leiste .hint { flex: 1 1 200px; }
.ed-fig { display: block; position: relative; width: fit-content; max-width: 100%; margin: 8px 0; user-select: none; }
.ed-fig img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 4px; cursor: zoom-in; background: #fff; }
.ed-fig .x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; line-height: 22px; text-align: center; border-radius: 12px; background: rgba(0,0,0,.65); color: #fff; font-size: 15px; border: none; cursor: pointer; padding: 0; }
.ed-fig .x:hover { background: var(--hot); }
.comment .inhalt:empty { display: none; }
.feld-zusatz { display: inline-flex; margin-top: 6px; font-size: 12.5px; }
a.feld-zusatz { color: var(--sap-blue); text-decoration: none; } a.feld-zusatz:hover { text-decoration: underline; }

/* ---------- Diagramme im Cockpit ---------- */
:root { --d-ok: #1c8a4a; --d-nok: #c9302c; --d-na: #8b949e; --d-offen: #d5dae0; --d-arbeit: var(--sd-akzent, var(--sd-akzent, #0a6ed1)); --d-fertig: #1c8a4a; }
[data-theme="dark"] { --d-ok: #46b872; --d-nok: #ef6b66; --d-na: #7d8792; --d-offen: #3d444d; --d-arbeit: var(--sd-akzent-hell, var(--sd-akzent-hell, #4da3ee)); --d-fertig: #46b872; }
.dia-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; margin-bottom: 28px; }
.panel.dia { margin-bottom: 0; display: flex; flex-direction: column; }
.panel.dia h3 { margin-bottom: 2px; } .panel.dia > .hint { margin: 0 0 14px; }
.dia-ring { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ring { width: 150px; height: 150px; flex: none; }
.ring circle { fill: none; stroke-width: 15; }
.r-spur { stroke: var(--surface-hover); }
.r-seg.d-ok { stroke: var(--d-ok); } .r-seg.d-nok { stroke: var(--d-nok); } .r-seg.d-na { stroke: var(--d-na); } .r-seg.d-offen { stroke: var(--d-offen); }
.r-zahl { font-size: 25px; font-weight: 700; fill: var(--text); } .r-unter { font-size: 11px; fill: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.legende { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text); }
.dia-ring .legende { flex-direction: column; flex: 0 1 170px; gap: 8px; }
.legende li { display: flex; align-items: center; gap: 8px; } .legende b { margin-left: auto; font-variant-numeric: tabular-nums; }
.dia-ring .legende b { min-width: 34px; text-align: right; }
.punkt { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.punkt.d-ok, .b-seg.d-ok { background: var(--d-ok); } .punkt.d-nok, .b-seg.d-nok { background: var(--d-nok); } .punkt.d-na, .b-seg.d-na { background: var(--d-na); }
.punkt.d-offen, .b-seg.d-offen { background: var(--d-offen); } .punkt.d-arbeit, .b-seg.d-arbeit { background: var(--d-arbeit); } .punkt.d-fertig, .b-seg.d-fertig { background: var(--d-fertig); }
.b-liste { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.b-zeile { display: grid; grid-template-columns: minmax(0, 34%) minmax(0, 1fr) 46px; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text); text-decoration: none; }
a.b-zeile:hover .b-name { color: var(--sap-blue); text-decoration: underline; }
.b-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-spur { display: flex; gap: 2px; height: 14px; }
.b-seg { display: block; height: 100%; min-width: 3px; border-radius: 2px; }
.b-seg:first-child { border-radius: 4px 2px 2px 4px; } .b-seg:last-child { border-radius: 2px 4px 4px 2px; } .b-seg:only-child { border-radius: 4px; }
.b-wert { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.panel.dia > .legende { margin-top: auto; }
@media (max-width: 640px) {
  .sammel { top: 4px; padding: 10px; }
  .editor { font-size: 16px; }
  .dia-ring { gap: 14px; } .ring { width: 124px; height: 124px; }
  details.phase:not(.hist) > table > tbody > tr.chk > td:nth-child(1) .nr-box { flex-direction: column; gap: 10px; align-items: flex-start; }
  input.wahl { width: 20px; height: 20px; }
}
/* Kacheln der Checkliste filtern die Liste */
button.tile-knopf { font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; }
button.tile-knopf:hover { border-color: var(--sap-blue); }
button.tile-knopf.aktiv { border-color: var(--sap-blue); box-shadow: 0 0 0 2px var(--sap-blue) inset; }
button.tile-knopf:focus-visible { outline: 2px solid var(--sap-blue); outline-offset: 2px; }
/* Bestätigung von Quelle und Ziel vor dem Anlegen */
.fest-kv { grid-template-columns: 170px 1fr; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-alt); }
.fest-kv dd { font-weight: 700; }
.fest-haken { display: flex; align-items: flex-start; margin: 14px 0; } .fest-haken input { margin-top: 2px; }
input:disabled, select:disabled { background: var(--surface-hover); color: var(--text-muted); cursor: not-allowed; opacity: 1; }
