/* Gleiche ruhige Oberfläche wie die Messprotokolle: Grau wie im Logo, Orange nur als sparsamer Akzent. */
:root {
  --bg: #F8F8F9; --card: #FFFFFF; --soft: #F2F3F4; --line: #E6E7EA; --btn-line: #D3D6DA; --field: #868C94;
  --text: #34383E; --muted: #5E646C;
  --sel: #E9EBEE; --sel-line: #6B7179;
  --accent: #F28A2E; --accent-soft: #FDF1E4; --accent-line: #B9742F; --accent-text: #7A430F;
  --ok-soft: #E8F2EA; --ok-line: #5B8A68; --ok-text: #2F5A3C;
  --warn-soft: #FFF1D6; --warn-line: #B98A2F; --warn-text: #6E4A05;
  --nok-soft: #FBEBE6; --nok-line: #B8654E; --nok-text: #8A3620;
  --bar: #8A9099; --c-mat: #B8654E; --c-arb: #B9742F; --c-ver: #4F6D8F;
  --focus: #B9742F; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--text); background: var(--bg); -webkit-text-size-adjust: 100%; }
#app { min-height: 100%; display: flex; flex-direction: column; }
button, input, select { font-family: inherit; font-size: 15px; color: var(--text); }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 24px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 4px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok-text); } .warn { color: var(--warn-text); } .nok { color: var(--nok-text); }

