/* DRK Protokoll – Simplified & Stable (offline-fähig) */
:root{
  --bg:#0b0c10;
  --card:#11131a;
  --card2:#0f1117;
  --text:#e8eaf2;
  --muted:#a8afc2;
  --line:rgba(255,255,255,.08);
  --red:#E60005;
  --blue:#0b4ea2;
  --white:#ffffff;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b0c10;
  color: var(--text);
}

.appbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  background: rgba(17,19,26,.85);
  position: sticky;
  top:0;
  z-index:10;
  backdrop-filter: blur(10px);
}
.brand{display:flex; align-items:center; gap:10px; min-width:260px}
.logo svg{width:34px; height:34px; fill:var(--red); display:block}
.brandtitle{font-weight:700}
.brandsub{color:var(--muted); font-size:12px}
.actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap; justify-content:flex-end}

.layout{
  display:grid;
  grid-template-columns: 340px 1fr;
  gap:12px;
  padding:12px;
  align-items:start;
}

.sidebar{
  background: var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
}
.sidehead{padding:12px; border-bottom:1px solid var(--line)}
.sidetitle{font-weight:700; margin-bottom:8px}
.sidefoot{
  display:flex; flex-wrap:wrap; gap:8px;
  padding:12px; border-top:1px solid var(--line)
}

.plist{max-height: calc(100vh - 250px); overflow:auto}
.protocol-item{
  padding:10px 12px;
  border-top:1px solid var(--line);
  cursor:pointer;
}
.protocol-item:hover{background: rgba(255,255,255,.04)}
.protocol-item.active{background: rgba(230,0,5,.10)}
.protocol-item .t{font-weight:650}
.protocol-item .s{color:var(--muted); font-size:12px; margin-top:2px}

.editor{display:flex; flex-direction:column; gap:12px}
.card{
  background: var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
}
.cardtitle{font-weight:800; margin-bottom:10px}
.cardtitle.row{display:flex; justify-content:space-between; align-items:center}

.grid{display:grid; grid-template-columns: repeat(4, 1fr); gap:10px}
.grid2{display:grid; grid-template-columns: 1fr 1fr; gap:10px; margin-top:10px}
.field span{display:block; font-size:12px; color:var(--muted); margin-bottom:6px}

.input, .textarea, .select{
  width:100%;
  border-radius:10px;
  border:1px solid var(--line);
  padding:10px 10px;
  background: var(--card2);
  color: var(--text);
  outline: none;
}
.textarea{resize:vertical; min-height:80px}
.select{padding:10px}

.btn{
  border:1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: var(--text);
  padding:10px 12px;
  border-radius:10px;
  cursor:pointer;
  user-select:none;
}
.btn:hover{background: rgba(255,255,255,.10)}
.btn.primary{background: rgba(230,0,5,.16); border-color: rgba(230,0,5,.5)}
.btn.primary:hover{background: rgba(230,0,5,.22)}
.btn.danger{background: rgba(230,0,5,.12); border-color: rgba(230,0,5,.45)}
.btn.small{padding:7px 9px; border-radius:9px; font-size:13px}
.btn.icon{padding:7px 9px; width:36px}

.tops{display:flex; flex-direction:column; gap:10px}
.top-card{
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
  background: rgba(0,0,0,.35);
}
.topbar{
  display:grid;
  grid-template-columns: 86px 1fr auto;
  gap:8px;
  align-items:center;
  padding:10px;
  border-bottom:1px solid var(--line);
  background: rgba(0,0,0,.35);
}
.topno{font-weight:800; color: var(--muted)}
.topbtns{display:flex; gap:6px}
.top-title{min-width:0}

.rte{padding:10px}
.toolbar{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px}
.toolbar .sep{width:1px; background:var(--line); margin:0 4px}
.editorbox{
  min-height:140px;
  padding:10px;
  border:1px solid var(--line);
  border-radius:10px;
  background: var(--card2);
  outline:none;
}
.editorbox:empty:before{
  content:"Beschluss / Inhalt eingeben…";
  color: rgba(168,175,194,.7);
}

