:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --border: #2a2a30;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --user-bubble: #3b3b42;
  --assistant-bubble: #27272a;
  --error: #f87171;
  --radius: 10px;
  --font-sans: "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.token-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.token-counter.hidden {
  display: none;
}

.token-label {
  font-weight: 600;
  color: var(--text-muted);
}

.token-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
}

.token-chip b {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 900px) {
  .token-counter .token-label { display: none; }
  .token-chip { font-size: 0.6875rem; }
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.controls select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.875rem;
  min-width: 140px;
}

.btn {
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

a.btn {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-loading {
  position: relative;
}

.btn-loading::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.5em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: -0.2em;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.session-switcher {
  position: relative;
}

.admin-session-switcher .admin-sessions-btn {
  border-style: dashed;
}

.sessions-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin: 0.25rem 0 0;
  padding: 0.35rem 0;
  min-width: 14rem;
  max-width: 22rem;
  max-height: 18rem;
  overflow-y: auto;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.sessions-dropdown.hidden {
  display: none !important;
}

.sessions-dropdown li {
  margin: 0;
}

.sessions-dropdown button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.85rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
}

.sessions-dropdown button:hover {
  background: var(--border);
}

.sessions-dropdown .session-label {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sessions-dropdown .session-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.sessions-dropdown .session-empty {
  padding: 0.6rem 0.85rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.main.split-view {
  flex-direction: row;
  max-width: none;
  margin: 0;
  height: 100%;
}

.main .left-panel {
  flex: 0 0 50%;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 1rem;
  border-right: 1px solid var(--border);
}

.main .right-panel {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 1.25rem;
  padding: 0.5rem 0;
}

.step-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.step-dot.active {
  border-color: var(--accent);
  color: var(--accent);
}

.step-dot.current {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.step-dot.locked {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.step-line {
  flex: 1;
  max-width: 2rem;
  height: 2px;
  background: var(--border);
}

.wizard-section,
.report-form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.report-form-section.collapsed .report-form {
  display: none;
}

.report-form-section.collapsed .form-title {
  margin-bottom: 0;
}

.result-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  max-height: 24rem;
  overflow-y: auto;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.result-preview h1,
.result-preview h2,
.result-preview h3 {
  margin-top: 0.75em;
  margin-bottom: 0.35em;
}

.result-preview pre,
.result-preview code {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

.result-preview-editable {
  outline: none;
}

.result-preview-editable:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.result-preview-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}

.autosave-status {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  min-height: 1.25em;
}

.autosave-status.saving {
  color: var(--accent);
}

.autosave-status.saved {
  color: var(--success, #22c55e);
}

.hidden {
  display: none !important;
}

.wizard-section .form-description {
  margin: 0 0 1rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

.form-hint-block {
  display: block;
  margin: 0 0 0.75rem 0;
  padding: 0.4rem 0.6rem;
  background: var(--bg-secondary, #f5f5f5);
  border-left: 3px solid var(--accent, #888);
  border-radius: 2px;
}

.info-box {
  margin: 0 0 1rem 0;
  padding: 0.6rem 0.85rem;
  background: #eef4ff;
  border-left: 3px solid #6b9fff;
  border-radius: 2px;
  font-size: 0.875rem;
  color: #333;
}

.questionnaire-section {
  margin-bottom: 1.25rem;
}

.questionnaire-section-title {
  margin: 0 0 0.5rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.questionnaire-field,
.questionnaire-textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
}

.questionnaire-field:focus,
.questionnaire-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-title {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.report-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-row label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-row input,
.form-row select,
.form-row textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-family: inherit;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row input::placeholder,
.form-row textarea::placeholder {
  color: var(--text-muted);
}

.form-row-full {
  width: 100%;
}

.form-row-inline {
  max-width: 12rem;
}

.form-row-inline input,
.form-row-inline select {
  width: 100%;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.field-error {
  outline: 2px solid #ef4444;
  outline-offset: 2px;
  border-radius: 4px;
}

.field-error-msg {
  font-size: 0.8125rem;
  color: #ef4444;
  margin-top: 0.25rem;
}

.upload-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.upload-area input[type="file"] {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 12rem;
}

.upload-area input[type="file"]::file-selector-button {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
}

.upload-area input[type="file"]::file-selector-button:hover {
  background: var(--border);
}

.upload-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.file-list {
  list-style: none;
  margin: 0.5rem 0 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.file-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.file-list li .file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-list li.file-pending {
  color: var(--text-muted);
}

.file-list li.file-done {
  color: var(--text);
}

.file-list li.file-error {
  color: var(--error);
}

.file-list li .file-status {
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .form-row-inline {
    display: inline-flex;
    max-width: none;
  }
  .form-inline-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 0.85rem;
  }
}

@media (max-width: 1024px) {
  .main.split-view {
    flex-direction: column;
    height: auto;
  }
  .main .left-panel {
    flex: 0 0 auto;
    max-height: 50vh;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main .right-panel {
    flex: 1;
    min-height: 20rem;
    height: auto;
  }
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem;
}

.verbose-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  cursor: pointer;
}

.verbose-toggle input {
  cursor: pointer;
}

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 1rem;
  min-height: 0;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 95%;
}

.msg.user {
  align-self: flex-end;
}

.msg.user .bubble {
  background: var(--user-bubble);
  border: 1px solid var(--border);
}

.msg.assistant {
  align-self: flex-start;
}

.msg.assistant .bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
}

.msg.tool .bubble {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.msg.error .bubble {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

.retry-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--error);
  border-radius: 6px;
  background: transparent;
  color: var(--error);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.retry-btn:hover:not(:disabled) {
  background: var(--error);
  color: #fff;
}

.retry-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.msg.thinking .bubble {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}

.msg.system .bubble {
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.msg.debug .bubble {
  background: var(--surface);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.msg.tool-result .bubble {
  max-height: 24rem;
  overflow-y: auto;
}

.tool-result-details summary,
.tool-args-details summary,
.debug-event-details summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--accent);
}

.tool-result-content,
.debug-event-content {
  margin: 0.5em 0 0;
  padding: 0.75rem;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 20rem;
  overflow-y: auto;
}

.msg.typing-indicator .bubble {
  padding: 0.85rem 1.2rem;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.typing-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s ease-in-out infinite both;
}

.typing-dots .dot:nth-child(1) { animation-delay: 0s; }
.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.1); opacity: 1; }
}

.bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble h1, .bubble h2, .bubble h3 {
  margin-top: 0.5em;
  margin-bottom: 0.25em;
}

.bubble code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

.bubble pre {
  margin: 0.5em 0;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.3);
}

.bubble pre code {
  background: none;
  padding: 0;
}

.msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
}

.input-row {
  display: flex;
  flex-direction: column;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  gap: 0;
}

.input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.4rem 0;
}

.input-wrapper textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  resize: none;
  transition: height 0.1s ease;
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.input-wrapper textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.input-wrapper .btn-primary {
  flex-shrink: 0;
  align-self: stretch;
}

/* Chat attachment bar */
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0 0.2rem;
}

.chat-attachments.hidden {
  display: none;
}

.chat-attachment-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem 0.4rem 0.2rem 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
}

.chat-attachment-chip.uploading {
  opacity: 0.6;
}

.chat-attachment-chip.error {
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

.chat-attachment-chip img.chip-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.chip-icon {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}

.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.chip-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 0.85rem;
  opacity: 0.7;
  margin-left: 0.1rem;
}

.chip-remove:hover {
  opacity: 1;
}

.chip-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent, #7c3aed);
  border-radius: 50%;
  animation: chip-spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes chip-spin {
  to { transform: rotate(360deg); }
}

.btn-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  transition: color 0.15s, border-color 0.15s;
  align-self: flex-end;
  margin-bottom: 0.15rem;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--border);
}

