:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --border: #d5d9e0;
  --accent: #0078d4;
  --accent-dark: #005ea2;
  --text: #1f2328;
  --muted: #6e7781;
  --green: #1a7f37;
  --red: #cf222e;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent-dark); color: #fff;
  padding: 10px 20px; box-shadow: var(--shadow);
}
.brand { color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: #fff; text-decoration: none; opacity: .92; }
.topnav a:hover { opacity: 1; text-decoration: underline; }
.topnav .user { opacity: .85; font-size: 13px; }
.btn-new { background: rgba(255,255,255,.16); padding: 5px 10px; border-radius: 6px; }

.content { max-width: 1200px; margin: 20px auto; padding: 0 20px; }

/* Flash + toast */
.flash { max-width: 1200px; margin: 12px auto 0; padding: 0 20px; }
.flash div { background: #fff3cd; border: 1px solid #ffe69c; padding: 8px 12px; border-radius: 6px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2328; color: #fff; padding: 10px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 100;
}
.toast.show { opacity: .96; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* Auth cards */
.auth-card {
  max-width: 380px; margin: 8vh auto; background: var(--card);
  padding: 28px; border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.auth-card h1 { margin-top: 0; }
.auth-card label { display: block; margin: 14px 0; }
.auth-card input { width: 100%; }

/* Buttons */
.btn {
  display: inline-block; background: #eef1f5; border: 1px solid var(--border);
  color: var(--text); padding: 7px 14px; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.btn:hover { background: #e2e6ec; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: #fdecec; }
.btn.small { padding: 4px 10px; font-size: 13px; }

/* Inputs */
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; }

/* Fallliste */
.page-head h1 { margin: 0 0 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type=search] { min-width: 260px; flex: 1; }
.counter { color: var(--muted); margin: 6px 0 14px; }

.grid { width: 100%; border-collapse: collapse; background: var(--card); box-shadow: var(--shadow); border-radius: 8px; overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.grid th { background: #f6f8fa; font-size: 13px; cursor: pointer; user-select: none; }
.grid tbody tr:hover { background: #f6f9fc; }
.grid tr.closed td { color: var(--muted); }
.grid tr.open td:first-child a { color: var(--green); font-weight: 600; }
.grid .empty { text-align: center; color: var(--muted); padding: 24px; }
.grid td a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* Editor */
.editor-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.editor-head h1 { margin: 0; }
.editor-actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  background: none; border: none; padding: 10px 16px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tabpane { display: none; }
.tabpane.active { display: block; }

fieldset {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px 18px; margin: 0 0 16px; box-shadow: var(--shadow);
}
legend { font-weight: 700; padding: 0 6px; color: var(--accent-dark); }

.row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.row label { flex: 1; min-width: 180px; }
label { display: block; font-size: 13px; color: #444; }
label input, label select, label textarea, .row input, .row select { width: 100%; margin-top: 3px; }
label.full { display: block; margin-bottom: 10px; }
.wide { min-width: 320px; }
.short { max-width: 70px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-col h3 { margin: 0 0 8px; color: var(--accent-dark); }
.two-col label { margin-bottom: 8px; }

.btnbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.muted { color: var(--muted); font-size: 13px; }

/* Fragebogen */
.fb-head { display: flex; justify-content: space-between; align-items: center; }
.fb-q { border-bottom: 1px dashed var(--border); padding: 8px 0 12px; }
.fb-frage { margin: 4px 0; }
.fb-relevanz { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.fb-relevanz input { width: 60px; margin: 0; }
.progress { display: flex; align-items: center; gap: 8px; min-width: 220px; }
.progress-bar { height: 12px; background: var(--green); border-radius: 6px; width: 0; transition: width .2s; }
.progress { position: relative; }
.progress::before { content: ""; position: absolute; left: 0; right: 40px; height: 12px; background: #e2e6ec; border-radius: 6px; z-index: 0; }
.progress-bar { position: relative; z-index: 1; }

/* Bericht */
.bericht-text { width: 100%; font-family: "Consolas", monospace; font-size: 12.5px; line-height: 1.4; white-space: pre; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; border-radius: 10px; padding: 22px; width: 480px; max-width: 92vw; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h3 { margin-top: 0; }
.modal label { margin: 10px 0; }
.modal input, .modal textarea, .modal select { width: 100%; margin-top: 3px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.icon-btn { background: none; border: none; cursor: pointer; font-size: 15px; padding: 2px 6px; }
.icon-btn:hover { background: #eef1f5; border-radius: 4px; }

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
  .row label { min-width: 140px; }
}