/* Bildauswahl im Editor */
.editorbox img.img-selected{
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.print-root{display:none}

/* ================= PRINT ================= */
@page{ size: A4; margin: 0; }

@media print{
  body{background:#fff; color:#000; -webkit-print-color-adjust: exact; print-color-adjust: exact}
  .appbar, .layout{display:none !important}
  .print-root{display:block !important}
  .print-page{
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 0;
    color:#000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11pt;
    line-height: 1.25;
  }
  .avoid-break{break-inside: avoid; page-break-inside: avoid}
  /* ====== Bereitschafts-Protokoll (PDF-Layout) ====== */
  .p-doc{width: 210mm; border-collapse: collapse;}
  .p-doc thead{display: table-header-group;}
  .p-doc tbody{display: table-row-group;}
  .p-doc td{padding:0;}

  .p-pad{padding-left: 22mm; padding-right: 22mm;}

  .p-header{display:flex; justify-content:space-between; align-items:flex-start; padding: 14mm 22mm 6mm; width: 100%; background:#fff; z-index: 10;}
  .p-header .left{font-size: 11pt;}
  .p-header .left b{font-weight:700}
  .p-header .right{display:flex; align-items:flex-start; gap:6mm;}
  .p-header .right .cross svg{width:18mm; height:18mm; fill: var(--red)}
  .p-header .right .rtxt{font-size: 16pt; line-height: 1.05; font-weight:700}

  .p-header-spacer{height: 28mm;}

  /* Mehr "Luft" oben: Abstand wie im Original (Small-Text nicht an der Kante) */
  .p-redband{background: var(--red); color:#fff; padding: 14mm 22mm 12mm;}
  .p-redband .small{font-size: 13pt; opacity: .95; margin-bottom: 2mm;}
  .p-redband .big{font-size: 26pt; font-weight:700; line-height:1.05;}

  .p-meta{padding: 9mm 22mm 0;}
  .p-meta .row{display:flex; gap:10mm;}
  .p-meta .tbl{margin-top: 2mm;}
  .p-meta .line{display:flex; gap:10mm; margin: 1.2mm 0;}
  .p-meta .lab{min-width: 34mm; color: var(--red); font-weight:700;}
  .p-meta .val{color: #0b2e5a; font-weight:700;}

  .p-h2{font-size: 22pt; font-weight:700; margin: 10mm 0 4mm; padding: 0 22mm;}
  .p-bullets{margin:0; padding: 0 22mm 6mm 28mm; color:#0b2e5a; font-size: 12pt;}
  .p-bullets li{margin: 1mm 0;}
  .p-bullets{list-style-type: square;}

  .p-topband{background: var(--red); color:#fff; text-align:center; padding: 3.5mm 22mm; font-weight:700; font-size: 14pt;}
  .p-topbody{padding: 3mm 22mm 6mm;}

  /* In den Beispiel-PDFs wirken Listen wie "-"-Bullets */
  .p-topbody ul{list-style:none; padding-left: 0; margin: 0;}
  .p-topbody li{margin: 1mm 0; padding-left: 8mm; position: relative;}
  .p-topbody li::before{content:"-"; position:absolute; left:0;}

  .p-topbody img{max-width: 100%; height:auto;}

  .p-blueband{background:#0b2e5a; color:#fff; text-align:center; padding: 2mm 22mm; font-size: 10pt; margin-top: 2mm;}
  .p-footer{padding: 4mm 22mm 10mm; text-align:center; font-size: 11pt;}
  .p-footer .page{margin-bottom: 1mm;}
}

/* ===== Passwortschutz Overlay ===== */
.pw-gate[hidden]{display:none !important;}

.pw-gate{
  backdrop-filter: blur(10px);

  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 9999;
}
.pw-card{
  width: min(420px, 92vw);
  background:#fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
  border: 1px solid rgba(0,0,0,.12);
}
.pw-title{font-size: 18px; font-weight: 800; margin-bottom: 4px;}
.pw-sub{opacity:.8; margin-bottom: 12px;}
.pw-row{display:flex; gap:10px; align-items:center;}
.pw-row .input{flex:1;}
.pw-err{color:#b00020; margin-top:10px; min-height: 1.2em;}
body.locked main, body.locked header.appbar{filter: blur(2px); pointer-events:none; user-select:none;}