/* Kopfzeile */
.topbar { flex: none; min-height: 56px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 6px 20px; padding-top: max(6px, env(safe-area-inset-top)); flex-wrap: wrap; }
.brand { display: flex; align-items: center; background: none; border: 0; padding: 0; min-height: 44px; }
.brand b { font-size: 17px; font-weight: 600; }
.mainnav { display: flex; gap: 4px; margin-left: 12px; }
.topright { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.toplogo { display: block; height: 30px; width: auto; flex: none; margin-left: 8px; }
.whoami { font-size: 13px; text-align: right; line-height: 1.25; margin-right: 8px; }
.whoami small { color: var(--muted); display: block; }
.tbtn { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; }
.tbtn.on { background: var(--sel); color: var(--text); font-weight: 600; }
.langs { display: flex; gap: 2px; }
.demo { background: var(--warn-soft); border-bottom: 1px solid var(--warn-line); color: var(--warn-text); padding: 6px 20px; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: 14px; font-weight: 500; }

/* Layout */
.page { flex: 1; padding: 24px; width: 100%; max-width: 1180px; margin: 0 auto; }
.page.narrow { max-width: 720px; }
.center-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login-box { width: 100%; max-width: 400px; }
.login-box .brand-big { margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.login-box h1 { margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.titelzeile { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.grid { display: grid; gap: 14px 18px; margin-bottom: 12px; }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.empty { text-align: center; padding: 36px 20px; }
.empty p { margin: 0 0 12px; }

/* Felder und Knöpfe */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: var(--muted); }
.inp { min-height: 44px; width: 100%; border: 1px solid var(--field); border-radius: 8px; padding: 8px 12px; background: var(--card); }
.btn { min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--btn-line); background: var(--card); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.pri { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.msg { padding: 12px 14px; border-radius: 8px; background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 14px; }
.msg.ok { background: var(--soft); border-color: var(--btn-line); }

/* Auswahl, Reiter, Markierungen */
.auswahl { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 18px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--btn-line); background: var(--card); font-weight: 500; font-size: 14px; }
.chip.on { background: var(--sel); border-color: var(--sel-line); box-shadow: inset 0 0 0 1px var(--sel-line); font-weight: 600; }
.chip.teil { border-style: dashed; border-color: var(--sel-line); }
.tabs { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.tab { min-height: 42px; padding: 0 16px; border-radius: 21px; border: 1px solid var(--btn-line); background: var(--card); font-weight: 500; }
.tab.on { background: var(--sel); border-color: var(--sel-line); font-weight: 600; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sel); color: var(--text); }
.pill.ok { background: var(--ok-soft); color: var(--ok-text); }
.pill.warn { background: var(--warn-soft); color: var(--warn-text); }
.pill.nok { background: var(--nok-soft); color: var(--nok-text); }

/* Kennzahlen */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.kpis.klein { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 14px 0 4px; gap: 10px; }
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi-kopf { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.kpi-kopf .ttl { font-weight: 600; }
.quelle { font-size: 12px; color: var(--muted); }
.kpi .gross { font-size: 26px; font-weight: 600; margin: 2px 0 6px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 1px 0; }
.kv.trenn { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.delta { font-weight: 600; }
.delta.pos { color: var(--ok-text); } .delta.neg { color: var(--nok-text); }
.kpi-k { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi-k b { font-size: 20px; font-weight: 600; }

/* Tabellen */
.tablewrap { overflow-x: auto; }
.dtable, .utable { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.dtable th, .dtable td, .utable th, .utable td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dtable th, .utable th { background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 600; }
.dtable .r { text-align: right; white-space: nowrap; }
.dtable tfoot td { font-weight: 600; border-bottom: 0; }
.utable select { min-height: 40px; }
.utable .inactive td { opacity: .55; }

/* Funnel */
.funnel { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px 0 8px; }
.f-stufe { min-height: 46px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 18px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.f-stufe:nth-child(1) { background: var(--soft); }
.f-stufe:nth-child(3) { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }

/* Projektliste */
.listkopf { margin-top: 10px; }
.listkopf .tabs { margin: 8px 0; }
.legende { gap: 14px; margin: 4px 0 10px; display: flex; align-items: center; flex-wrap: wrap; }
.strich-mini { display: inline-block; width: 2px; height: 14px; background: var(--text); margin-right: 6px; vertical-align: -3px; }
.plist { display: flex; flex-direction: column; gap: 10px; }
.pkarte { text-align: left; width: 100%; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.pkarte:hover { border-color: var(--sel-line); }
.pk-name { flex: 0 0 170px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.pk-name .ttl { font-weight: 600; font-size: 15px; }
.pk-bars { flex: 1 1 360px; min-width: 0; }
.pk-rechts { flex: 1 0 190px; max-width: 240px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); padding-left: 14px; }
.bar { display: grid; grid-template-columns: 78px minmax(80px, 1fr) 44px 112px; gap: 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.bar-spur { display: block; position: relative; height: 10px; background: var(--soft); border-radius: 2px; }
.bar-wert { display: block; height: 10px; background: var(--bar); border-radius: 2px; }
.bar-wert.warn { background: var(--warn-line); } .bar-wert.nok { background: var(--nok-line); }
.bar-strich { position: absolute; top: -4px; height: 18px; width: 2px; background: var(--text); }
.bar-pct { text-align: right; font-weight: 600; }
.bar-txt { text-align: right; font-size: 12px; white-space: nowrap; }

/* Projektdetail */
.ampelbox { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.reiter { margin-top: 4px; }
.reiter h3 { margin-top: 18px; } .reiter h3:first-child { margin-top: 0; }
.svgwrap { max-width: 760px; }
.mbars { display: flex; gap: 10px; align-items: flex-end; min-height: 110px; max-width: 640px; }
.mbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mbar-s { display: block; width: 100%; max-width: 56px; background: var(--bar); border-radius: 3px 3px 0 0; }

/* Regie, Material, Planung */
.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rapporte { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.rapport { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.rapport > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 10px 12px; min-height: 44px; }
.rapport > summary::-webkit-details-marker { display: none; }
.rapport > summary::before { content: '›'; color: var(--muted); transition: transform .15s; }
.rapport[open] > summary::before { transform: rotate(90deg); }
.rapport .r-nr { font-weight: 600; }
.rapport .r-txt { flex: 1 1 220px; }
.rapport .r-betrag { margin-left: auto; }
.rapport .tablewrap { padding: 0 12px 12px; }
details.belege { margin-top: 16px; }
details.belege > summary { cursor: pointer; font-weight: 600; min-height: 36px; }
.planhilfe { margin: 6px 0 10px; }
.inp.zahl { width: 84px; min-height: 38px; padding: 4px 8px; text-align: right; }
.planwrap { max-height: 460px; overflow-y: auto; border-radius: var(--radius); }
.planwrap thead th { position: sticky; top: 0; z-index: 1; }
.kpi-k b.warn { color: var(--warn-text); }

/* Dialoge */
.modal-bg { position: fixed; inset: 0; background: rgba(52, 56, 62, .35); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--card); border-radius: 14px; padding: 22px; max-width: 520px; width: 100%; box-shadow: 0 12px 40px rgba(52, 56, 62, .18); }
.modal h3 { margin: 0 0 10px; font-size: 18px; }
.modal .actions { justify-content: flex-end; }
#toast { position: fixed; left: 50%; top: 68px; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  .page { padding: 16px; }
  .grid.c4 { grid-template-columns: 1fr 1fr; }
  .pk-rechts { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 8px; max-width: none; }
  .bar { grid-template-columns: 64px minmax(60px, 1fr) 40px; }
  .bar-txt { grid-column: 2 / -1; text-align: left; margin-top: -4px; }
  .whoami { display: none; }
  .mainnav { margin-left: 0; order: 3; width: 100%; }
  .toplogo { display: none; }
  .f-stufe { width: 100% !important; }
  .pk-name { flex-basis: 100%; }
}
/* Status der Projektnummer (Aufwand je Projektnummer) */
.pill.ph-offerte { background: #FAEEDA; color: #633806; }
.pill.ph-gewonnen { background: #EAF3DE; color: #27500A; }
.pill.ph-verloren, .pill.ph-unbekannt { background: #F1EFE8; color: #444441; }

.dtable tr.sum td { font-weight: 700; }
/* Aufklappbare Zeilen: Projekt, Funktion, Person */
.pipeline { margin-bottom: 16px; }
.pipeline .dtable .r:nth-child(-n+3) { text-align: left; }
.pipeline summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; gap: 8px; }
.pipeline summary::before { content: '▸'; color: var(--muted); }
.pipeline[open] summary::before { content: '▾'; }
.pipeline[open] summary { margin-bottom: 8px; }
.dtable.baum tr.auf { cursor: pointer; user-select: none; }
.dtable.baum .pfeil { display: inline-block; width: 28px; min-height: 28px; margin-right: 2px; padding: 0; border: 0; background: transparent; color: var(--muted); vertical-align: middle; }
.dtable.baum button.pfeil { cursor: pointer; }
.dtable.baum tr.ebene1 td, .dtable.baum tr.ebene2 td { background: var(--soft); }
.dtable.baum tr.ebene2 td { color: var(--muted); }
.dtable.baum tbody tr.ebene1 td.baum-name { padding-left: 28px; }
.dtable.baum tbody tr.ebene2 td.baum-name { padding-left: 48px; }
.dtable.baum tbody tr.ebene1 td.baum-name:first-child { padding-left: 42px; }
.dtable.baum .baum-zelle { display: flex; align-items: center; }
.dtable.baum .pfeil { flex: none; }
.dtable.baum td.baum-nr { white-space: nowrap; }
.dtable.baum td .angaben { max-width: 260px; }
/* Ergebnisrechnung auf dem Telefon: Spalte «Quelle» ausblenden, damit Stunden und CHF sichtbar bleiben */
@media (max-width: 600px) {
  .dtable.ergebnis th:nth-child(2), .dtable.ergebnis td:nth-child(2) { display: none; }
  .dtable.ergebnis { font-size: 13px; } .dtable.ergebnis th, .dtable.ergebnis td { padding: 7px 4px; overflow-wrap: anywhere; }
}
.schalter { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; font-weight: 500; cursor: pointer; }
.schalter input { width: 20px; height: 20px; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.page > section.panel + section.panel { margin-top: 16px; }
.page > .knoepfe { margin-top: 16px; }
.dtable.eingabe td { padding: 6px; } .dtable.eingabe td .inp:not(.zahl) { min-width: 110px; min-height: 38px; padding: 4px 8px; }
a.btn { text-decoration: none; color: inherit; }
@media (max-width: 600px) { .tablewrap.budget .dtable { font-size: 12px; } .tablewrap.budget th, .tablewrap.budget td { padding: 6px 3px; } }
/* Noch nicht genehmigte Stunden: separat und gelb hinterlegt, zählen nicht gegen das Budget */
.ng { display: inline-block; padding: 0 .4rem; border-radius: 8px; background: #FAEEDA; color: #633806; }
.pk-ng { margin-top: .35rem; color: var(--muted, #5F5E5A); }
