:root {
  --orange: #ef6a2c;
  --slate: #2f4858;
  --teal: #2aa792;
  --bg: #f4f5f2;
  --card: #fff;
  --line: #dfe2dc;
  --ink: #1f2a30;
  --muted: #6b767c;
  --green: #3aaa35;
  --font: "Century Gothic", Futura, "Jost", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--slate); }
h1, h2, h3 { margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; color: var(--orange); letter-spacing: .02em; text-transform: uppercase; }
h3 { font-size: 1rem; color: var(--slate); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Brand */
.brand { display: flex; align-items: baseline; gap: .35rem; font-weight: 700; letter-spacing: .04em; font-size: .9rem; }
.b-thela { color: var(--slate); }
.b-amp { color: var(--orange); }
.b-bbo { color: var(--teal); }

/* Layout */
#app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
#side { background: var(--slate); color: #e9eef0; padding: 1.1rem .9rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: .6rem; }
#side .brand .b-thela { color: #fff; }
#side .brand .b-bbo { color: #7fe0cf; }
.side-title { font-size: 1.25rem; font-weight: 700; color: #fff; }
.year-pick { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: #b9c6cc; }
.year-pick select { padding: .45rem; border-radius: 6px; border: 0; background: #fff; color: var(--ink); font-weight: 700; }
#nav { display: flex; flex-direction: column; gap: 1px; margin-top: .4rem; }
#nav a { color: #dfe7ea; text-decoration: none; padding: .38rem .5rem; border-radius: 6px; display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
#nav a:hover { background: rgba(255, 255, 255, .08); }
#nav a.act { background: #fff; color: var(--slate); font-weight: 700; }
.nav-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: #93a6af; margin: .8rem .5rem .2rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #c3ccd0; }
.dot.in_arbeit { background: #f7a823; }
.dot.geprueft { background: #56c252; }
.dot.home { background: var(--orange); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: .35rem; padding-top: 1rem; }
.side-foot .btn { width: 100%; text-align: left; color: #e9eef0; border-color: rgba(255, 255, 255, .25); }
.side-foot .btn:hover { background: rgba(255, 255, 255, .1); }
#main { padding: 1.5rem 2rem 4rem; min-width: 0; }
.loading { color: var(--muted); padding: 2rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: .6rem; }
[contenteditable="true"] { outline: none; border-bottom: 1px dashed transparent; }
[contenteditable="true"]:hover, [contenteditable="true"]:focus { border-bottom-color: var(--orange); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem; margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.intro { max-width: 70ch; color: #3e4a50; }
.hint { background: #fff6ef; border-left: 3px solid var(--orange); padding: .5rem .8rem; border-radius: 4px; font-size: .85rem; }

/* Buttons */
.btn { display: inline-block; padding: .45rem .8rem; border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; font-size: .87rem; line-height: 1.2; }
.btn:hover { border-color: #b9c0c3; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: #b3261e; border-color: #e8b4b0; }
.icon { border: 0; background: transparent; cursor: pointer; padding: .15rem .3rem; color: var(--muted); border-radius: 4px; font-size: .85rem; }
.icon:hover { background: #eef0ec; color: var(--ink); }
.icon.del:hover { background: #fde8e6; color: #b3261e; }
.lnk { font-size: .82rem; color: var(--orange); text-decoration: none; white-space: nowrap; }

.status-chip { padding: .25rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #e7eaec; color: #4b575d; }
.status-chip.in_arbeit { background: #fff1d6; color: #8a5a00; }
.status-chip.geprueft { background: #ddf3dc; color: #24701f; }

/* Progress / chips */
.prog { height: 10px; background: #eceee9; border-radius: 99px; overflow: hidden; }
.prog > div { height: 100%; background: linear-gradient(90deg, var(--green), #8cc63f); }
.prog-txt { font-size: .82rem; color: var(--muted); margin: .3rem 0 .6rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { font-size: .8rem; padding: .2rem .55rem; border: 1px solid var(--line); border-radius: 99px; text-decoration: none; color: var(--slate); }
.chip:hover { border-color: var(--orange); color: var(--orange); }
.ok-txt { color: #24701f; font-weight: 700; }

/* Checkliste */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: grid; grid-template-columns: 1fr auto minmax(140px, 28%) 26px; align-items: center; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid #f0f1ee; }
.checklist li label { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; }
.checklist li.done label span { color: var(--muted); text-decoration: line-through; }
.checklist input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--green); margin-top: 1px; }
.cl-note { border: 1px solid transparent; border-radius: 5px; padding: .25rem .4rem; font-size: .82rem; background: #fafbf9; }
.cl-note:focus { border-color: var(--line); outline: none; background: #fff; }
.row-add { display: flex; gap: .5rem; margin-top: .7rem; }
.row-add input { flex: 1; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 7px; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: .5rem .6rem; resize: vertical; }
table.mini td { padding: .15rem .6rem .15rem 0; vertical-align: top; }

/* Felder */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem 1.2rem; }
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--muted); }
.field input, .field select, .field textarea { padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); font-size: .9rem; background: #fff; }

/* Tabellen-Editor */
.tbl-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 760px; }
table.grid.wide { min-width: 1350px; }
table.grid th { text-align: left; font-size: .74rem; font-weight: 700; color: var(--slate); padding: .45rem .35rem; border-bottom: 2px solid var(--slate); vertical-align: bottom; hyphens: auto; overflow-wrap: anywhere; }
table.grid td { border-bottom: 1px solid #eceee9; padding: 1px 2px; vertical-align: top; }
table.grid tr:hover td { background: #fbfaf6; }
table.grid th.act, table.grid td.act { width: 104px; white-space: nowrap; text-align: right; }
table.grid td input, table.grid td textarea, table.grid td select { width: 100%; border: 1px solid transparent; background: transparent; padding: .32rem .35rem; border-radius: 4px; font-size: .85rem; resize: none; overflow: hidden; line-height: 1.35; }
table.grid td input:focus, table.grid td textarea:focus, table.grid td select:focus { border-color: var(--orange); background: #fff; outline: none; }
table.grid td select { -webkit-appearance: none; appearance: none; cursor: pointer; }
table.grid td.t-rating, table.grid td.t-check, table.grid th.t-rating, table.grid th.t-check, table.grid td.t-calc, table.grid th.t-calc, table.grid td.t-scale, table.grid th.t-scale { text-align: center; }
table.grid td.t-scale select { text-align: center; text-align-last: center; }
.num { text-align: right; }
.calc { display: inline-block; padding: .35rem; font-weight: 700; color: var(--slate); }
.rate { width: 26px; height: 22px; margin: 4px auto; display: block; border: 1px dashed #c5cbc8; border-radius: 3px; background: transparent; cursor: pointer; }
.rate[style*="background"] { border-color: transparent; }
.rate:disabled { cursor: default; }
.chk { width: 24px; height: 22px; margin: 4px auto; display: block; border: 1px solid #d2d7d4; border-radius: 4px; background: #fff; cursor: pointer; font-size: .75rem; color: var(--slate); padding: 0; }
.chk.on { background: #eef3f5; border-color: var(--slate); font-weight: 700; }
.tbl-actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .78rem; margin-top: .7rem; align-items: center; }
.legend span { display: flex; align-items: center; gap: .3rem; }
.legend i, i.sq { display: inline-block; width: 14px; height: 12px; border-radius: 2px; }
table.grid.ro { min-width: 0; font-size: .8rem; }
table.grid.ro td { padding: .3rem .35rem; }
.vorjahr { background: #fafaf7; border-style: dashed; }

/* Bewertung */
.bew { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: .7rem; max-width: 640px; }
.bew-seg { border: 0; padding: .55rem .2rem; border-radius: 6px; cursor: pointer; background: color-mix(in srgb, var(--c) 18%, white); color: #333; font-size: .8rem; }
.bew-seg.on { background: var(--c); color: #fff; font-weight: 700; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }
.bew-seg:disabled { cursor: default; }

.files { list-style: none; padding: 0; margin: 0 0 .7rem; }
.files li { padding: .25rem 0; }

/* Toast + Dialog */
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--slate); color: #fff; padding: .6rem 1rem; border-radius: 8px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: #b3261e; }
dialog { border: 0; border-radius: 12px; padding: 1.3rem; width: min(640px, 92vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(20, 30, 35, .45); }
dialog .field { margin-bottom: .7rem; }
.dlg-btns { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Login */
.login-body { display: grid; place-items: center; background: linear-gradient(135deg, var(--slate), #1c2d37); }
.login-card { background: #fff; padding: 2rem; border-radius: 14px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: .8rem; }
.login-card h1 { margin: .4rem 0 0; }
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.login-card input { padding: .6rem; border: 1px solid var(--line); border-radius: 7px; }
.msg.err { background: #fde8e6; color: #8c1d18; padding: .5rem .7rem; border-radius: 6px; font-size: .85rem; }

/* Verwendung (eine Quelle) */
.used { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: -.3rem 0 1rem; font-size: .8rem; color: var(--muted); }
.used a { background: #eef6ee; color: #24701f; border-radius: 99px; padding: .2rem .6rem; text-decoration: none; }
.used a:hover { background: #ddf3dc; }
code { background: #f1f2ee; padding: 0 .25rem; border-radius: 3px; }

/* Qualifikationsmatrix */
table.grid.matrix { min-width: 1900px; }
table.grid.matrix th.t-stufe { height: 150px; vertical-align: bottom; padding: 4px 0; }
.vert { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block; font-size: .72rem; }
table.grid.matrix td.t-stufe { text-align: center; }
.stf { width: 20px; height: 18px; }

/* Handbuch-Editor */
.hb { display: grid; grid-template-columns: 290px 1fr; gap: 1rem; align-items: start; }
.hb-toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; display: flex; flex-direction: column; gap: .5rem; padding: .8rem; }
.hb-toc input { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; }
.hb-list { display: flex; flex-direction: column; overflow: auto; }
.hb-list a { text-decoration: none; color: var(--ink); padding: .22rem .4rem; border-radius: 5px; font-size: .83rem; }
.hb-list a:hover { background: #f1f2ee; }
.hb-list a.act { background: var(--orange); color: #fff; }
.hb-list a.l1 { font-weight: 700; margin-top: .4rem; }
.hb-list a.l3 { padding-left: 1.2rem; } .hb-list a.l4 { padding-left: 1.8rem; font-size: .78rem; }
.hb-head { display: flex; gap: .8rem; align-items: flex-end; }
.hb-head .field:first-child { width: 110px; } .hb-head .grow { flex: 1; }
.hb-kact { display: flex; gap: .2rem; padding-bottom: .4rem; }
.blk { padding: .7rem .9rem; }
.blk-h { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.blk-h .blk-ctl { margin-left: auto; }
.blk textarea { min-height: 120px; line-height: 1.5; font-size: .9rem; overflow: hidden; resize: none; }
.blk .row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.blk select { padding: .4rem; border: 1px solid var(--line); border-radius: 6px; max-width: 520px; }
.embed-blk { border-left: 4px solid var(--green); background: #f8fcf7; }
.blk.umbruch { background: repeating-linear-gradient(45deg, #fafaf7, #fafaf7 8px, #f1f2ee 8px, #f1f2ee 16px); text-align: center; }
.bild-row img { border: 1px solid var(--line); border-radius: 6px; max-height: 260px; }
.bild-f { display: flex; flex-direction: column; gap: .5rem; min-width: 260px; }
.btn.sm { padding: .3rem .6rem; font-size: .8rem; }
.md-prev { border-top: 1px dashed var(--line); margin-top: .6rem; padding-top: .6rem; }
.md-prev table.md { border-collapse: collapse; } .md-prev table.md td, .md-prev table.md th { border: 1px solid var(--line); padding: .2rem .4rem; font-size: .8rem; }
.add-blocks { align-items: center; }

.lock { margin-left: auto; font-size: .7rem; opacity: .7; }
table.users td { vertical-align: middle; }
table.users tr.inaktiv td { color: #9aa3a7; text-decoration: line-through; }
table.users td.act { width: 150px; }
.modcheck { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .25rem .8rem; font-size: .85rem; margin-bottom: .8rem; }
.modcheck label { display: flex; gap: .4rem; align-items: center; }

/* Vorschläge */
.vsb { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--orange); color: #fff; font-size: .7rem; font-weight: 700; text-align: center; line-height: 18px; }
#nav a .vsb { margin-left: auto; }
#nav a .vsb + .lock { margin-left: 4px; }
.vs { border-left: 4px solid var(--orange); }
.vs-h { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .4rem; }
.vs-h h3 { margin: 0; }
.vs-h .btn { margin-left: auto; }
.vs-item { display: grid; grid-template-columns: 26px 1fr auto; gap: .6rem; align-items: start; padding: .55rem .2rem; border-top: 1px solid #f0f1ee; font-size: .88rem; }
.vs-item .src { font-size: 1rem; line-height: 1.3; }
.vs-item.p-hoch .vs-t > div:first-child { font-weight: 700; }
.vs-item .op { margin-top: .25rem; font-size: .8rem; color: #24701f; background: #eef6ee; padding: .2rem .5rem; border-radius: 5px; display: inline-block; }
.vs-a { display: flex; gap: .3rem; }
.vs-wichtig { margin: 0; padding-left: 1.1rem; font-size: .86rem; } .vs-wichtig li { margin: .25rem 0; }
.vs-wichtig a { color: var(--orange); text-decoration: none; font-weight: 700; }

@media (max-width: 900px) {
  .hb { grid-template-columns: 1fr; }
  #app { grid-template-columns: 1fr; }
  #side { position: static; height: auto; }
  .grid2 { grid-template-columns: 1fr; }
  #main { padding: 1rem; }
  .checklist li { grid-template-columns: 1fr auto; }
}

/* Dokumentenlenkung */
.lk-hint { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.lk-hint.entwurf { background: #fff3e6; border-left: 4px solid var(--orange); }
.lk-hint.ok { background: #e8f5ec; border-left: 4px solid #2e8b57; }
.lk-hint a { font-weight: 700; margin-left: .4rem; color: inherit; }
.lk-top.entwurf { border-left: 4px solid var(--orange); }
.lk-top.ok { border-left: 4px solid #2e8b57; }
.lk-st { display: inline-block; padding: .15rem .5rem; border-radius: 99px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.lk-st.ok { background: #ddf3dc; color: #24701f; }
.lk-st.neu { background: #fff1d6; color: #8a5a00; }
table.lk tr.lk-offen td { background: #fffaf3; }
#nav a .vsb.lk { background: #8a5a00; }
.files .ver { font-size: .72rem; background: #e7eaec; border-radius: 99px; padding: .05rem .45rem; margin-left: .3rem; }
.files li.alt { padding-left: 1rem; }
.files li.alt ul { margin: .2rem 0 0; }
.fg-liste { max-height: 42vh; overflow-y: auto; border: 1px solid #e3e6e2; border-radius: 6px; padding: .5rem .7rem; margin-bottom: .6rem; }
.fg-liste .field span { font-weight: 700; }
#auText { width: 100%; font-family: inherit; }
