/* IBT AVA – Oberfläche im Stil von IBT Honorar (Apple Human Interface Guidelines, macOS):
   semantische Farbrollen mit Hell/Dunkel, Seitenleiste und Werkzeugleiste, 13 px, ohne Bibliotheken, nie kursiv. */
:root {
  color-scheme: light dark;
  --schrift: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --schrift-titel: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --fenster: #f5f5f7;
  --flaeche: #ffffff;
  --flaeche-2: #f7f7f9;
  --flaeche-hover: rgba(0, 0, 0, .04);
  --seitenleiste: rgba(236, 236, 240, .82);
  --glas: rgba(255, 255, 255, .72);
  --text: #1d1d1f;
  --text-2: #636366;
  --text-3: #8e8e93;
  --trenner: rgba(0, 0, 0, .1);
  --trenner-stark: rgba(0, 0, 0, .16);
  --fuellung: rgba(118, 118, 128, .12);
  --fuellung-2: rgba(118, 118, 128, .08);
  --akzent: #0071e3;
  --akzent-text: #0066cc;
  --akzent-hell: rgba(0, 113, 227, .12);
  --fokus: rgba(0, 113, 227, .45);
  --gruen: #1e7b34; --gruen-hell: #34c759; --gruen-fl: rgba(52, 199, 89, .14);
  --orange: #c93400; --orange-hell: #ff9500; --orange-fl: rgba(255, 149, 0, .15);
  --rot: #d70015; --rot-hell: #ff3b30; --rot-fl: rgba(255, 59, 48, .12);
  --grau: #636366; --grau-hell: #aeaeb2; --grau-fl: rgba(142, 142, 147, .14);
  --schatten-klein: 0 1px 2px rgba(0, 0, 0, .06);
  --schatten-menue: 0 10px 30px rgba(0, 0, 0, .16), 0 0 0 .5px rgba(0, 0, 0, .12);
  --radius: 10px;
  --leiste-h: 52px;
  --seite-b: 224px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fenster: #161618;
    --flaeche: #1f1f21;
    --flaeche-2: #242427;
    --flaeche-hover: rgba(255, 255, 255, .05);
    --seitenleiste: rgba(42, 42, 45, .82);
    --glas: rgba(36, 36, 38, .72);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --trenner: rgba(255, 255, 255, .1);
    --trenner-stark: rgba(255, 255, 255, .16);
    --fuellung: rgba(118, 118, 128, .24);
    --fuellung-2: rgba(118, 118, 128, .16);
    --akzent-text: #2997ff;
    --akzent-hell: rgba(10, 132, 255, .2);
    --fokus: rgba(10, 132, 255, .55);
    --gruen: #30d158; --gruen-fl: rgba(48, 209, 88, .16);
    --orange: #ff9f0a; --orange-fl: rgba(255, 159, 10, .16);
    --rot: #ff453a; --rot-fl: rgba(255, 69, 58, .16);
    --grau: #a1a1a6; --grau-fl: rgba(142, 142, 147, .2);
    --schatten-klein: none;
    --schatten-menue: 0 10px 30px rgba(0, 0, 0, .5), 0 0 0 .5px rgba(255, 255, 255, .14);
  }
}
@media (prefers-contrast: more) {
  :root { --trenner: rgba(0, 0, 0, .3); --trenner-stark: rgba(0, 0, 0, .45); --text-2: #3a3a3c; --text-3: #636366; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --seitenleiste: #ececf0; --glas: #ffffff; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.38 var(--schrift); color: var(--text); background: var(--fenster); -webkit-font-smoothing: antialiased; overflow: hidden; }
#app { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--akzent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 1px; border-radius: 5px; }
::selection { background: var(--akzent-hell); }
[hidden] { display: none !important; }
i, em, cite, address, var, dfn { font-style: normal; }
h1 { font: 700 26px/32px var(--schrift-titel); margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font: 600 13px/16px var(--schrift); margin: 0 0 8px; }
p { margin: 0 0 8px; }

/* ---------- Fenster: Seitenleiste | Hauptbereich ---------- */
.fenster { display: grid; grid-template-columns: var(--seite-b) 1fr; height: 100vh; }
.seitenleiste { background: var(--seitenleiste); backdrop-filter: blur(30px) saturate(1.4); -webkit-backdrop-filter: blur(30px) saturate(1.4); border-right: 1px solid var(--trenner); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.seiten-kopf { height: var(--leiste-h); display: flex; align-items: center; gap: 9px; padding: 0 14px 0 16px; flex: none; }
.seiten-kopf img { width: 22px; height: 22px; }
.seiten-kopf .name { font-weight: 600; font-size: 13px; flex: 1; }
.seiten-scroll { overflow: auto; padding: 4px 10px 16px; flex: 1; }
.seiten-gruppe { margin-top: 14px; }
.seiten-gruppe:first-child { margin-top: 2px; }
.seiten-gruppe > .kopf { font-size: 11px; font-weight: 600; color: var(--text-2); padding: 0 8px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: 6px; color: var(--text); cursor: default; user-select: none; text-decoration: none !important; white-space: nowrap; }
.si:hover { background: var(--flaeche-hover); }
.si[aria-current="page"] { background: var(--fuellung); font-weight: 500; }
.si.unter { padding-left: 16px; }
.seiten-fuss { padding: 10px 14px; border-top: 1px solid var(--trenner); display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-2); flex: none; }
.seiten-fuss button { background: none; border: 0; padding: 2px 4px; border-radius: 5px; color: inherit; cursor: default; display: flex; align-items: center; gap: 6px; font-size: 11px; height: auto; }
.seiten-fuss button:hover { background: var(--flaeche-hover); }
.seiten-fuss a { color: inherit; }
.punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--grau-hell); flex: none; display: inline-block; }
.punkt.gut { background: var(--gruen-hell); } .punkt.warn { background: var(--orange-hell); } .punkt.schlecht { background: var(--rot-hell); }

