:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #f0f1f4;
  --border: #dcdfe5;
  --text: #1d2027;
  --text2: #5d6472;
  /* Marke LIAS (marke/lias/LEITFADEN.md): Akzent LIAS-Grün, Markenlinie Liapor-Rot */
  --accent: #16a34a;
  --accent-text: #ffffff;
  --accent-soft: #dcfce7;
  --brand-red: #e30613;
  --p1: #c62828; --p1-bg: #fde8e8;
  --p2: #d35400; --p2-bg: #fdeee3;
  --p3: #1f6fb5; --p3-bg: #e6f0fa;
  --p4: #5d6472; --p4-bg: #eceef2;
  --ok: #1e8e4e; --ok-bg: #e3f5ea;
  --warn: #9a6b00; --warn-bg: #fdf4d8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141a; --surface: #1b1e27; --surface2: #242835; --border: #333849;
    --text: #e8eaf0; --text2: #9aa1b5; --accent-soft: #14321f;
    --p1: #ff6b6b; --p1-bg: #3d1d1f; --p2: #ff9a4d; --p2-bg: #3a2414; --p3: #6cb2f0; --p3-bg: #172a3d; --p4: #9aa1b5; --p4-bg: #262a36;
    --ok: #4cd08a; --ok-bg: #16301f; --warn: #f0c35a; --warn-bg: #352b12;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12141a; --surface: #1b1e27; --surface2: #242835; --border: #333849;
  --text: #e8eaf0; --text2: #9aa1b5; --accent-soft: #14321f;
  --p1: #ff6b6b; --p1-bg: #3d1d1f; --p2: #ff9a4d; --p2-bg: #3a2414; --p3: #6cb2f0; --p3-bg: #172a3d; --p4: #9aa1b5; --p4-bg: #262a36;
  --ok: #4cd08a; --ok-bg: #16301f; --warn: #f0c35a; --warn-bg: #352b12;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding-bottom: calc(64px + var(--safe-bottom)); }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h3 { font-size: .95rem; margin: 14px 0 8px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--text2); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ── Kopf / Navigation ── */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 16px; padding: calc(8px + var(--safe-top)) 16px 8px; background: var(--surface); border-bottom: 3px solid var(--brand-red); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand-logo { height: 26px; width: auto; }
/* Marke LIAS (marke/lias/LEITFADEN.md) */
/* Symbol so hoch wie der Text daneben (LIAS + ausgeschriebener Name) */
.brand-symbol { height: 52px; width: 52px; border-radius: 8px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 800; letter-spacing: .06em; color: #E30613; font-size: 1.15rem; }
.brand-sub { font-size: .56rem; font-weight: 500; color: var(--text2); white-space: normal; width: 118px; line-height: 1.15; margin-top: 2px; }
.brand-sub b { color: var(--brand-red); font-weight: 800; }
.topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topnav a, .bottomnav a { text-decoration: none; color: var(--text2); border-radius: 8px; position: relative; }
.topnav a { padding: 7px 11px; white-space: nowrap; }
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topright { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--p1); color: #fff; font-size: .72rem; line-height: 18px; text-align: center; font-weight: 700; }
.bottomnav { display: none; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text2); display: inline-block; }
.live-dot.on { background: var(--ok); }

