* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #334155;
  line-height: 1.6;
}

nav {
  background: #1e293b;
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

nav .brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: #3b82f6;
  text-decoration: none;
}

nav a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

nav a:hover {
  color: #fff;
}

nav a.active {
  color: #fff;
  border-bottom-color: #3b82f6;
}

.container {
  width: 95%;
  margin: 2rem auto;
  padding: 0;
}

h1 {
  margin-bottom: 1.5rem;
  color: #1e293b;
}

h2 {
  margin: 1.5rem 0 1rem;
  color: #1e293b;
}

h3 {
  margin: 1rem 0 0.5rem;
  color: #475569;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}

.card h3 {
  margin-top: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.85rem;
  color: #64748b;
  text-transform: uppercase;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.4rem;
}

th.sortable:hover {
  color: #2563eb;
}

th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 0.4rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

th.sortable.asc::after {
  content: '▲';
  color: #2563eb;
}

th.sortable.desc::after {
  content: '▼';
  color: #2563eb;
}

tr:hover {
  background: #f1f5f9;
}

a {
  color: #2563eb;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.5;
  text-decoration: none;
  color: #fff;
  vertical-align: middle;
  white-space: nowrap;
  box-sizing: border-box;
  margin: 0;
}

.btn-primary {
  background: #2563eb;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-success {
  background: #16a34a;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-secondary {
  background: #6c757d;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-disabled {
  background: #ccc;
  color: #888;
  cursor: default;
  pointer-events: none;
}

button.btn:disabled,
button:disabled.btn-primary,
button:disabled.btn-success,
button:disabled.btn-danger,
button:disabled.btn-secondary {
  opacity: 0.4;
  cursor: not-allowed;
  filter: saturate(0.2);
}

button.btn:disabled:hover,
button:disabled.btn-primary:hover,
button:disabled.btn-success:hover,
button:disabled.btn-danger:hover,
button:disabled.btn-secondary:hover {
  background: inherit;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

/* ── Filter Chips ── */

.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.filter-bar .filter-label {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
  margin-right: 0.25rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  border: 1.5px solid #cbd5e1;
  background: transparent;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  text-decoration: none;
}

.filter-chip.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.filter-chip.active:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

button.filter-chip {
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  line-height: 1.5;
}

.table-filter-input {
  padding: 0.35rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 260px;
  max-width: 100%;
}
.table-filter-input:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148,163,184,0.2);
}

.filter-bar::before {
  content: '';
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  align-self: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M1.5 1.5A.5.5 0 0 1 2 1h12a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.128.334L10 8.692V13.5a.5.5 0 0 1-.342.474l-3 1A.5.5 0 0 1 6 14.5V8.692L1.628 3.834A.5.5 0 0 1 1.5 3.5v-2z'%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.55;
}

/* ── Badges ── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pass {
  background: #dcfce7;
  color: #166534;
}

.badge-fail {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-offen {
  background: #fef3c7;
  color: #92400e;
}

.badge-batch {
  background: #ede9fe;
  color: #5b21b6;
  font-size: 0.7rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  text-decoration: none;
}

.badge-batch:hover {
  background: #ddd6fe;
  text-decoration: none;
}

.batch-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.step-card.pass {
  border-left: 4px solid #16a34a;
}

.step-card.fail {
  border-left: 4px solid #dc2626;
}

.step-card.bypass {
  border-left: 4px solid #64748b;
}

.step-card.offen {
  border-left: 4px solid #f59e0b;
}

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.step-label {
  font-weight: 600;
  font-size: 0.9rem;
}

#link-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1e293b;
  color: #f1f5f9;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  pointer-events: none;
  display: none;
  max-width: 400px;
  word-break: break-all;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  line-height: 1.5;
}
#link-tooltip-status { font-weight: 600; margin-bottom: 0.2rem; }
#link-tooltip-url { color: #94a3b8; font-size: 0.75rem; }
#link-tooltip-error { color: #fca5a5; font-size: 0.75rem; margin-top: 0.2rem; }

.response-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.8rem;
  margin: 0.5rem 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 0.85rem;
  max-height: 300px;
  overflow-y: auto;
}

.expected-box {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 4px;
  padding: 0.5rem 0.8rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: #475569;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-inline {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-inline .form-group {
  flex: 1;
}

.note-select {
  width: auto;
  min-width: 80px;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.flash-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.meta {
  color: #64748b;
  font-size: 0.85rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.story-step {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.8rem;
  background: #f8fafc;
}

.step-toolbar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.step-toolbar .step-number {
  font-weight: 600;
  font-size: 0.95rem;
  margin-right: auto;
}

.step-toolbar .btn {
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
}

.report-content table {
  margin: 1rem 0;
}

.report-content h2 {
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 0.3rem;
}

.report-content h3 {
  color: #1e293b;
}

.report-content hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 2rem 0;
}

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.3rem;
}

.progress-bar .fill {
  height: 100%;
  background: #16a34a;
  transition: width 0.3s;
}

.run-status {
  padding: 2rem;
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.score-grid {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: center;
}

.score-item {
  text-align: center;
}

.score-item .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e293b;
}

.score-item .label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #64748b;
}

.cli-banner {
  padding: 0.6rem 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.cli-banner a {
  color: inherit;
  text-decoration: underline;
  margin-left: 0.3rem;
}

.cli-banner-running {
  background: #dbeafe;
  color: #1e40af;
  border-bottom: 2px solid #bfdbfe;
}

.cli-banner-done {
  background: #dcfce7;
  color: #166534;
  border-bottom: 2px solid #bbf7d0;
}

.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 1.5rem;
}

nav .nav-spacer {
  flex: 1;
}

nav .nav-logout {
  color: #94a3b8;
  font-size: 0.85rem;
}

nav .nav-version {
  color: #475569;
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ── Info-Icon (Tooltip) ── */

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 0.4rem;
  cursor: help;
  vertical-align: middle;
  line-height: 1;
}

