:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --text: #1d2420;
  --muted: #66706a;
  --border: #e2e0d8;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e6efe9;
  --danger: #a33a2c;
  --danger-soft: #f6e5e2;
  --warn-soft: #fbf3dc;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --surface: #1c211e; --surface-2: #222824; --text: #e6ebe7; --muted: #95a199;
    --border: #2f3632; --accent: #5fae86; --accent-ink: #0f1411; --accent-soft: #1f3329;
    --danger: #e0806f; --danger-soft: #3a2420; --warn-soft: #3a3420;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- Grundgerüst ---------- */
.shell { display: grid; grid-template-columns: 270px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.brand .logo svg { width: 18px; height: 18px; fill: var(--accent-ink); }
.search { flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; }
.usermenu { display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px 30px; overflow-y: auto;
  position: sticky; top: 56px; height: calc(100vh - 56px); }
.side .group { margin-bottom: 14px; }
.side .area-title { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: .78rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }
.side a.nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px 7px 27px;
  border-radius: 7px; color: var(--text); text-decoration: none; }
.side a.nav:hover { background: var(--surface-2); }
.side a.nav.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a.nav .lv { font-size: .7rem; color: var(--muted); }
.side .sep { border-top: 1px solid var(--border); margin: 14px 6px; }
.main { padding: 26px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.crumb { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.btn { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 7px 13px; font: inherit; font-size: .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 9px; font-size: .82rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { min-height: 120px; resize: vertical; }
label.f { display: block; margin-bottom: 12px; font-size: .88rem; font-weight: 550; }
label.f > input, label.f > select, label.f > textarea { margin-top: 4px; font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { width: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: #8a6a14; border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag { display: inline-block; padding: 0 7px; margin: 1px 3px 1px 0; border-radius: 5px; font-size: .75rem;
  background: var(--accent-soft); color: var(--accent); cursor: pointer; }
.empty { padding: 34px; text-align: center; color: var(--muted); }
.note { background: var(--warn-soft); border-radius: 8px; padding: 10px 12px; font-size: .88rem; margin-bottom: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 300px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tr:last-child td { border-bottom: none; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
#tbl td { min-width: 110px; }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.act { text-align: right; white-space: nowrap; }
.doc-title { font-weight: 600; }

/* ---------- Startseite ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { padding: 18px; border-top: 4px solid var(--c, var(--accent)); }
.tile h3 { margin-bottom: 4px; }
.tile ul { list-style: none; padding: 0; margin: 12px 0 0; }
.tile li a { display: block; padding: 5px 0; text-decoration: none; }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.linkcard { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.linkcard a.go { font-weight: 650; font-size: 1.02rem; text-decoration: none; }
.linkcard .url { font-size: .78rem; color: var(--muted); word-break: break-all; }

/* ---------- Seiten / Wissen ---------- */
.pages { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.pagelist a { display: block; padding: 8px 12px; border-radius: 7px; text-decoration: none; color: var(--text); }
.pagelist a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.md { line-height: 1.6; }
.md h1, .md h2, .md h3 { margin-top: 1.1em; }
.md :first-child { margin-top: 0; }
.md code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: .88em; }
.md blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor textarea { min-height: 380px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; }

/* ---------- Upload ---------- */
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted);
  cursor: pointer; transition: .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filelist { list-style: none; padding: 0; margin: 12px 0; font-size: .88rem; }
.filelist li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }

/* ---------- Rechte ---------- */
.perm-area { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.perm-area:last-child { border-bottom: none; }
.perm-row { display: grid; grid-template-columns: 1fr 190px; gap: 12px; align-items: center; padding: 4px 0; }
.perm-row.sub { padding-left: 22px; font-size: .9rem; }
.perm-row select { padding: 5px 8px; }

/* ---------- Spalten-Editor ---------- */
.colrow { display: grid; grid-template-columns: 1fr 140px 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }

/* ---------- Modal / Toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 20, 17, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; }
.modal.wide { width: min(820px, 100%); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; z-index: 200; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.err { background: var(--danger); color: #fff; }
.copybox { display: flex; gap: 8px; }
.copybox input { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth .brand { margin-bottom: 20px; }
.err { color: var(--danger); font-size: .88rem; min-height: 1.2em; margin-bottom: 8px; }
.qr { background: #fff; padding: 10px; border-radius: 8px; width: 200px; }

.btn.full { width: 100%; justify-content: center; }
.gap, .spacer { height: 16px; }
.grow { flex: 1; }
.btns.mt { margin: 16px 0; }
.selflt { max-width: 240px; width: auto; }
.pad-s { padding: 10px; }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; top: 56px; left: 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .brand .name { display: none; }
  .usermenu .uname { display: none; }
  .pages, .editor { grid-template-columns: 1fr; }
  .colrow { grid-template-columns: 1fr 1fr; }
  .perm-row { grid-template-columns: 1fr 150px; }
}