@media (max-width: 1023px) {
  .topnav { display: none; }
  .brand-sub { max-width: 210px; }
  .topbar { padding: calc(6px + var(--safe-top)) 12px 6px; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + var(--safe-bottom)); justify-content: space-around; }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; font-size: .7rem; }
  .bottomnav a .ico { font-size: 1.25rem; line-height: 1.2; }
  .bottomnav a.active { color: var(--accent); font-weight: 600; }
  .bottomnav .badge { position: absolute; top: 0; right: 18%; }
}
@media (min-width: 1024px) { body { padding-bottom: 24px; } }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ── Bausteine ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.tight { padding: 10px 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
/* Am Handy: Arbeits- und Statusknoepfe nach oben, vor Beschreibung und Verlauf */
@media (max-width: 900px) { .detail-layout { display: flex; flex-direction: column; align-items: stretch; gap: 0; } .detail-layout > .col, .detail-layout #d-links { display: contents; } .detail-layout .aktion { order: -1; } }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr; } }

button, .btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; min-height: 40px; }
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn-danger { color: var(--p1); }
.btn-big { padding: 14px 18px; font-size: 1.05rem; min-height: 52px; }
.btn-sm { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; font-size: .85rem; color: var(--text2); margin: 10px 0 4px; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; font-size: .95rem; margin: 8px 0; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); min-height: 42px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.form-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.err { color: var(--p1); margin: 8px 0 0; font-size: .9rem; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; white-space: nowrap; border: 0; border-radius: 0; border-right: 1px solid var(--border); min-height: 42px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.seg.prio button.on[data-v="1"] { background: var(--p1); }
.seg.prio button.on[data-v="2"] { background: var(--p2); }
.seg.prio button.on[data-v="3"] { background: var(--p3); }
.seg.prio button.on[data-v="4"] { background: var(--p4); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 12px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface2); color: var(--text2); }
.prio-1 { background: var(--p1-bg); color: var(--p1); }
.prio-2 { background: var(--p2-bg); color: var(--p2); }
.prio-3 { background: var(--p3-bg); color: var(--p3); }
.prio-4 { background: var(--p4-bg); color: var(--p4); }
.st-neu { background: var(--p1-bg); color: var(--p1); }
.st-zugewiesen { background: var(--p3-bg); color: var(--p3); }
.st-in_arbeit { background: var(--ok-bg); color: var(--ok); }
.st-wartet { background: var(--warn-bg); color: var(--warn); }
.st-erledigt { background: var(--accent-soft); color: var(--accent); }
.st-abgeschlossen { background: var(--surface2); color: var(--text2); }
.chip.neu { background: var(--p1); color: #fff; }

/* ── Listen ── */
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters .f-suche { grid-column: 1 / -1; } }
.tlist { display: flex; flex-direction: column; gap: 8px; }
.titem { display: grid; grid-template-columns: 6px 1fr auto; gap: 0 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); overflow: hidden; box-shadow: var(--shadow); }
.titem:hover { border-color: var(--accent); }
.titem .bar { background: var(--p3); }
.titem .bar.p1 { background: var(--p1); } .titem .bar.p2 { background: var(--p2); } .titem .bar.p4 { background: var(--p4); }
.titem .main { padding: 10px 0; min-width: 0; }
.titem .side { padding: 10px 12px 10px 0; text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.titem .t { font-weight: 600; overflow-wrap: anywhere; }
.titem .meta { font-size: .82rem; color: var(--text2); display: flex; gap: 4px 12px; flex-wrap: wrap; margin-top: 2px; }
.titem.done { opacity: .7; }
.working { color: var(--ok); font-weight: 600; }
.empty { padding: 28px; text-align: center; color: var(--text2); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-size: .8rem; color: var(--text2); text-transform: uppercase; letter-spacing: .03em; }
.tbl tr.off td { opacity: .5; }
.table-wrap { overflow-x: auto; }

/* ── Detail ── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: .93rem; }
.kv dt { color: var(--text2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 9px 0 9px 14px; border-left: 2px solid var(--border); margin-left: 6px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.timeline li.kommentar::before { background: var(--p3); }
.timeline li.dokumentation::before { background: var(--ok); }
.timeline li.arbeit::before { background: var(--accent); }
.timeline .who { font-size: .8rem; color: var(--text2); }
.timeline .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li.dokumentation .txt, .timeline li.kommentar .txt { background: var(--surface2); padding: 8px 10px; border-radius: 8px; margin-top: 3px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos .ph { position: relative; aspect-ratio: 1; background: var(--surface2); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photos .ph .x { position: absolute; top: 4px; right: 4px; min-height: 0; padding: 2px 7px; font-size: .8rem; background: rgba(0,0,0,.55); color: #fff; border: 0; }
.workbox { border: 2px solid var(--ok); background: var(--ok-bg); }
.workbox .timer { font-size: 1.6rem; font-weight: 700; color: var(--ok); font-variant-numeric: tabular-nums; }
.assignee { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.assignee:last-child { border-bottom: 0; }
.picklist { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; }

/* Laufende Arbeit unter dem Kopf */
#arbeit-banner .ab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; background: var(--ok); color: #fff; }
#arbeit-banner .ab a { color: #fff; font-weight: 600; }
#arbeit-banner .ab .sp { flex: 1; min-width: 120px; overflow-wrap: anywhere; }
#arbeit-banner button { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.5); color: #fff; min-height: 34px; padding: 4px 12px; }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.tile .n { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .l { font-size: .82rem; color: var(--text2); }
.tile.alarm .n { color: var(--p1); }
.ma-row.idle td { color: var(--text2); }

/* Anlagenbaum */
.tree { list-style: none; padding-left: 0; margin: 0; }
.tree .tree { padding-left: 22px; border-left: 1px dashed var(--border); margin-left: 8px; }
.tree li > .node { display: flex; align-items: center; gap: 8px; padding: 5px 0; flex-wrap: wrap; }
.tree .node .lbl { flex: 1; min-width: 160px; }
.tree .node.off .lbl { opacity: .5; text-decoration: line-through; }
.tree li.zu > .tree { display: none; }
.tree .tog { min-height: 0; width: 28px; height: 28px; padding: 0; flex-shrink: 0; }
.tree .tog::before { content: '▾'; }
.tree li.zu > .node .tog::before { content: '▸'; }
.tree .tog-leer { width: 28px; flex-shrink: 0; }
.tree .kz { font-family: Consolas, monospace; font-size: .82rem; color: var(--text2); }
.anlage-picker { position: relative; }
.anlage-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; }
.anlage-results div { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--border); }
.anlage-results div:hover, .anlage-results div.hl { background: var(--accent-soft); }
.anlage-chosen { display: flex; align-items: center; gap: 8px; padding: 8px 11px; background: var(--accent-soft); border-radius: 8px; }
.anlage-chosen span { flex: 1; overflow-wrap: anywhere; }