.hauptbereich { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--flaeche); position: relative; }
.werkzeugleiste { height: var(--leiste-h); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 14px 0 16px; background: var(--glas); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); border-bottom: 1px solid var(--trenner); position: relative; z-index: 5; }
.werkzeugleiste .titel { font: 600 15px/1.2 var(--schrift-titel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.werkzeugleiste .untertitel { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.werkzeugleiste .titelblock { display: flex; flex-direction: column; min-width: 90px; flex: 0 1 auto; }
.werkzeugleiste .platz { flex: 1; }
.werkzeugleiste .trenn { width: 1px; height: 20px; background: var(--trenner); margin: 0 2px; }
.ansicht { flex: 1; overflow: auto; min-height: 0; position: relative; }
.inhalt { padding: 20px 24px 40px; max-width: 1600px; }

/* ---------- Bedienelemente ---------- */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 7px; border: 0; background: var(--fuellung); color: var(--text); font-weight: 500; cursor: default; white-space: nowrap; user-select: none; text-decoration: none !important; }
button:hover, .btn:hover { background: var(--trenner-stark); }
button.primary { background: var(--akzent); color: #fff; }
button.primary:hover { background: #0068d1; }
button.danger { background: transparent; color: var(--rot); }
button.danger:hover { background: var(--rot-fl); }
button.klein { height: 24px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
button:disabled { opacity: .45; pointer-events: none; }
.segment { display: inline-flex; background: var(--fuellung); border-radius: 7px; padding: 2px; gap: 2px; }

input, select, textarea { height: 26px; border: 1px solid var(--trenner-stark); border-radius: 6px; background: var(--flaeche); padding: 0 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--akzent); box-shadow: 0 0 0 3px var(--fokus); }
textarea { height: auto; min-height: 64px; padding: 6px 8px; resize: vertical; line-height: 1.45; width: 100%; }
input:disabled { background: var(--fuellung-2); color: var(--text-2); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
label.f input, label.f select { width: 100%; }

/* ---------- Inhalte ---------- */
.panel { background: var(--flaeche); border: 1px solid var(--trenner); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--schatten-klein); margin-bottom: 14px; min-width: 0; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.cols { display: grid; gap: 16px; grid-template-columns: 330px 1fr; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
.muted { color: var(--text-2); }
.ok { color: var(--gruen); } .err { color: var(--rot); } .warn { color: var(--orange); }
.right { text-align: right; }
.diff { font-size: 12px; color: var(--text-2); }
.diff b { color: var(--text); font-weight: 600; }
.kz { font-size: 12px; color: var(--text-2); }
.kz + div { font: 600 15px/20px var(--schrift-titel); margin-top: 2px; }

.toast { position: fixed; right: 16px; bottom: 16px; background: var(--glas); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); color: var(--text); padding: 10px 14px; border-radius: 10px; max-width: 420px; z-index: 50; box-shadow: var(--schatten-menue); }
.toast.err { color: var(--rot); }
.banner { background: var(--akzent-hell); color: var(--akzent-text); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; }

/* ---------- Tabellen (macOS: abwechselnde Zeilen, Auswahl, feste Kopfzeile) ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { position: sticky; top: 0; z-index: 2; background: var(--flaeche); text-align: left; font-weight: 500; font-size: 12px; color: var(--text-2); padding: 0 10px; height: 28px; border-bottom: 1px solid var(--trenner); white-space: nowrap; }
th.right { text-align: right; }
td { padding: 0; height: 30px; border-bottom: 1px solid var(--trenner); vertical-align: middle; }
table.plain td { padding: 6px 10px; height: 34px; border-bottom-color: transparent; }
table.plain tbody tr:nth-child(even) td { background: var(--flaeche-2); }
table.plain tbody tr:hover td { background: var(--flaeche-hover); }
td.p { padding: 4px 10px; }
td.num { text-align: right; padding: 0 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.oz { padding: 0 10px; white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; width: 1%; }
table.lv td input, table.lv td select, table.lv td textarea { width: 100%; height: 29px; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 0 10px; }
table.lv td input:focus, table.lv td select:focus, table.lv td textarea:focus { background: var(--flaeche); box-shadow: inset 0 0 0 2px var(--akzent); }
table.lv td select { padding: 0 4px; }
table.lv td textarea { padding: 6px 10px; }
table.lv td input.bad { box-shadow: inset 0 0 0 2px var(--rot-hell); }
table.lv td button { height: 24px; font-size: 12px; padding: 0 9px; border-radius: 6px; }
table.lv td.p { padding: 2px 10px; }
th.p { padding: 4px 10px; height: auto; }
th.p input { width: 100%; }
tr.titel td { background: var(--fuellung-2); font-weight: 600; }
tr.titel td input { font-weight: 600; }
tr.sel td, tr.titel.sel td { background: var(--akzent-hell); }
tr.lang td { background: var(--flaeche); }
tr.lang textarea { min-height: 90px; }
td.min { background: var(--akzent-hell); }
td.min input { font-weight: 700; }
tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--flaeche); border-top: 1px solid var(--trenner); border-bottom: 0; height: 30px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 0 10px; }
@media (max-width: 1000px) { .fenster { grid-template-columns: 1fr; } .seitenleiste { display: none; } }

/* ---------- Projekt: Baum | Detail (Aufbau wie SJ AVA) ---------- */
.ansicht.fix { overflow: hidden; }
.ansicht.fix > .inhalt { padding: 0; max-width: none; height: 100%; }
.teilung { display: grid; grid-template-columns: var(--baum-b, 380px) 5px minmax(0, 1fr); height: 100%; min-height: 0; }
.baum { overflow: auto; padding: 6px 4px 24px; background: var(--flaeche); outline: none; min-width: 0; }
.teiler { cursor: col-resize; background: var(--trenner); }
.teiler:hover, .teiler.zieht { background: var(--akzent); }
.detail { overflow: auto; padding: 0 18px 28px; min-width: 0; background: var(--flaeche); }
.bz { display: flex; align-items: center; gap: 6px; height: 22px; padding-right: 8px; white-space: nowrap; cursor: default; border-radius: 5px; margin: 0 2px; user-select: none; }
.bz:hover { background: var(--flaeche-hover); }
.bz.gewaehlt { background: var(--akzent-hell); }
.baum:focus-within .bz.gewaehlt { background: var(--akzent); color: #fff; }
.bz .chev { width: 12px; flex: none; text-align: center; color: var(--text-2); font-size: 9px; }
.baum:focus-within .bz.gewaehlt .chev { color: #fff; }
.bz .txt { overflow: hidden; text-overflow: ellipsis; }
.bz.fett .txt { font-weight: 600; }
.ico { width: 16px; height: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font: 700 10px/16px var(--schrift); color: #fff; }
.ico.p { background: var(--gruen-hell); }
.ico.p.bedarf { background: var(--orange-hell); }
.ico.p.alternativ { background: var(--grau-hell); }
.ico.h { background: var(--akzent); }
.ico.ordner svg, .ico.sym svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico.ordner { color: var(--orange-hell); }
.ico.sym { color: var(--akzent); }
.reiter { display: flex; gap: 2px; border-bottom: 1px solid var(--trenner); margin: 0 -18px 14px; padding: 0 12px; background: var(--flaeche-2); position: sticky; top: 0; z-index: 3; }
.reiter button { height: 32px; background: none; border-radius: 0; border-bottom: 2px solid transparent; padding: 0 12px; color: var(--text-2); }
.reiter button:hover { background: var(--flaeche-hover); }
.reiter button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--akzent); font-weight: 600; }
.kopfzeile { padding-top: 14px; }
.fk1 { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 10px; align-items: center; margin-bottom: 10px; }
.fk1 > span { color: var(--text-2); }
.fk1 .nr { width: 100px; }
.formraster { display: grid; grid-template-columns: minmax(250px, 1.1fr) minmax(170px, .6fr) minmax(190px, .7fr) minmax(300px, 2fr); gap: 12px 24px; align-items: start; margin-top: 4px; }
@media (max-width: 1500px) { .formraster { grid-template-columns: 1fr 1fr; } }
.fgrp { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 8px; align-items: center; }
.fgrp > span { text-align: right; color: var(--text-2); white-space: nowrap; }
.fgrp .paar { display: flex; gap: 6px; min-width: 0; }
.fgrp .paar input:first-child { width: 90px; flex: none; }
.fgrp .paar input:last-child { flex: 1; }
.fgrp input.num, .fgrp input[type=text], .fgrp select { width: 100%; }
.fgrp .wert { font-weight: 600; color: var(--akzent-text); }
.chkzeile { display: flex; flex-wrap: wrap; gap: 4px 22px; align-items: center; margin: 0 0 10px; }
.chk { display: inline-flex; align-items: center; gap: 6px; }
.chk input { width: 14px; height: 14px; margin: 0; accent-color: var(--akzent); }
.chk.aus { color: var(--text-3); }
.editwerk { border: 1px solid var(--trenner-stark); border-radius: 8px; overflow: hidden; margin-top: 14px; background: var(--flaeche); }
.edleiste { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 6px; background: var(--flaeche-2); border-bottom: 1px solid var(--trenner); }
.edleiste button.tb { width: 28px; height: 24px; padding: 0; font-size: 12px; background: transparent; }
.edleiste button.tb:hover { background: var(--fuellung); }
.edleiste select { height: 24px; font-size: 12px; }
.edleiste .trenn { width: 1px; height: 18px; background: var(--trenner); margin: 0 3px; }
.editor { min-height: 300px; max-height: calc(100vh - 430px); overflow: auto; padding: 10px 14px; font: 13px/1.45 Arial, var(--schrift); outline: none; }
.editor:focus { box-shadow: inset 0 0 0 2px var(--fokus); }
.editor ul, .editor ol { margin: 0 0 0 22px; padding: 0; }
.edstatus { padding: 3px 10px; font-size: 11px; color: var(--text-2); border-top: 1px solid var(--trenner); background: var(--flaeche-2); }
.bilder { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; }
.bilder figure { margin: 0; border: 1px solid var(--trenner); border-radius: 8px; overflow: hidden; background: var(--flaeche-2); }
.bilder img { display: block; width: 100%; height: 140px; object-fit: cover; }
.bilder figcaption { display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-size: 11px; }
.bilder figcaption span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.lt { padding: 2px 10px 8px; color: var(--text-2); font-size: 12px; white-space: pre-wrap; }
td.nr { padding: 0 10px; color: var(--text-2); white-space: nowrap; width: 1%; font-variant-numeric: tabular-nums; }
table.ue tbody tr { cursor: default; }
table.ue tbody tr:hover td { background: var(--flaeche-hover); }
table.ue td { padding: 5px 10px; height: auto; }
@media print {
  .baum, .teiler, .reiter { display: none !important; }
  .teilung { display: block; height: auto; }
  .detail { overflow: visible; padding: 0; }
  .ansicht.fix { overflow: visible; }
  .ansicht.fix > .inhalt { height: auto; }
}

/* ---------- Anmeldung ---------- */
.login-seite { height: 100%; display: grid; place-items: center; padding: 16px; background: var(--fenster); }
.login { width: 100%; max-width: 340px; }
.login .kopf { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.login .kopf img { width: 40px; height: 40px; border-radius: 10px; }
.login .kopf h1 { font: 600 20px/1.2 var(--schrift-titel); margin: 0; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login button { height: 32px; }

@media print {
  .seitenleiste, .werkzeugleiste, .banner, .toast { display: none !important; }
  .fenster { display: block; height: auto; }
  body { overflow: visible; background: #fff; color: #000; }
  .ansicht { overflow: visible; }
  th { position: static; }
  table.lv td input, table.lv td textarea { color: #000; }
  tfoot td { position: static; }
}
