:root {
  --bg: #f4f3ef; --card: #fff; --ink: #1d2030; --mute: #6c7084; --line: #e3e1da; --line2: #c9c6bc;
  --acc: #0f6e6e; --acc-soft: #e2f1f0; --red: #d63a3a; --ok: #2e9e6b; --grp: #f7f6f2; --sel: #d5ebe9;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
#main { height: 100%; display: flex; flex-direction: column; }
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.btn { border: 1px solid var(--line2); background: var(--card); border-radius: 7px; padding: 6px 12px; white-space: nowrap; }
.btn:hover { border-color: var(--acc); }
.btn:disabled { opacity: .4; cursor: default; border-color: var(--line2); }
.btn.pri { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.danger { color: var(--red); }
.btn.icon { padding: 5px 9px; }
.inp { border: 1px solid var(--line2); border-radius: 7px; padding: 6px 9px; background: #fff; min-width: 0; width: 100%; }
.inp:focus { outline: 2px solid var(--acc-soft); border-color: var(--acc); }
.inp[readonly] { background: #f6f5f1; color: var(--mute); }
textarea.inp { resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; } .row.end { justify-content: flex-end; } .sp { flex: 1; }
.mute { color: var(--mute); } .small { font-size: 12px; }

/* Kopf */
.top { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--acc); letter-spacing: .04em; text-decoration: none; margin-right: 14px; }
.top nav { display: flex; gap: 2px; }
.top nav a { padding: 6px 12px; border-radius: 7px; color: var(--mute); text-decoration: none; }
.top nav a.on { background: var(--acc-soft); color: var(--acc); font-weight: 600; }
.av { width: 26px; height: 26px; border-radius: 50%; background: #d9e6e5; color: #24504f; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; vertical-align: middle; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar .inp { width: 240px; }
.bar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }

.pill { display: inline-block; padding: 0 8px; border-radius: 99px; font-size: 11px; line-height: 18px; border: 1px solid var(--line2); color: var(--mute); }
.pill.p1 { color: #8a5a00; border-color: #ecd79a; background: #fdf6e0; }
.pill.p2 { color: #1e5fa8; border-color: #c4d9f2; background: #edf4fd; }
.pill.p3 { color: var(--ok); border-color: #b9e0cd; background: #eef8f3; }
.empty { padding: 40px; text-align: center; color: var(--mute); }
/* Formulare */
.form label, .dlg label { display: block; font-size: 12px; color: var(--mute); margin: 10px 0 3px; }
.form .g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.form .g3 { display: grid; grid-template-columns: 1fr 2fr; gap: 0 10px; }
.form .g4 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 10px; }
.form details { border-bottom: 1px solid var(--line); padding: 6px 0 12px; }
.form details:not([open]) { padding-bottom: 6px; }
.form summary { cursor: pointer; font-weight: 600; color: var(--acc); padding: 6px 0; list-style-position: inside; }
.form .chk { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--ink); font-size: 14px; }
.wrap { padding: 20px; overflow: auto; flex: 1; }
.page { max-width: 1100px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table.plain { border-collapse: collapse; width: 100%; }
.plain th, .plain td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.plain th { font-size: 12px; color: var(--mute); font-weight: 600; }
.plain tr.click { cursor: pointer; } .plain tr.click:hover td { background: #faf9f6; }
/* Dialoge */
#modal { position: fixed; inset: 0; background: rgba(20, 22, 35, .4); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dlg { width: 460px; max-width: 100%; max-height: 100%; overflow: auto; padding: 18px; }
.dlg h3 { margin: 0 0 6px; } .dlg > .row { margin-top: 16px; flex-wrap: wrap; } .dlg p { margin: 6px 0; }
#menu { position: fixed; z-index: 25; background: var(--card); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, .15); min-width: 220px; overflow: hidden; }
#menu .mi { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 14px; }
#menu .mi:hover { background: #faf9f6; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 40; max-width: 90vw; }
.login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { width: 340px; max-width: 100%; padding: 24px; }
.login h2 { margin: 12px 0 4px; font-size: 18px; }
.login label { display: block; font-size: 12px; color: var(--mute); margin: 12px 0 4px; }
.login .btn { width: 100%; margin-top: 18px; }
#menu a.mi { display: block; padding: 9px 14px; color: inherit; text-decoration: none; }
#menu a.mi:hover { background: #faf9f6; }
.link { color: var(--acc); cursor: pointer; text-decoration: underline; }
a.btn { text-decoration: none; display: inline-block; }

/* ---------- Dokumente ---------- */
.dlg.wide { width: 640px; }
.top nav a.sub { color: var(--ink); }
.crumb { color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb a { color: var(--acc); text-decoration: none; } .crumb b { color: var(--ink); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pcard { padding: 16px; cursor: pointer; display: block; color: inherit; text-decoration: none; }
.pcard:hover { border-color: var(--acc); }
.pcard b { display: block; font-size: 16px; margin: 2px 0 6px; }
.pcard .row { margin-top: 10px; }

.fx { flex: 1; min-height: 0; display: flex; }
.fx-tree { width: 290px; flex: none; overflow: auto; background: var(--card); border-right: 1px solid var(--line2); padding: 8px 0; }
.fx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--card); position: relative; }
.fx-list { flex: 1; overflow: auto; }
.fx-main.drop::after { content: 'Dateien hier ablegen'; position: absolute; inset: 8px; border: 2px dashed var(--acc); border-radius: 12px; background: rgba(226, 241, 240, .85); display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--acc); z-index: 5; pointer-events: none; }
.tn { display: flex; align-items: center; gap: 4px; padding: 5px 10px 5px 0; cursor: pointer; white-space: nowrap; color: inherit; text-decoration: none; }
.tn:hover { background: #faf9f6; }
.tn.on { background: var(--sel); font-weight: 600; }
.tn .tw { width: 18px; text-align: center; color: var(--mute); flex: none; user-select: none; }
.tn .nm { overflow: hidden; text-overflow: ellipsis; }
.tn .cnt { color: var(--mute); font-size: 11px; font-weight: 400; margin-left: auto; padding-left: 8px; }
table.fl { border-collapse: collapse; width: 100%; min-width: 860px; }
.fl th { position: sticky; top: 0; z-index: 2; background: #efede6; text-align: left; font-size: 12px; font-weight: 600; color: var(--mute); padding: 7px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.fl td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
.fl tr:hover td { background: #faf9f6; }
.fl td.nm a { color: var(--ink); text-decoration: none; font-weight: 500; }
.fl td.nm a:hover { color: var(--acc); text-decoration: underline; }
.fl .num { text-align: right; }
.fl td.mn { width: 40px; text-align: right; overflow: visible; }
.fl td.late { color: var(--red); font-weight: 600; }
.ext { display: inline-block; min-width: 34px; text-align: center; font-size: 9px; font-weight: 700; letter-spacing: .03em; line-height: 16px; border-radius: 4px; color: #fff; background: #8a8fa3; margin-right: 8px; padding: 0 4px; vertical-align: 1px; }
.ext.cad { background: #c2410c; } .ext.bim { background: #1e5fa8; } .ext.pdf { background: #d63a3a; } .ext.doc { background: #2b579a; } .ext.xls { background: #1e7145; } .ext.img { background: #7c3aed; } .ext.dir { background: #c9a227; }
.vpill { display: inline-block; border: 1px solid var(--line2); border-radius: 5px; padding: 0 6px; font-size: 11px; line-height: 17px; color: var(--mute); background: #fff; }
.pill.s-offen { color: #b45309; border-color: #f1d5a8; background: #fdf3e2; }
.pill.s-arbeit { color: #1e5fa8; border-color: #c4d9f2; background: #edf4fd; }
.pill.s-pruef { color: #6d28d9; border-color: #d9cdf5; background: #f4effd; }
.pill.s-ok { color: var(--ok); border-color: #b9e0cd; background: #eef8f3; }
.pill.s-zu { color: var(--mute); background: #f3f2ee; }
#upl { position: fixed; right: 18px; bottom: 18px; width: 340px; max-height: 50vh; overflow: auto; z-index: 28; padding: 12px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .18); }
#upl .u { font-size: 12px; margin-top: 8px; } #upl .u span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#upl .pb { height: 4px; background: var(--line); border-radius: 2px; margin-top: 3px; overflow: hidden; } #upl .pb i { display: block; height: 100%; background: var(--acc); width: 0; }
#upl .u.err { color: var(--red); } #upl .u.err .pb i { background: var(--red); }
.cm { border-top: 1px dashed var(--line); padding: 6px 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm small { display: block; color: var(--mute); font-size: 11px; }

/* Betrachter */
.vw { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vw-body { flex: 1; min-height: 0; display: flex; }
.vw-stage { flex: 1; min-width: 0; position: relative; background: #e9e8e3; }
#viewer { position: absolute; inset: 0; }
.vw-msg { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--mute); z-index: 3; background: #e9e8e3; }
.vw-msg b { color: var(--ink); font-size: 16px; }
.spin { width: 30px; height: 30px; border: 3px solid var(--line2); border-top-color: var(--acc); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.vw-side { width: 330px; flex: none; border-left: 1px solid var(--line2); background: var(--card); display: flex; flex-direction: column; }
.vw-side header { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.vw-side .body { flex: 1; overflow: auto; }
.ti { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ti:hover { background: #faf9f6; } .ti.on { background: var(--sel); }
.ti b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti .row { margin-top: 4px; font-size: 12px; color: var(--mute); flex-wrap: wrap; gap: 6px; }
.rl { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 16px; background: var(--card); border-bottom: 1px solid var(--line2); }
.rl .t { border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.rl .t:hover { background: #f3f2ee; } .rl .t.on { background: var(--acc-soft); border-color: var(--acc); color: var(--acc); font-weight: 600; }
.rl .sw { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line2); padding: 0; }
.rl .sw.on { box-shadow: 0 0 0 2px var(--ink); }
.rl .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.rl select { border: 1px solid var(--line2); border-radius: 6px; padding: 3px 4px; background: #fff; }

@media (max-width: 900px) {
  .fx-tree { width: 200px; }
  .vw-side { width: 240px; }
  .bar .inp { width: 100%; }
}
#menu .mi.danger { color: var(--red); }
a.btn { color: inherit; } a.btn.pri { color: #fff; }

/* PDF-Betrachter (Stirling) */
.pv { position: absolute; inset: 0; overflow: hidden; background: #d9d8d3; cursor: grab; touch-action: none; user-select: none; }
.pv.edit { cursor: crosshair; } .pv.edit.pick { cursor: default; }
.pv-in { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 2px 14px rgba(0, 0, 0, .25); }
.pv-in > * { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.pv-tools { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; z-index: 5; cursor: default; }

/* Gemeinsame Tabelle: variable Spalten und Filterzeile */
table.dt { table-layout: fixed; min-width: 100%; }
.dt td { max-width: none; }
.dt thead th { position: sticky; z-index: 2; overflow: hidden; }
.dt tr.h th { top: 0; height: 32px; padding: 0 10px; user-select: none; }
.dt tr.h .lbl { display: block; cursor: pointer; overflow: hidden; text-overflow: ellipsis; line-height: 32px; }
.dt tr.h .lbl:hover { color: var(--ink); }
.dt tr.h th.flt .lbl { color: var(--acc); }
.dt tr.h th.flt .lbl::before { content: '● '; font-size: 9px; vertical-align: 1px; }
.dt .rz { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; border-right: 2px solid transparent; }
.dt .rz:hover, .dt .rz:active { border-right-color: var(--acc); }
.dt tr.f th { top: 32px; padding: 3px 6px 5px; background: #f6f5f0; vertical-align: top; }
.dt .fi { display: block; width: 100%; min-width: 0; border: 1px solid var(--line2); border-radius: 5px; padding: 2px 5px; font-size: 12px; font-weight: 400; color: var(--ink); background: #fff; }
.dt .fi + .fi { margin-top: 2px; }
.dt .fi:focus { outline: 2px solid var(--acc-soft); border-color: var(--acc); }
.dt th.mn { text-align: right; padding: 0 6px; white-space: nowrap; overflow: visible; }
.dt th.mn .btn { padding: 1px 6px; font-size: 12px; }
.dt td.mn { width: auto; }
.dt td a.mute { color: var(--mute); }
.dt th.mn, .dt td.mn { position: sticky; right: 0; }
.dt td.mn { background: var(--card); }
.dt tr:hover td.mn { background: #faf9f6; }
.dt tr.h th.mn { z-index: 3; background: #efede6; }
.dt tr.f th:last-child { position: sticky; right: 0; z-index: 3; }

/* Schnelle IFC-Ansicht (fragview.js) */
.fv-c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
.pv.pv-3d { background: transparent; pointer-events: none; cursor: default; }
.pv.pv-3d.edit { pointer-events: auto; cursor: crosshair; } .pv.pv-3d.edit.pick { cursor: default; }
.pv-3d .pv-in { background: transparent; box-shadow: none; }
.pv-3d .pv-img, .pv-3d .pv-tools { display: none; }
.fv-tools { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; z-index: 6; }
.fv-tools .btn.on { border-color: var(--acc); color: var(--acc); }
.fv-props { position: absolute; left: 12px; top: 12px; width: 330px; max-width: calc(100% - 24px); max-height: calc(100% - 24px); overflow: auto; z-index: 6;
  background: var(--card); border: 1px solid var(--line2); border-radius: 8px; padding: 10px 12px; font-size: 12px; box-shadow: 0 4px 18px rgba(0, 0, 0, .15); }
.fv-props header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; } .fv-props header b { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.fv-props h4 { margin: 10px 0 3px; font-size: 12px; }
.fv-props table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.fv-props th { text-align: left; font-weight: 400; color: #6b7280; width: 45%; padding: 2px 6px 2px 0; vertical-align: top; overflow-wrap: anywhere; }
.fv-props td { padding: 2px 0; overflow-wrap: anywhere; }