/* ── Kontext-Gruppen (story.ejs) ── */

.story-step.context-start {
  border-left: 3px solid #2563eb;
  margin-bottom: 0.2rem;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.story-step.context-follow {
  margin-left: 1.5rem;
  margin-top: 0;
  border-left: 3px solid #2563eb;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-bottom: 0.2rem;
}

.story-step.context-follow:not(.context-start) {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  margin-bottom: 0.8rem;
}

.story-step.context-follow.context-start {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* ── Kontext-Gruppen (run.ejs) ── */

.step-card.context-start {
  box-shadow: -6px 0 0 0 #2563eb;
  margin-bottom: 0.2rem;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.step-card.context-follow {
  margin-left: 1.5rem;
  margin-top: 0;
  box-shadow: -6px 0 0 0 #2563eb;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-bottom: 0.2rem;
}

.step-card.context-follow:not(.context-start) {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  margin-bottom: 1rem;
}

.step-card.context-follow.context-start {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* ── Noten-Farbskala ── */

.note-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  min-width: 2.5rem;
}

.note-0 { background: #fee2e2; color: #991b1b; }
.note-1 { background: #ffedd5; color: #9a3412; }
.note-2 { background: #fef9c3; color: #854d0e; }
.note-3 { background: #dcfce7; color: #166534; }
.note-4 { background: #bbf7d0; color: #14532d; }

/* ── Bot-Reset Step (Editor) ── */

.story-step.bot-reset-step {
  background: #f1f5f9;
  border: 1px dashed #94a3b8;
  padding: 0.5rem 1rem;
}

/* ── Bot-Reset Step (Ergebnis-Ansicht) ── */

.step-card.bot-reset {
  border-left: 4px solid #94a3b8;
  padding: 0.5rem 1rem;
  background: #f8fafc;
}

/* ── Report Akkordeon Indikator ── */

details.card > summary {
  list-style: none;
}
details.card > summary::-webkit-details-marker {
  display: none;
}
details.card > summary::before {
  content: '▶';
  display: inline-block;
  font-size: 0.7rem;
  margin-right: 0.5rem;
  transition: transform 0.2s;
  color: #64748b;
}
details[open].card > summary::before {
  transform: rotate(90deg);
}

/* ── FAQ Checkbox ── */

.faq-checkbox {
  width: 1.2rem;
  height: 1.2rem;
  cursor: pointer;
  accent-color: #2563eb;
}

/* ── Mini-Run-Badges (Report Summary) ── */

.run-mini {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}

/* ── Story editor: test panel ── */

.test-status {
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}
.test-status-running { background: #dbeafe; color: #1e40af; }
.test-status-done    { background: #dcfce7; color: #166534; }
.test-status-error   { background: #fee2e2; color: #991b1b; }

/* ── Inline result slots (story editor) ── */

.step-result-slot {
  border-radius: 0 0 6px 6px;
  padding: 0.6rem 1rem;
  margin-top: -0.8rem;
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
}

.step-result-waiting {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-top: none;
  color: #3b82f6;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-result-waiting-spinner {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid #bfdbfe;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1.4s linear infinite;
  flex-shrink: 0;
  opacity: 0.7;
}

.step-result-running {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-top: none;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-result-spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid #93c5fd;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.step-result-filled {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
}

.test-result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.test-prev-status {
  font-size: 0.85rem;
  color: #64748b;
}

.test-prev-stale {
  color: #92400e;
}

.test-result-input {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 0.4rem;
}

.test-result-response {
  display: block;
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.5;
  white-space: pre-wrap;
  min-height: 6rem;
  max-height: 20rem;
  overflow-y: auto;
  resize: vertical;
  margin-bottom: 0.4rem;
}

.test-result-detail {
  font-size: 0.8rem;
  color: #dc2626;
  margin-bottom: 0.4rem;
}

/* ── Nav: laufender Batch-Indikator ── */

.nav-run-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 3px;
  vertical-align: middle;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ── Batch: laufender Lauf Banner ── */

.batch-running-banner {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

/* ── Report: Batch-Tabelle ── */

.batch-row:hover {
  background: #f0f9ff;
}

.batch-row.batch-selected {
  background: #eff6ff;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.batch-row.batch-filtered-out {
  opacity: 0.3;
  cursor: default;
}

#chart-container svg .bar {
  cursor: pointer;
  transition: opacity 0.15s;
}

#chart-container svg .bar:hover {
  opacity: 0.8;
}