/* Drag-over highlight on chat section */
.chat-section.drag-over {
  outline: 2px dashed var(--accent, #7c3aed);
  outline-offset: -4px;
  border-radius: 8px;
}

/* Attachment previews inside chat bubbles */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.msg-attachment-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: opacity 0.15s;
}

.msg-attachment-thumb:hover {
  opacity: 0.85;
}

.msg-attachment-file {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.status.connecting {
  color: #fbbf24;
}

.status.error {
  color: var(--error);
}

/* ─── INQA Mode ──────────────────────────────────────────────────────────── */

.mode-selector {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  flex-direction: column;
}

.mode-selector h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.mode-cards {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mode-card-wrapper {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mode-card {
  width: 100%;
  padding: 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.mode-card:hover {
  border-color: var(--accent);
  background: #1e1e24;
}

.mode-card.active {
  border-color: var(--accent);
  background: #1e1e28;
}

.mode-card .mode-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.mode-card .mode-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Gestaltungsfelder checkbox group */
.gestaltungsfelder-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.gestaltungsfeld-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  line-height: 1.35;
}

.gestaltungsfeld-item input[type="checkbox"] {
  margin-top: 0.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* INQA tag input for "Beteiligte Rollen" */
.tags-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 2.5rem;
  align-items: center;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.tag-chip button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
}

.tag-chip button:hover { opacity: 1; }

.tags-input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  flex: 1;
  min-width: 120px;
  font-family: inherit;
}

/* ─── QM Handbuch: collapsible form sections ─────────────────────────────── */

.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.form-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.form-section-header:hover {
  background: #1e1e24;
}

.form-section-toggle {
  font-size: 0.75rem;
  opacity: 0.6;
  flex-shrink: 0;
}

.form-section-body {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

.form-section-body.hidden {
  display: none;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ─── QM Handbuch: repeatable person/reference blocks ───────────────────── */

.repeatable-block {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: #1a1a1e;
}

.repeatable-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.repeatable-block-header strong {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.btn-remove-block {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.125rem;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}

.btn-remove-block:hover {
  color: var(--error);
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
}

.form-hint-block {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0.75rem;
  line-height: 1.4;
}


/* Session mode badges in dropdown */
.session-mode-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.session-mode-badge.mode-bafa        { background: #2563eb; color: #fff; }
.session-mode-badge.mode-inqa        { background: #059669; color: #fff; }
.session-mode-badge.mode-qm_handbuch { background: #d97706; color: #fff; }
.session-server-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: #6b7280;
  color: #fff;
  margin-left: 4px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Real-time field update animations ─────────────────────────────────── */

@keyframes field-flash {
  0%   { background-color: rgba(124, 58, 237, 0.25); }
  100% { background-color: transparent; }
}

.field-updated {
  animation: field-flash 1.5s ease-out;
}

/* ─── Import button (on mode cards) ─────────────────────────────────────── */

.import-btn {
  width: 100%;
  font-size: 0.8125rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-align: center;
  font-family: inherit;
}

.import-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124, 58, 237, 0.07);
}

/* ─── Import View (inline in left panel) ─────────────────────────────────── */

#import-view {
  display: flex;
  flex-direction: column;
}

.import-view-content {
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.import-view-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.import-view-content > p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.import-view-content label {
  display: block;
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
}

.import-view-content textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg, #13131a);
  border: 1px solid var(--border, #2e2e3a);
  border-radius: 8px;
  color: var(--text, #e0e0e8);
  padding: 0.75rem;
  font-size: 0.875rem;
  resize: vertical;
  font-family: inherit;
  min-height: 120px;
}

.import-view-content textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.import-dropzone {
  border: 2px dashed var(--border, #2e2e3a);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.import-dropzone:hover,
.import-dropzone.dragover {
  border-color: var(--accent, #7c3aed);
  background: rgba(124, 58, 237, 0.07);
}

.import-dropzone p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.import-dropzone-hint {
  font-size: 0.75rem !important;
  margin-top: 0.25rem !important;
}

.import-file-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.import-file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  padding: 0.4rem 0.65rem;
  background: var(--surface, #1a1a22);
  border: 1px solid var(--border, #2e2e3a);
  border-radius: 6px;
  gap: 0.5rem;
}

.import-file-list .file-name-import {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.import-file-list .file-status-import {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.import-file-list .remove-import-file {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.import-file-list .remove-import-file:hover {
  color: #ef4444;
}

.import-file-list .file-status-import:has(~ .file-retry-btn),
.file-status-import[data-error] {
  color: var(--error);
}

.file-retry-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  padding: 1px 8px;
  font-size: 0.7rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.file-retry-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.import-view-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.import-status {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.4rem;
}

.import-prefill-banner {
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  color: var(--accent, #7c3aed);
  margin-bottom: 1rem;
}

/* ── Login screen ─────────────────────────────────────────────────────────── */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.login-subtitle {
  margin: 0 0 1.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.login-field label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-field input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.login-field input[type="password"]:focus {
  border-color: var(--accent);
}

.login-error {
  font-size: 0.85rem;
  color: var(--error);
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 6px;
  background: rgba(248, 113, 113, 0.08);
}

.login-error.hidden {
  display: none;
}

.login-btn {
  width: 100%;
  justify-content: center;
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