/* Dokumentation */
.doku-filter { grid-template-columns: 2fr 1fr 1fr 1fr; }
.doku-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.doku-karte { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.doku-karte:hover { border-color: var(--accent); }
.doku-bild { position: relative; aspect-ratio: 4 / 3; background: var(--surface2); display: flex; align-items: center; justify-content: center; }
.doku-bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doku-anz { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: 1px 7px; border-radius: 10px; }
.doku-text { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.doku-text .t { font-weight: 600; overflow-wrap: anywhere; }
.doku-kurz { color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.doku-fotos { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
@media (max-width: 900px) { .doku-filter { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .doku-grid { grid-template-columns: 1fr 1fr; gap: 8px; } .doku-text { padding: 8px; } }
/* Newsticker auf dem Dashboard */
.ticker { background: var(--accent); color: #fff; border-radius: var(--radius); overflow: hidden; white-space: nowrap; font-weight: 600; padding: 8px 0; margin-bottom: 14px; }
.ticker-lauf { display: inline-block; padding-left: 100%; animation: ticker-lauf 30s linear infinite; }
.ticker:hover .ticker-lauf { animation-play-state: paused; }
.ticker-trenner { opacity: .6; margin: 0 1.2em; }
@keyframes ticker-lauf { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .ticker-lauf { animation: none; padding-left: 12px; white-space: normal; } }
.tk-zeile { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.tk-zeile textarea { min-height: 0; }
.tk-zeile .btn-row, #tk-body > .btn-row { margin-top: 6px; align-items: center; }
.monitor-link { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; overflow-wrap: anywhere; background: var(--surface2); padding: 8px; border-radius: 6px; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* Login */
.auth-box { max-width: 380px; margin: 8vh auto 0; }
.auth-box .brand-logo { height: 40px; display: block; margin: 0 auto 14px; }
.auth-box .auth-logo { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto 18px; }

.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--p1); color: #fff; }

dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(560px, calc(100vw - 24px)); width: 100%; background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .dlg-body { padding: 18px; max-height: 80vh; overflow-y: auto; }
dialog.img { max-width: 96vw; background: #000; }
dialog.img img { display: block; max-width: 96vw; max-height: 90vh; margin: auto; }

/* Schaltbuch */
.sb-angefordert { background: var(--p3-bg); color: var(--p3); }
.sb-freigeschaltet { background: #c62828; color: #fff; }
.sb-zuschaltung_angefordert { background: var(--p2-bg); color: var(--p2); }
.sb-zugeschaltet { background: var(--ok-bg); color: var(--ok); }
.sb-storniert { background: var(--surface2); color: var(--text2); text-decoration: line-through; }
.sb-banner { padding: 12px 16px; border-radius: var(--radius); font-weight: 600; margin-bottom: 14px; }
.sb-banner.frei { background: #c62828; color: #fff; font-size: 1.05rem; }
.sb-banner.zu { background: var(--ok-bg); color: var(--ok); }
.sb-banner.anf { background: var(--p3-bg); color: var(--p3); }
.sb-banner.storno { background: var(--surface2); color: var(--text2); }
.sb-hinweis { border-color: var(--p2); background: var(--p2-bg); }
.sb-schritt:not(.done) { opacity: .65; }
.sb-nr { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--surface2); align-items: center; justify-content: center; font-size: .85rem; margin-right: 4px; }
.sb-schritt.done .sb-nr { background: var(--accent); color: #fff; }

/* Druck (Schaltschein): nur der Inhalt, hell */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface2: #eee; --text: #000; --text2: #444; --border: #999; --shadow: none; color-scheme: light; }
  .topbar, .bottomnav, #arbeit-banner, .noprint, .toast, .aktion { display: none !important; }
  body { padding: 0; background: #fff; }
  main { max-width: none; padding: 0; }
  .detail-layout { display: block; }
  .card { break-inside: avoid; box-shadow: none; }
  .sb-schritt:not(.done) { opacity: 1; }
  .sb-banner.frei { background: #fff; color: #000; border: 3px solid #000; }
}

/* Schaltauftrag Mittelspannung */
.chip.ms { background: #7b3fa0; color: #fff; }
.sa-entwurf, .sa-storniert { background: var(--surface2); color: var(--text2); }
.sa-storniert { text-decoration: line-through; }
.sa-ausgestellt, .sa-angenommen { background: var(--p3-bg); color: var(--p3); }
.sa-freigeschaltet { background: #c62828; color: #fff; }
.sa-rueckschaltung { background: var(--p2-bg); color: var(--p2); }
.sa-abgeschlossen { background: var(--ok-bg); color: var(--ok); }
.sf td, .sf th { padding: 5px 6px; vertical-align: middle; }
.sf input, .sf select { min-height: 36px; padding: 6px 8px; }
.sf .nr { width: 36px; text-align: center; color: var(--text2); font-weight: 600; }
.sf .sg, .sf .ak { width: 88px; } .sf .x { width: 40px; }
.sf tr.done td { background: var(--ok-bg); }
.sf tr.next td { background: var(--accent-soft); }
.sf .phase { font-weight: 700; color: var(--text2); text-transform: uppercase; font-size: .78rem; letter-spacing: .04em; background: var(--surface2); }
.verantw { display: grid; grid-template-columns: 190px 1fr 90px; gap: 8px; align-items: center; margin-bottom: 8px; }
.verantw .l { font-weight: 600; }
.kuerzel { text-align: center; font-weight: 700; }
.warnbox { border: 2px solid var(--p1); background: var(--p1-bg); color: var(--p1); font-weight: 700; text-align: center; padding: 10px; border-radius: var(--radius); margin: 14px 0; }
@media (max-width: 700px) { .verantw { grid-template-columns: 1fr 70px; } .verantw .l { grid-column: 1 / -1; } }

/* A4-Seite fuers Stationsschaltbuch: nur im Druck sichtbar, immer schwarz auf weiss */
#druck { display: none; }
#druck .blatt { background: #fff; color: #000; font: 10pt/1.3 Arial, sans-serif; display: flex; flex-direction: column; min-height: 270mm; }
#druck h1 { color: #c00; text-align: center; font-size: 18pt; margin: 0 0 7mm; }
#druck .zeile { display: flex; gap: 6mm; margin-bottom: 2.5mm; }
#druck .feld { flex: 1; border-bottom: 1px solid #000; padding: 0 1mm .5mm; min-height: 5mm; }
#druck .feld b { font-weight: normal; color: #444; margin-right: 2mm; }
#druck table { width: 100%; border-collapse: collapse; margin-top: 2mm; }
#druck th, #druck td { border: 1px solid #000; padding: 1mm 1.5mm; text-align: left; vertical-align: middle; height: 6mm; font-size: 9pt; }
#druck th { background: #e6e6e6; }
#druck .c { text-align: center; }
#druck .ph td { background: #f2f2f2; font-weight: bold; font-size: 8pt; height: 4.5mm; }
#druck .warn { border: 2px solid #c00; color: #c00; font-weight: bold; text-align: center; padding: 2mm; margin-top: 4mm; }
#druck .abk { font-size: 7.5pt; color: #333; margin-top: 2mm; }
#druck .unterschrift { display: flex; gap: 8mm; margin-top: 9mm; }
#druck .unterschrift div { flex: 1; border-top: 1px solid #000; padding-top: 1mm; font-size: 8pt; }
#druck .fuss { margin-top: auto; padding-top: 4mm; border-top: 1px solid #999; font-size: 7.5pt; color: #444; display: flex; justify-content: space-between; gap: 4mm; }
#druck .blattkopf { display: flex; align-items: center; border-bottom: 2px solid #c00; padding-bottom: 3mm; margin-bottom: 5mm; }
#druck .blattkopf img, #druck .blattkopf span { width: 40mm; flex: 0 0 40mm; }
#druck .blattkopf img { height: 12mm; width: auto; object-fit: contain; object-position: left; }
#druck .blattkopf h1 { flex: 1; margin: 0; }
#druck h2 { font-size: 11pt; margin: 6mm 0 1mm; border-bottom: 1px solid #000; padding-bottom: 1mm; }
#druck .krit { display: grid; grid-template-columns: max-content 1fr; gap: 1mm 4mm; font-size: 9.5pt; }
#druck .krit b { font-weight: normal; color: #444; }
#druck .nok { color: #c00; font-weight: bold; }
#druck .sammel th, #druck .sammel td { height: auto; font-size: 8.5pt; vertical-align: top; }
#druck .einzel { margin-top: 4mm; break-inside: avoid; }
#druck .einzel .ek { margin: 0 0 1mm; }
#druck .einzel p.small { margin: 1mm 0 0; font-size: 8.5pt; }
@media print {
  @page { size: A4; margin: 12mm; }
  body.druck-sa > *:not(#druck) { display: none !important; }
  body.druck-sa #druck { display: block; }
  #druck th, #druck .ph td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Dokumentation: Rubriken und Regelarbeiten */
.rubriken { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.rubriken a { padding: 7px 12px; border-radius: 18px; border: 1px solid var(--border); text-decoration: none; color: var(--text); background: var(--surface); font-size: .9rem; }
.rubriken a.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rubriken a .n { opacity: .7; margin-left: 5px; font-size: .8rem; }
.rubriken a.add { border-style: dashed; color: var(--text2); }
.rubriken a.prot { margin-left: auto; }
.faellig { font-weight: 600; } .faellig.ueber { color: var(--p1); } .faellig.bald { color: var(--warn); } .faellig.ok { color: var(--ok); }
.ra-pos { margin: 0; padding-left: 22px; } .ra-pos li { padding: 4px 0; }
.pos td { vertical-align: middle; }
.pos .nr, .ed .nr { width: 34px; color: var(--text2); text-align: center; font-weight: 600; }
.pos input, .ed input, .ed select { min-height: 34px; padding: 5px 8px; }
.erg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.erg button { border: 0; border-radius: 0; min-height: 34px; padding: 4px 10px; border-right: 1px solid var(--border); font-size: .85rem; white-space: nowrap; }
.erg button:last-child { border-right: 0; }
.erg .ok.on { background: var(--ok); color: #fff; font-weight: 600; }
.erg .nok.on { background: var(--p1); color: #fff; font-weight: 600; }
.erg .na.on { background: var(--text2); color: var(--surface); font-weight: 600; }
.mw { width: 90px; } .mw.schlecht { border-color: var(--p1); background: var(--p1-bg); color: var(--p1); font-weight: 700; }
input.pflicht { border-color: var(--p1); }
/* Eingabefelder (Messwerte) an Positionen: Plan-Editor und Durchfuehrung */
.ra-felder { display: flex; flex-direction: column; gap: 6px; }
.ra-felder-zeile td { border-top: 0; padding-top: 0; }
.ra-feld { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--surface2); border-radius: 8px; padding: 6px; }
.ra-feld input[data-ff=name] { flex: 1 1 180px; width: auto; }
.ra-feld select { width: auto; }
.ra-feld .kurz { width: 90px; }
.ra-feld .check { margin: 0; white-space: nowrap; }
.ra-werte { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; }
.ra-wert { display: flex; flex-direction: column; margin: 0; font-weight: 600; font-size: .8rem; color: var(--text2); }
.ra-wert input { width: 150px; min-height: 34px; padding: 5px 8px; margin-top: 2px; }
.ra-wert input.schlecht { border-color: var(--p1); background: var(--p1-bg); color: var(--p1); font-weight: 700; }
.check-zeile { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.check-zeile input[type=checkbox] { width: 24px; height: 24px; margin-top: 2px; flex-shrink: 0; }
.check-zeile .t { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.check-zeile.done .t b { text-decoration: line-through; color: var(--text2); }

/* Einsatzplan */
.ez-wrap { padding: 0; overflow-x: auto; --ezname: 170px; }
@media (max-width: 600px) { .ez-wrap { --ezname: 110px; } }
.ez-grid { display: flex; flex-direction: column; }
.ez-row { display: grid; border-bottom: 1px solid var(--border); position: relative; min-height: 30px; }
.ez-row:last-child { border-bottom: 0; }
.ez-name { grid-column: 1; position: sticky; left: 0; z-index: 3; background: var(--surface); padding: 5px 10px; border-right: 1px solid var(--border); font-weight: 600; font-size: .88rem; display: flex; flex-direction: column; justify-content: center; overflow-wrap: anywhere; }
.ez-head { position: sticky; top: 0; z-index: 4; background: var(--surface); }
.ez-head .ez-name { color: var(--text2); font-weight: 600; font-size: .78rem; text-transform: uppercase; }
.ez-kopf { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; font-size: .72rem; color: var(--text2); padding: 4px 0 3px; border-left: 1px solid var(--border); line-height: 1.2; }
.ez-kopf b { font-size: .85rem; color: var(--text); }
.ez-kopf .kw { font-size: .65rem; color: var(--accent); font-weight: 700; }
.ez-kopf.we, .ez-tag.we { background: var(--surface2); }
.ez-kopf.heute b { color: #fff; background: var(--accent); border-radius: 10px; padding: 0 5px; }
.ez-tag { border-left: 1px solid var(--border); }
.ez-tag.heute { box-shadow: inset 2px 0 0 var(--accent); }
.ez-tag.over { background: repeating-linear-gradient(135deg, var(--p1-bg) 0 5px, transparent 5px 10px); box-shadow: inset 0 -3px 0 var(--p1); }
.ez-tag.klick { cursor: copy; }
.ez-tag.klick:hover { background: var(--accent-soft); }
.ez-bar, .ez-auf { z-index: 2; margin: 3px 2px; border-radius: 5px; font-size: .74rem; line-height: 22px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; min-width: 0; }
.ez-bar { color: #fff; font-weight: 600; }
.ez-bar.cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.ez-bar.cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.ez-auf { border: 1px dashed var(--text2); color: var(--text2); background: var(--surface); text-decoration: none; }
.ez-leg { display: inline-flex; align-items: center; gap: 6px; }
.ez-leg i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.ez-leg i.auf { border: 1px dashed var(--text2); }
.ez-leg i.over { background: var(--p1-bg); border: 1px solid var(--p1); }

/* Protokolle filtern (Sammelprotokoll) */
.pf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pf .breit { grid-column: span 2; }
.pf label { margin-top: 0; }
@media (max-width: 900px) { .pf { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .pf { grid-template-columns: 1fr; } .pf .breit { grid-column: auto; } }
.schnell { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.schnell button { min-height: 30px; padding: 3px 10px; font-size: .85rem; }
.schnell button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.summe { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.summe .tile { flex: 0 0 160px; }

/* Gruppen innerhalb einer Plan-Rubrik */
.gruppe { padding: 0; overflow: hidden; margin-bottom: 12px; }
.gkopf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; cursor: pointer; background: var(--surface2); border-bottom: 1px solid var(--border); user-select: none; }
.gkopf .pfeil { font-size: .8rem; width: 14px; color: var(--text2); }
.gkopf h2 { margin: 0; font-size: 1.05rem; flex: 1; min-width: 180px; }
.gkopf .anz { color: var(--text2); font-size: .85rem; font-weight: 400; margin-left: 8px; }
.gruppe.zu .ginhalt { display: none; }
.gruppe.zu .gkopf { border-bottom: 0; }
.gruppe.ohne .gkopf { background: transparent; }
.gruppe .gbeschr { padding: 8px 14px 0; }
.gruppe .gleer { padding: 10px 14px; margin: 0; }
.gruppe .tbl { margin: 0; }
td.cb, th.cb { width: 34px; }
.auswahl { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 10px; }
.auswahl select { width: auto; min-width: 200px; }
.auswahl button { background: #fff; color: #000; border-color: #fff; }
.auswahl button.hell { background: transparent; color: #fff; }
@media (max-width: 700px) { .auswahl { bottom: 76px; } }

/* Meldestellen */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subtabs a { padding: 7px 14px; border-radius: 18px; border: 1px solid var(--border); text-decoration: none; color: var(--text); background: var(--surface); font-size: .9rem; }
.subtabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.ml-liste { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; margin-top: 6px; }
.ml-liste .check { margin: 4px 0; }
.balken { display: inline-block; height: 10px; background: var(--accent); border-radius: 3px; vertical-align: middle; margin-right: 6px; }
.summe .tile { flex: 0 0 150px; }
#druck .aushang .ah-name { font-size: 20pt; text-align: center; margin: 8mm 0 3mm; }
#druck .aushang .ah-text { text-align: center; font-size: 12pt; margin: 2mm 0; }
#druck .aushang .ah-qr { width: 110mm; height: 110mm; margin: 6mm auto; }
#druck .aushang .ah-qr svg { width: 100%; height: 100%; display: block; }
#druck .aushang .ah-link { text-align: center; font-family: ui-monospace, Consolas, monospace; font-size: 8pt; word-break: break-all; color: #333; margin: 0 15mm 4mm; }

/* Plan kopieren */
.kopie-hinweis { border: 1px solid var(--accent); background: var(--surface2); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.pruefen { box-shadow: 0 0 0 2px var(--p2); border-radius: 8px; padding: 0 6px 6px; }

/* Dashboard-Kacheln (feste Hoehe, Inhalt scrollt innen; Anordnung je Benutzer) */
.dk-raster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.dk { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.dk.b2 { grid-column: span 2; }
.dk.b3 { grid-column: span 3; }
.dk-kopf { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface2); border-bottom: 1px solid var(--border); }
.dk-kopf h2 { margin: 0; font-size: .98rem; flex: 1; min-width: 0; }
.dk-kopf .anz { color: var(--text2); font-weight: 400; font-size: .85rem; margin-left: 6px; }
.dk-zu { min-height: 26px; padding: 0 8px; background: transparent; border: 0; color: var(--text2); }
.dk-inhalt { padding: 10px 12px; max-height: 300px; overflow-y: auto; }
.dk-fuss { padding: 6px 12px 8px; border-top: 1px solid var(--border); font-size: .85rem; }
.dk.ein .dk-inhalt, .dk.ein .dk-fuss { display: none; }
.dk.ein .dk-kopf { border-bottom: 0; }
.gtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.gtiles .tile { padding: 8px 10px; box-shadow: none; }
.gtiles .tile .n { font-size: 1.45rem; }
.dk .tlist .titem { padding: 8px 10px; }
.ma-liste { margin-top: 8px; }
.ma-zeile { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.ma-zeile:first-child { border-top: 0; }
.ma-zeile .r { text-align: right; }
.ma-zeile.idle b { color: var(--text2); font-weight: 500; }
.ma-zeile .btn-sm { min-height: 24px; padding: 0 7px; margin-left: 4px; }
.dk-raster.ordnen .dk { outline: 2px dashed var(--accent); outline-offset: -2px; }
.dk-raster.ordnen .dk-inhalt { pointer-events: none; opacity: .7; max-height: 140px; }
.dk-raster.ordnen .dk.ziehen { opacity: .45; }
.griff { cursor: grab; touch-action: none; user-select: none; color: var(--text2); font-size: 1.2rem; padding: 0 4px; }
.werkz { display: flex; gap: 3px; }
.werkz button { min-height: 26px; padding: 0 8px; font-size: .8rem; }
.werkz button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dk-leiste { position: sticky; top: 8px; z-index: 6; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--accent); color: #fff; padding: 9px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.dk-leiste button { background: #fff; color: #000; border-color: #fff; }
@media (max-width: 900px) { .dk-raster { grid-template-columns: minmax(0, 1fr); } .dk.b2, .dk.b3 { grid-column: auto; } }

/* Menüpunkte je Benutzer (Verwaltung → Benutzer) */
.menue-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.menue-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.menue-grid .check.aus { color: var(--text2); }
@media (max-width: 600px) { .menue-grid { grid-template-columns: 1fr; } }
