/* ─── RESET & BASE ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #f0f2f5;
  color: #1e2939;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ─── BOOT SCREEN ───────────────────────────────────────────────── */
#boot {
  position: fixed; inset: 0; background: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; z-index: 9999;
}
.boot-logo  { font-size: 48px; margin-bottom: 4px; }
.boot-title { font-size: 1.3rem; font-weight: 700; color: #1e2939; }
.boot-sub   { font-size: .9rem; color: #6b7280; }
.boot-spinner {
  width: 28px; height: 28px;
  border: 3px solid #e5e9ef; border-top-color: #1a56db;
  border-radius: 50%; animation: spin .7s linear infinite; display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-err { color: #b91c1c; font-size: .85rem; max-width: 360px; text-align: center; }
.boot-btn {
  padding: 10px 28px; background: #1a56db; color: #fff;
  border: none; border-radius: 8px; font-size: .95rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.boot-btn:hover { background: #1648c5; }

/* ─── APP SHELL ─────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ─── HEADER ────────────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #1648c5 0%, #1a56db 100%);
  color: #fff; flex-shrink: 0;
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-icon  { font-size: 26px; }
.header-title { font-size: 17px; font-weight: 700; display: block; }
.header-sub   { font-size: 11px; color: rgba(255,255,255,.65); display: block; }
.header-user  { display: flex; align-items: center; gap: 10px; }
.user-name    { font-size: 13px; color: rgba(255,255,255,.85); }

.gremium-badge {
  background: rgba(255,255,255,.2); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 10px; text-transform: uppercase;
}

/* ─── NAV TABS ──────────────────────────────────────────────────── */
.nav-tabs {
  background: #fff; border-bottom: 1px solid #e5e9ef;
  display: flex; padding: 0 24px; flex-shrink: 0;
}
.nav-tab {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: .875rem; font-weight: 500; color: #6b7280;
  padding: 13px 18px; border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 6px;
  transition: color .15s, border-color .15s;
}
.nav-tab:hover  { color: #1a56db; }
.nav-tab.active { color: #1a56db; border-bottom-color: #1a56db; font-weight: 600; }

.tab-badge {
  background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}

/* ─── MAIN ──────────────────────────────────────────────────────── */
.main { flex: 1; max-width: 1280px; margin: 0 auto; padding: 24px; width: 100%; }

/* ─── VIEWS ─────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

.view-header { margin-bottom: 20px; }
.view-header h2 { font-size: 1.2rem; font-weight: 700; color: #1e2939; margin-bottom: 4px; }
.view-desc { font-size: .875rem; color: #6b7280; max-width: 700px; line-height: 1.5; }

.view-header-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px; gap: 12px;
}
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ─── BUTTONS ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; cursor: pointer; border-radius: 7px;
  font-family: inherit; font-weight: 600; font-size: .875rem;
  padding: 8px 16px; transition: opacity .15s, background .15s;
  text-decoration: none;
}
.btn:hover    { opacity: .88; }
.btn-primary  { background: #1a56db; color: #fff; }
.btn-success  { background: #16a34a; color: #fff; }
.btn-danger   { background: #dc2626; color: #fff; }
.btn-outline  { background: #fff; color: #1a56db; border: 1.5px solid #1a56db; }
.btn-ghost    { background: rgba(255,255,255,.15); color: #fff; }
.btn-neutral  { background: #f3f4f6; color: #374151; border: 1px solid #e5e9ef; }
.btn-sm       { padding: 5px 12px; font-size: .8rem; }
.btn-lg       { padding: 12px 28px; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── FORM ──────────────────────────────────────────────────────── */
.form-card {
  background: #fff; border-radius: 12px;
  border: 1px solid #e5e9ef; padding: 28px 32px;
  max-width: 760px;
}
.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: #1a56db; margin-bottom: 16px;
  padding-bottom: 8px; border-bottom: 1px solid #e5e9ef;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  display: block; font-size: .8rem; font-weight: 600; color: #374151;
  margin-bottom: 4px;
}
.form-label .req { color: #dc2626; margin-left: 2px; }
.form-hint { font-size: .75rem; color: #9ca3af; margin-top: 3px; line-height: 1.4; }
.form-control {
  width: 100%; padding: 7px 10px; border: 1.5px solid #e5e9ef;
  border-radius: 7px; font-family: inherit; font-size: .875rem; color: #1e2939;
  background: #fff; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: #1a56db; }
.form-control.invalid { border-color: #ef4444; }
textarea.form-control { resize: vertical; min-height: 76px; }
.form-footer { margin-top: 8px; padding-top: 20px; border-top: 1px solid #f3f4f6; }

.success-banner {
  background: #f0fdf4; border: 1.5px solid #bbf7d0;
  border-radius: 10px; padding: 14px 18px;
  color: #15803d; font-size: .875rem; font-weight: 500;
  margin-bottom: 20px;
}

/* ─── FILTER ────────────────────────────────────────────────────── */
.filter-select {
  padding: 6px 26px 6px 10px; border: 1.5px solid #e5e9ef;
  border-radius: 7px; font-family: inherit; font-size: .8rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 8px center;
  -webkit-appearance: none; cursor: pointer; color: #374151;
}
.filter-select:focus { outline: none; border-color: #1a56db; }

/* ─── CARDS ─────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.item-card {
  background: #fff; border-radius: 11px;
  border: 1.5px solid #e5e9ef; padding: 16px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.item-card:hover {
  border-color: #1a56db;
  box-shadow: 0 2px 12px rgba(26,86,219,.08);
}
.card-top  { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.card-title { font-size: .875rem; font-weight: 600; color: #1e2939; line-height: 1.35; }
.card-meta  { font-size: .75rem; color: #9ca3af; margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.card-tags  { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ─── BADGES ────────────────────────────────────────────────────── */
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap; flex-shrink: 0;
}
.s-eingereicht { background: #eff6ff; color: #1d4ed8; }
.s-in-pruefung { background: #fffbeb; color: #b45309; }
.s-genehmigt   { background: #f0fdf4; color: #15803d; }
.s-abgelehnt   { background: #fef2f2; color: #dc2626; }
.s-rueckfrage  { background: #faf5ff; color: #7e22ce; }

.badge-risk {
  display: inline-block; font-size: .75rem; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.r-gering   { background: #f0fdf4; color: #15803d; }
.r-normal   { background: #eff6ff; color: #1d4ed8; }
.r-hoch     { background: #fff7ed; color: #c2410c; }
.r-verboten { background: #fef2f2; color: #dc2626; }

.badge-type {
  display: inline-block; font-size: .75rem; font-weight: 500;
  padding: 2px 8px; border-radius: 20px;
  background: #eff3ff; color: #1a56db;
}

/* ─── LOADING / EMPTY ───────────────────────────────────────────── */
.loading-state {
  text-align: center; color: #9ca3af; padding: 48px 24px; font-size: .875rem;
}
.empty-state {
  text-align: center; color: #9ca3af; padding: 48px 24px;
  font-size: .875rem; background: #fff; border-radius: 12px;
  border: 1.5px dashed #e5e9ef;
}

/* ─── SIDE PANEL ────────────────────────────────────────────────── */
.panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 200;
}
.side-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 520px; max-width: 95vw;
  background: #fff; z-index: 201;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.1);
}
.panel-header {
  padding: 16px 20px; border-bottom: 1px solid #e5e9ef;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; background: #f0f4ff;
}
.panel-title { font-size: .95rem; font-weight: 700; color: #1e2939; }
.panel-close {
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: #6b7280; padding: 2px 6px; border-radius: 4px;
}
.panel-close:hover { background: #e5e9ef; color: #1e2939; }
.panel-body { flex: 1; overflow-y: auto; padding: 20px; }

.panel-section { margin-bottom: 22px; }
.panel-section-title {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: #1a56db; margin-bottom: 10px;
}
.panel-field { margin-bottom: 10px; }
.panel-field-label { font-size: .75rem; color: #9ca3af; margin-bottom: 2px; }
.panel-field-value { font-size: .875rem; color: #1e2939; line-height: 1.5; }
.panel-field-value.pre { white-space: pre-wrap; }

.panel-gremium {
  background: #f0f4ff; border: 1.5px solid #c7d7f9;
  border-radius: 10px; padding: 16px; margin-top: 16px;
}
.panel-gremium-title {
  font-size: .8rem; font-weight: 700; color: #1a56db;
  margin-bottom: 14px; text-transform: uppercase; letter-spacing: .5px;
}
.panel-gremium .form-group { margin-bottom: 10px; }
.panel-gremium .form-label { font-size: .8rem; }
.panel-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ─── MODAL ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal-header {
  padding: 16px 22px; border-bottom: 1px solid #e5e9ef;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-title { font-size: .95rem; font-weight: 700; color: #1e2939; }
.modal-close {
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: #6b7280; padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: #f3f4f6; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px; padding-top: 14px; border-top: 1px solid #f3f4f6;
}

/* ─── LIZENZEN TABLE ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 11px; border: 1px solid #e5e9ef; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: #6b7280;
  background: #fafafa; border-bottom: 1px solid #e5e9ef;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f3f4f6; cursor: pointer; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f0f4ff; }
tbody td { padding: 10px 14px; color: #1e2939; vertical-align: middle; }

.expiry-warn  { color: #c2410c; font-weight: 600; }
.expiry-alert { color: #dc2626; font-weight: 700; }
.expiry-ok    { color: #6b7280; }

.util-bar-wrap { background: #f3f4f6; border-radius: 20px; height: 6px; width: 80px; overflow: hidden; display: inline-block; vertical-align: middle; }
.util-bar { height: 100%; border-radius: 20px; }
.util-ok   { background: #22c55e; }
.util-warn { background: #f59e0b; }
.util-full { background: #ef4444; }

/* ─── STATS ROW ─────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card {
  background: #fff; border: 1px solid #e5e9ef; border-radius: 10px;
  padding: 14px 18px; flex: 1; min-width: 120px;
}
.stat-value { font-size: 1.5rem; font-weight: 800; color: #1e2939; }
.stat-label { font-size: .75rem; color: #9ca3af; margin-top: 2px; }
.stat-card.accent { border-left: 3px solid #1a56db; }
.stat-card.green  { border-left: 3px solid #16a34a; }
.stat-card.orange { border-left: 3px solid #d97706; }
.stat-card.red    { border-left: 3px solid #dc2626; }


/* ─── PEOPLE AUTOCOMPLETE ─────────────────────────────────────── */
.people-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
  color: #1e2939;
  transition: background .1s;
}
.people-item:last-child { border-bottom: none; }
.people-item-hover, .people-item:hover { background: #f0f4ff; }

/* ─── TOAST ─────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
}
.toast {
  background: #1e2939; color: #fff;
  padding: 12px 18px; border-radius: 9px;
  font-size: .875rem; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  max-width: 360px; line-height: 1.4;
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: #15803d; }
.toast.toast-error   { background: #dc2626; }
.toast.toast-info    { background: #1a56db; }

/* ─── FILTER SEARCH ──────────────────────────────────────────────── */
.filter-search {
  padding: 6px 10px; border: 1.5px solid #e5e9ef;
  border-radius: 7px; font-family: inherit; font-size: .8rem;
  color: #374151; background: #fff; width: 180px;
  transition: border-color .15s;
}
.filter-search:focus { outline: none; border-color: #1a56db; }

/* ─── SETTINGS VIEW ──────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 768px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-card {
  background: #fff; border: 1.5px solid #e5e9ef;
  border-radius: 12px; padding: 22px 24px;
}
.settings-card-title {
  font-size: .925rem; font-weight: 700; color: #1e2939;
  margin-bottom: 10px;
}
.settings-check {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 12px; cursor: pointer; font-size: .875rem; color: #374151;
}
.settings-check input[type="checkbox"] {
  margin-top: 2px; width: 15px; height: 15px; flex-shrink: 0;
  accent-color: #1a56db; cursor: pointer;
}

/* ─── RICHTLINIE HINT BANNER ────────────────────────────────────── */
.richtlinie-hint {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 10px; margin-bottom: 16px;
}
.richtlinie-hint-left {
  display: flex; align-items: center; gap: 12px;
}
.richtlinie-hint-icon { font-size: 1.3rem; flex-shrink: 0; }
.richtlinie-hint-left div { display: flex; flex-direction: column; gap: 2px; }
.richtlinie-hint-left strong { font-size: .85rem; color: #1d4ed8; }
.richtlinie-hint-left span  { font-size: .78rem; color: #3b82f6; }

/* ─── MODAL WIDE (für Richtlinie) ──────────────────────────────── */
.modal-wide { max-width: 820px !important; width: 95vw !important; }

/* ─── RICHTLINIE DOKUMENT ───────────────────────────────────────── */
.rdoc { font-size: .85rem; line-height: 1.65; color: #1e2939; }
.rdoc h3 {
  font-size: .95rem; font-weight: 700; color: #1648c5;
  margin: 20px 0 8px; padding-bottom: 5px;
  border-bottom: 2px solid #e0e7ff;
}
.rdoc h4 {
  font-size: .87rem; font-weight: 600; color: #1e2939;
  margin: 14px 0 5px;
}
.rdoc p  { margin-bottom: 8px; }
.rdoc ul { margin: 6px 0 8px 18px; }
.rdoc ul li { margin-bottom: 4px; }
.rdoc-meta-table {
  background: #f9fafb; border: 1px solid #e5e9ef;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 18px;
}
.rdoc-meta-table table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.rdoc-meta-table td { padding: 3px 10px 3px 0; vertical-align: top; color: #6b7280; }
.rdoc-meta-table td:nth-child(odd) { font-weight: 500; color: #374151; white-space: nowrap; }
.rdoc-badge {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  font-size: .75rem; font-weight: 600;
}
.rdoc-gering  { background: #dcfce7; color: #166534; }
.rdoc-normal  { background: #fef3c7; color: #92400e; }
.rdoc-hoch    { background: #fee2e2; color: #991b1b; }
.rdoc-verboten{ background: #1e2939; color: #fff; }
.rdoc-highlight {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  background: #eff6ff; color: #1d4ed8; border-radius: 99px;
  font-size: .72rem; font-weight: 500;
}
.rdoc-warning {
  background: #fef2f2; border: 1px solid #fca5a5;
  border-radius: 7px; padding: 8px 12px; color: #991b1b;
  font-size: .83rem; margin-bottom: 8px;
}
.rdoc-anlage {
  width: 100%; border-collapse: collapse; font-size: .8rem; margin-top: 8px;
}
.rdoc-anlage th {
  background: #1648c5; color: #fff; padding: 7px 10px; text-align: left;
}
.rdoc-anlage td {
  padding: 6px 10px; border-bottom: 1px solid #e5e9ef; vertical-align: top;
}
.rdoc-anlage tr:nth-child(even) td { background: #f9fafb; }
.rdoc-anlage td:first-child { font-weight: 500; white-space: nowrap; color: #1e2939; width: 40%; }

/* ─── ANHÄNGE ───────────────────────────────────────────────────── */
.att-list {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-height: 24px;
}
.att-item {
  display: flex; align-items: center; gap: 8px;
  background: #f9fafb; border: 1px solid #e5e9ef;
  border-radius: 7px; padding: 7px 10px;
}
.att-name {
  flex: 1; font-size: .83rem; color: #1a56db; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att-name:hover { text-decoration: underline; }
.att-del {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: #ef4444; font-size: .85rem; padding: 2px 6px; border-radius: 5px;
  line-height: 1; transition: background .15s;
}
.att-del:hover { background: #fef2f2; }
.att-drop {
  border: 2px dashed #d1d5db; border-radius: 10px;
  padding: 18px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: #6b7280; font-size: .82rem; transition: border-color .2s, background .2s;
  cursor: default;
}
.att-drop.drag-over {
  border-color: #1a56db; background: #eff6ff; color: #1d4ed8;
}
.att-drop.att-uploading {
  border-color: #fbbf24; background: #fffbeb; color: #92400e; pointer-events: none;
}
.att-drop-icon { font-size: 1.4rem; }
.att-drop-btn {
  display: inline-block; padding: 4px 12px;
  background: #1a56db; color: #fff; border-radius: 6px;
  font-size: .78rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.att-drop-btn:hover { background: #1648c5; }
