:root{
  --blue:#0d63c4; --green:#12a03c; --ink:#1d2b33; --line:#1d2b33;
  --ui-bg:#eef1f4; --ui-border:#d7dde3; --accent:#0d63c4; --muted:#5d6b76;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:"Lato","Source Sans Pro","Segoe UI",system-ui,-apple-system,"Helvetica Neue",Arial,sans-serif;
  color:var(--ink);background:var(--ui-bg);
}

/* ---------- Kopfleiste ---------- */
.topbar{
  position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:16px;flex-wrap:wrap;
  padding:10px 18px;background:#fff;border-bottom:1px solid var(--ui-border);
  box-shadow:0 1px 6px rgba(20,40,60,.05);
}
.brand{font-weight:800;font-size:17px;letter-spacing:-.01em}
.setpicker{display:flex;gap:8px;flex-wrap:wrap;flex:1}
.topactions{display:flex;gap:8px;flex-wrap:wrap;margin-left:auto}

.btn{
  font:inherit;font-size:14px;font-weight:600;padding:9px 15px;border-radius:8px;
  border:1px solid var(--ui-border);background:#fff;color:var(--ink);cursor:pointer;
  text-decoration:none;display:inline-flex;align-items:center;gap:6px;line-height:1.1;
}
.btn:hover{background:#eef2f6}
.btn-primary,.btn-primary:hover{background:var(--accent);border-color:var(--accent);color:#fff}
.btn-primary:hover{background:#0a54a8;border-color:#0a54a8}
.btn-quiet{color:var(--muted)}
.btn.tiny{padding:5px 9px;font-size:12.5px}
.btn[aria-pressed="true"],.btn[aria-pressed="true"]:hover{background:#12384f;border-color:#12384f;color:#fff}
.btn[aria-pressed="true"]:hover{background:#0d2a3b;border-color:#0d2a3b}

.chip{
  padding:9px 16px;border:1px solid var(--ui-border);border-radius:999px;background:#fff;
  font-size:14.5px;font-weight:600;cursor:pointer;white-space:nowrap;color:var(--ink);
}
.chip:hover{background:#eef2f6}
.chip.active,.chip.active:hover{background:var(--accent);border-color:var(--accent);color:#fff}
.chip.active:hover{background:#0a54a8;border-color:#0a54a8}
.chip .lock{font-size:12px;opacity:.75}

/* ---------- Login ---------- */
.loginbox{
  position:fixed;inset:0;z-index:60;background:rgba(20,35,48,.45);
  display:flex;align-items:flex-start;justify-content:center;padding-top:12vh;
}
.loginbox[hidden]{display:none}
.loginbox form{
  background:#fff;padding:22px;border-radius:12px;width:min(360px,92vw);
  box-shadow:0 18px 50px rgba(15,30,45,.3);display:flex;flex-direction:column;gap:8px;
}
.loginbox label{font-size:12.5px;font-weight:700;color:#41505b}
input[type=text],input[type=password],textarea{
  width:100%;padding:9px 10px;border:1px solid var(--ui-border);border-radius:7px;
  font:inherit;font-size:14px;background:#fff;color:var(--ink);
}
input:focus,textarea:focus{outline:2px solid #b9d5f7;border-color:var(--accent)}
.err{color:#a12727;font-size:13px;margin:2px 0 0}

/* ---------- Einrichtung ---------- */
body.setup{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:20px}
.setupcard{
  background:#fff;padding:26px;border-radius:14px;width:min(430px,94vw);
  box-shadow:0 14px 44px rgba(15,30,45,.14);display:flex;flex-direction:column;gap:7px;
}
.setupcard h1{margin:0 0 4px;font-size:21px}
.setupcard p{margin:0 0 8px;font-size:13.5px;color:var(--muted);line-height:1.5}
.setupcard label{font-size:12.5px;font-weight:700;color:#41505b;margin-top:6px}
.setupcard .btn{margin-top:12px;justify-content:center}
.hint{font-size:12px;color:var(--muted);line-height:1.5}

/* ---------- Aufbau ---------- */
.layout{display:flex;align-items:flex-start}
.editor{
  width:430px;flex:0 0 430px;background:#fff;border-right:1px solid var(--ui-border);
  padding:16px 16px 90px;height:calc(100vh - 57px);overflow-y:auto;position:sticky;top:57px;
}
.editor[hidden]{display:none}
.previewPane{flex:1;padding:22px;overflow-x:auto}

fieldset{border:1px solid var(--ui-border);border-radius:9px;margin:0 0 13px;padding:12px}
legend{font-size:11.5px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);padding:0 5px}
.editor label{display:block;font-size:12px;font-weight:600;margin:9px 0 4px;color:#41505b}
textarea{min-height:92px;resize:vertical;line-height:1.5}
.row{display:flex;gap:7px;flex-wrap:wrap}
.row>*{flex:1}
.group{border:1px solid var(--ui-border);border-radius:8px;padding:10px;margin-bottom:10px;background:#fbfcfd}
.group h3{margin:0;font-size:12.5px;color:var(--muted);letter-spacing:.03em;text-transform:uppercase}
.grouphead{display:flex;justify-content:space-between;align-items:center;gap:6px}
.tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:10px}
.tab{padding:6px 11px;border:1px solid var(--ui-border);border-radius:999px;background:#fff;font-size:13px;cursor:pointer;white-space:nowrap}
.tab.active{background:var(--accent);border-color:var(--accent);color:#fff}
.tab.priv{border-style:dashed}
.check{display:flex;align-items:center;gap:7px;font-size:13px;font-weight:600;color:#41505b;margin:10px 0 0}
.check input{width:16px;height:16px;margin:0}
.check label{margin:0}
.smallhint{font-size:11.5px;color:#7a8792;margin-top:4px;line-height:1.45}

/* ---------- Speicherleiste ---------- */
.savebar{
  position:fixed;left:0;bottom:0;z-index:50;width:430px;display:flex;align-items:center;gap:10px;
  padding:12px 16px;background:#fff;border-top:1px solid var(--ui-border);border-right:1px solid var(--ui-border);
  box-shadow:0 -3px 14px rgba(20,40,60,.07);font-size:13px;
}
.savebar[hidden]{display:none}
#savestate{flex:1;color:var(--muted);font-weight:600}
#savestate.ok{color:var(--green)}
#savestate.bad{color:#a12727}

/* ---------- Blatt ---------- */
.zoomwrap{transform-origin:top left}
.sheetwrap{position:relative;margin:0 0 26px;width:210mm}
.sheetbar{
  position:absolute;top:8px;right:8px;z-index:5;opacity:0;transition:opacity .12s;
}
.sheetwrap:hover .sheetbar,.sheetbar:focus-within{opacity:1}
.sheet{
  width:210mm;min-height:297mm;padding:17mm 15mm 15mm;background:#fff;
  box-shadow:0 2px 14px rgba(20,40,60,.16);display:flex;flex-direction:column;
}
.sheet-head{display:flex;justify-content:space-between;align-items:baseline;gap:12mm;margin-bottom:9mm}
.sheet-title{font-size:22pt;font-weight:800;letter-spacing:-.01em}
.sheet-date{font-size:13.5pt;font-weight:700;white-space:nowrap}
.grp{margin-bottom:9mm}
.grp-title{color:var(--blue);font-size:13.5pt;font-weight:800;margin-bottom:3.5mm}
table.tasks{width:100%;border-collapse:collapse;table-layout:fixed}
table.tasks td{
  border-top:1.6px solid var(--line);border-bottom:1.6px solid var(--line);
  padding:3.6mm 3mm;font-size:12pt;line-height:1.25;vertical-align:middle;
}
table.tasks td.t{border-left:1.6px solid var(--line);padding-left:5mm}
table.tasks td.c{width:17mm;border-left:1.6px solid var(--line);border-right:1.6px solid var(--line)}
.box{display:block;width:7mm;height:7mm;border:1.6px solid var(--line);margin:0 auto}
.reward{font-size:12.5pt;font-weight:700;margin-top:4mm}
.reward b{color:var(--green)}
.reward.choice{display:flex;align-items:flex-start;gap:3mm}
.reward.choice .opts{display:flex;flex-direction:column;gap:2.4mm}
.reward.choice .opt{display:flex;align-items:center;gap:3mm}
.reward.choice .box{width:6.5mm;height:6.5mm;margin:0;flex:0 0 auto}
.sign{margin-top:auto;padding-top:14mm;display:flex;gap:14mm}
.sign div{flex:1}
.sign .lbl{font-size:13pt;margin-bottom:11mm}
.sign .line{border-bottom:1.8px solid var(--line)}
.privflag{
  position:absolute;top:8px;left:8px;z-index:5;background:#12384f;color:#fff;
  font-size:11px;font-weight:700;padding:3px 8px;border-radius:999px;letter-spacing:.02em;
}

@media (max-width:1000px){
  .layout{flex-direction:column}
  .editor{width:100%;flex:none;height:auto;position:static;border-right:0;border-bottom:1px solid var(--ui-border)}
  .savebar{width:100%}
  .previewPane{padding:14px}
}

/* ---------- Druck ---------- */
@page{size:A4 portrait;margin:0}
@media print{
  body{background:#fff}
  .topbar,.editor,.savebar,.loginbox,.noprint,.sheetbar,.privflag{display:none !important}
  .layout{display:block}
  .previewPane{padding:0;overflow:visible}
  .zoomwrap{transform:none !important;height:auto !important;margin-left:0 !important}
  #sheets{font-size:0}
  .sheetwrap{margin:0;width:210mm;position:static}
  .sheet{
    box-shadow:none;margin:0;width:210mm;height:295mm;min-height:0;overflow:hidden;
    break-after:page;page-break-after:always;
  }
  .sheetwrap:last-child .sheet{break-after:auto;page-break-after:auto}
  .sheetwrap.hidden-print{display:none !important}
}
