/* ===== GENERIC MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal {
  background: var(--parchment);
  border: 2px solid var(--bronze);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
@media (max-height: 700px) { .modal { max-height: 95vh; padding: 1.2rem; } }
.modal h3 { font-family: 'Cinzel', serif; color: var(--blood); margin-bottom: 1.2rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ===== TEMPLATE PICKER ===== */
.tpl-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 1rem;
}
.tpl-modal {
  background: var(--parchment);
  border: 2px solid var(--bronze);
  border-radius: 8px;
  width: 100%; max-width: 680px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}
.tpl-modal-header {
  background: var(--ink);
  padding: 1rem 1.2rem;
  display: flex; align-items: center; gap: 0.8rem;
  border-bottom: 2px solid var(--gold);
}
.tpl-modal-title { font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 600; color: var(--gold); flex: 1; }
.tpl-modal-close {
  background: none; border: none;
  color: var(--stone-light); font-size: 1.3rem;
  cursor: pointer; padding: 0.2rem 0.5rem;
  border-radius: 4px; transition: all 0.2s;
}
.tpl-modal-close:hover { background: rgba(255,255,255,0.1); color: white; }
.tpl-modal-controls {
  padding: 0.8rem 1rem;
  background: var(--parchment-dark);
  border-bottom: 1px solid rgba(160,112,48,0.3);
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.tpl-search {
  flex: 1; min-width: 180px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--bronze);
  border-radius: var(--radius);
  background: var(--input-bg-focus);
  font-family: 'Crimson Text', serif; font-size: 0.95rem;
}
.tpl-search:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px var(--glow); }
.tpl-group-filter {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--bronze);
  border-radius: var(--radius);
  background: var(--input-bg-focus);
  font-family: 'Crimson Text', serif; font-size: 0.9rem;
}
.tpl-modal-body { flex: 1; overflow-y: auto; padding: 1rem; }
.tpl-group-label {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem; letter-spacing: 0.12em;
  color: var(--stone); text-transform: uppercase;
  padding: 0.5rem 0 0.3rem;
  border-bottom: 1px solid rgba(160,112,48,0.25);
  margin-bottom: 0.5rem; margin-top: 0.8rem;
}
.tpl-group-label:first-child { margin-top: 0; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.5rem; margin-bottom: 0.5rem; }
.tpl-card {
  background: white;
  border: 1px solid rgba(160,112,48,0.35);
  border-radius: 4px; padding: 0.6rem 0.8rem;
  cursor: pointer; transition: all 0.15s; position: relative;
}
.tpl-card:hover { border-color: var(--gold); background: rgba(200,151,42,0.06); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.1); }
.tpl-card.already-added { opacity: 0.45; cursor: not-allowed; background: rgba(0,0,0,0.03); }
.tpl-card.already-added:hover { transform: none; box-shadow: none; }
.tpl-card.vn-card-selected { border-color: var(--gold); background: rgba(200,151,42,0.1); box-shadow: 0 0 0 2px rgba(200,151,42,0.35); }
.tpl-card-name { font-family: 'Crimson Text', serif; font-size: 0.95rem; font-weight: 600; color: var(--ink); margin-bottom: 0.2rem; }
.tpl-card-probe { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--stone); }
.tpl-card-badge { position: absolute; top: 0.4rem; right: 0.4rem; background: var(--blood); color: white; font-family: 'Cinzel', serif; font-size: 0.55rem; padding: 0.1rem 0.35rem; border-radius: 2px; }
.tpl-card-badge.be { background: var(--stone); }
.tpl-card-badge.merkmal { background: #1a4a8b; }
.tpl-manual-btn {
  margin-top: 1rem; padding: 0.6rem 1rem;
  border: 2px dashed rgba(160,112,48,0.4);
  border-radius: 4px; background: transparent; width: 100%;
  font-family: 'Cinzel', serif; font-size: 0.75rem;
  color: var(--stone); cursor: pointer; transition: all 0.2s;
}
.tpl-manual-btn:hover { border-color: var(--bronze); color: var(--bronze); background: rgba(160,112,48,0.05); }
.tpl-empty { text-align: center; padding: 2rem; color: var(--stone); font-style: italic; }

/* ===== SIDEBAR OVERLAY ===== */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 140;
}

/* ===== PDF-PROTOKOLL MODAL ===== */
.pdf-log-box {
  background: #1a1a1a;
  border: 1px solid var(--bronze);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  width: min(780px, 95vw);
  max-height: 80vh;
  overflow: hidden;
}
.pdf-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(200,151,42,0.12);
  border-bottom: 1px solid rgba(200,151,42,0.25);
  flex-shrink: 0;
}
.pdf-log-title {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}
.pdf-log-close {
  background: none;
  border: none;
  color: var(--stone);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}
.pdf-log-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.pdf-log-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bronze) transparent;
}
.pdf-log-body .mits-error-log {
  font-size: 0.8rem;
  padding: 0.8rem 1rem;
}
.pdf-log-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.6rem 1rem;
  border-top: 1px solid rgba(200,151,42,0.2);
  flex-shrink: 0;
}
