:root {
  --bg-page: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --border: #e4e4e7;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #9a9aa2;
  --bg-accent-muted: #f2f5ff;
  --accent: #3b5bfd;
  --bg-warning: #fef3c7;
  --text-warning: #92620a;
  --bg-success: #dcfce7;
  --text-success: #15803d;
  --bg-danger: #fee2e2;
  --text-danger: #b91c1c;
  --bg-info: #e0f2fe;
  --text-info: #075985;
  --bg-neutral: #f1f1f3;
  --text-neutral: #52525b;
  --radius: 6px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  margin: 0;
  padding: 0 2rem 3rem;
  color: var(--text-primary);
  background: var(--bg-page);
}

header.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 1.5rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-link:hover {
  opacity: 0.75;
}

header.top img.brand-logo {
  height: 24px;
  width: auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

header.top h1 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
}

header.top nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

header.top a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}

header.top a:hover {
  color: var(--text-primary);
}

/* Shows the language you'd switch TO, not the current one — a single
   link/toggle instead of two side-by-side DE/EN links. */
header.top a.lang-switch {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

header.top a.lang-switch:hover {
  color: var(--text-primary);
  background: var(--bg-neutral);
}

.card {
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-head .title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.card h3 {
  font-size: 0.95rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-primary);
}

.card h3:first-child {
  margin-top: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.btn:hover {
  filter: brightness(0.92);
}

.card-head .count {
  font-size: 12px;
  color: var(--text-muted);
}

.tc-list-head, .tc-row {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr 0.7fr 0.9fr 1.1fr 1.4fr;
  gap: 8px;
  align-items: center;
}

/* Our own `display: grid` above otherwise beats the browser's default
   [hidden] { display: none } rule (same specificity, author stylesheet
   wins) — this is what makes toggling `.hidden` from JS actually work. */
.tc-row[hidden] {
  display: none;
}

.tc-list-head {
  padding: 0 8px 8px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 0.5px solid var(--border);
}

.tc-row {
  padding: 10px 8px;
  border-bottom: 0.5px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
}

.tc-row:last-child {
  border-bottom: none;
}

.tc-row:hover {
  background: var(--bg-accent-muted);
}

.tc-title {
  font-size: 13px;
  color: var(--text-primary);
  text-decoration: none;
}

.tc-title:hover {
  text-decoration: underline;
}

.tc-cell {
  font-size: 13px;
  color: var(--text-secondary);
}

.tc-action {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tc-action svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.tc-action-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
}

.tc-action-link:hover {
  color: var(--text-primary);
}

.inline-assign-form {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-assign-form input[type="text"] {
  width: 4.5rem;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.inline-assign-form button,
.inline-release-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 8px;
  color: var(--accent);
  border-color: var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 0.5px solid var(--border);
  font-size: 0.9rem;
}

/* Deployment-ID/Job-ID are for debugging, not routine reading — hidden by
   default so the message column gets the room, one click away via the
   "show IDs" toggle. */
.tech-col {
  display: none;
}

table.show-tech-cols .tech-col {
  display: table-cell;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

tr:hover td {
  background: var(--bg-accent-muted);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
}

.badge.draft { background: var(--bg-warning); color: var(--text-warning); }
.badge.ready { background: var(--bg-success); color: var(--text-success); }
.badge.successful { background: var(--bg-success); color: var(--text-success); }
.badge.failed { background: var(--bg-danger); color: var(--text-danger); }
.badge.starting, .badge.running { background: var(--bg-info); color: var(--text-info); }
.badge.unknown { background: var(--bg-neutral); color: var(--text-neutral); }

.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }

.field-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.5rem;
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.field-grid dt { color: var(--text-muted); }
.field-grid dd { margin: 0; }

/* Two genuinely independent .field-grid blocks side by side, each with its
   own themed set of fields (see testcase-detail.ejs) — CHANGED 2026-09-14:
   a single 4-column grid can only alternate every other field between
   "left"/"right", it can't group fields by theme regardless of how many
   there are on each side. Wraps to a single stacked column on narrow
   screens. */
.field-grid-columns {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.field-grid-columns .field-grid {
  flex: 1;
  margin-bottom: 0;
  align-self: stretch;
}

@media (max-width: 700px) {
  .field-grid-columns {
    flex-direction: column;
  }
}

code {
  background: var(--bg-neutral);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.85em;
}

section h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.filters {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.filters input {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-right: 0.5rem;
}

.empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius-lg);
}

section {
  margin-bottom: 1.5rem;
}

.action-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.action-form label {
  color: var(--text-muted);
}

.action-form input[type="text"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 12rem;
  font: inherit;
}

.action-form input[type="text"].wide {
  width: 28rem;
  max-width: 100%;
}

button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

button svg {
  width: 14px;
  height: 14px;
  flex: none;
}

button:hover:not(:disabled) {
  background: var(--bg-accent-muted);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#variants-table .variant-row input[type="text"] {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  box-sizing: border-box;
}

#variants-table .variant-row button {
  font-size: 14px;
  padding: 2px 8px;
  line-height: 1;
}

.error-msg {
  color: var(--text-danger);
  background: var(--bg-danger);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.hint {
  color: var(--text-info);
  background: var(--bg-info);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Control Room settings page's "Verbindung testen" result — one line per
   checked item (auth, Run-As user, each pool), icon + text instead of a
   plain string so a failure among several successes still stands out. */
.test-result {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.test-result-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-family: inherit;
}
.test-result-line svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.test-result-line.ok svg { color: var(--text-success); }
.test-result-line.fail svg { color: var(--text-danger); }

/* ---- K-IT Formbridge: forms ------------------------------------------- */
.form-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.form-tile { display: flex; flex-direction: column; gap: 0.4rem; text-decoration: none; color: inherit; }
.form-tile:hover { border-color: var(--accent); }
.form-tile .title { font-weight: 600; color: var(--text-primary); }
.form-tile-open { margin-top: auto; color: var(--accent); font-size: 0.9rem; }

/* Caps a single form/record at a comfortable reading width and centers it —
   without this, a form with mostly full-width fields sits flush left with a
   large empty area on wide screens. Lists/tables (index.ejs, submissions.ejs)
   and the split-view editor keep the full width on purpose. */
.page-narrow { max-width: 720px; margin: 0 auto; }
.form-card { display: flex; flex-wrap: wrap; align-content: flex-start; column-gap: 1.25rem; }
.form-field { flex: 0 0 100%; max-width: 100%; margin-bottom: 1.1rem; box-sizing: border-box; }
.form-field.w-half { flex-basis: calc(50% - 0.625rem); max-width: calc(50% - 0.625rem); }
.form-field.w-third { flex-basis: calc(33.333% - 0.834rem); max-width: calc(33.333% - 0.834rem); }
@media (max-width: 560px) {
  .form-field.w-half, .form-field.w-third { flex-basis: 100%; max-width: 100%; }
}
.form-field[hidden] { display: none; }
.form-field label, .form-field legend { display: block; font-weight: 500; margin-bottom: 0.3rem; }
.form-field label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin-bottom: 0.25rem; }
.form-field fieldset { border: 0; padding: 0; margin: 0; }
.form-field input[type="text"], .form-field input[type="email"], .form-field input[type="number"],
.form-field input[type="date"], .form-field input[type="time"], .form-field input[type="datetime-local"],
.form-field select, .form-field textarea {
  width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; background: var(--surface);
}
.form-field.has-error input, .form-field.has-error select, .form-field.has-error textarea { border-color: var(--text-danger); }
.form-field .help { color: var(--text-muted); font-size: 0.85rem; margin: 0.25rem 0 0; }
.form-field .field-error { color: var(--text-danger); font-size: 0.85rem; margin: 0.25rem 0 0; }
.form-field .req { color: var(--text-danger); }
.form-field h3 { margin: 1.25rem 0 0.25rem; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.form-field legend { padding: 0; }

/* ---- form editor ------------------------------------------------------- */
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.editor-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.editor-toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; margin: 0; background: transparent; padding: 0.4rem 0.9rem; }
.seg button.on { background: var(--accent); color: #fff; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.ed-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.ed-right { position: sticky; top: 0.75rem; }
.ed-preview-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.35rem; }
.ed-right iframe { width: 100%; height: calc(100vh - 6rem); min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-page); }
#json {
  width: 100%; height: 75vh; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem;
  padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); resize: vertical; box-sizing: border-box;
}
@media (max-width: 1000px) { .ed-grid { grid-template-columns: 1fr; } .ed-right { position: static; } }
#builder h3 { margin: 0 0 0.6rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); }
.small { font-size: 0.8rem; }
.ed-meta { margin-bottom: 1.25rem; }
.fe { display: block; margin: 0 0 0.75rem; }
.fe-l { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.2rem; }
.fe input[type="text"], .fe input[type="number"], .fe input[type="date"], .fe input[type="time"], .fe input[type="datetime-local"],
.fe select, .fe textarea, .cond input[type="text"], .cond select, .opts input[type="text"] {
  width: 100%; box-sizing: border-box; padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font: inherit; font-size: 0.9rem; color: var(--text-primary);
}
.fe input:focus, .fe select:focus, .fe textarea:focus, .cond input:focus, .cond select:focus, .opts input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent);
}
.fe input[readonly] { background: var(--bg-neutral); color: var(--text-secondary); }
.fe-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.fe-pair.bot { grid-template-columns: 16rem 1fr; }
.fe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.6rem 0.75rem; margin-bottom: 0.75rem; }
.fe-grid .fe { margin: 0; }
.fe-flags { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin-bottom: 0.75rem; }
.fe-check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; cursor: pointer; }
.fe-adv { margin-top: 0.25rem; }
.fe-adv summary { cursor: pointer; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 0.6rem; }
.fc-list { margin-bottom: 1.25rem; }
.fc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 0.5rem; transition: box-shadow .15s, border-color .15s; }
.fc:hover { border-color: #c9ccd6; }
.fc.open { border-color: var(--accent); box-shadow: 0 2px 12px rgba(59, 91, 253, 0.10); }
.fc.drop { border-color: var(--accent); box-shadow: 0 -3px 0 var(--accent); }
.fc.has-cond { border-left: 3px solid #f59e0b; }
.fc-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; cursor: pointer; user-select: none; }
.fc-grip { color: var(--text-muted); cursor: grab; font-size: 1.05rem; line-height: 1; }
.fc-glyph {
  flex: none; min-width: 2rem; height: 2rem; padding: 0 0.3rem; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 0.8rem; font-weight: 600; background: var(--bg-accent-muted); color: var(--accent);
}
.fc-glyph.t-radio, .fc-glyph.t-select, .fc-glyph.t-checkbox, .fc-glyph.t-checkboxgroup, .fc-glyph.t-multiselect { background: #ecfdf3; color: #15803d; }
.fc-glyph.t-date, .fc-glyph.t-time, .fc-glyph.t-datetime { background: #fff4e0; color: #b45309; }
.fc-glyph.t-heading, .fc-glyph.t-info, .fc-glyph.t-divider { background: var(--bg-neutral); color: var(--text-secondary); }
.fc-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.fc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.fc-type { color: var(--text-muted); font-size: 0.8rem; }
.fc-req { color: var(--text-danger); font-weight: 700; }
.fc-id { font-size: 0.75rem; color: var(--text-muted); background: none; padding: 0; }
.fc-btns { display: flex; gap: 0.15rem; opacity: 0; transition: opacity .12s; }
.fc:hover .fc-btns, .fc.open .fc-btns, .fc:focus-within .fc-btns { opacity: 1; }
.fc-chev { color: var(--text-muted); width: 1rem; text-align: center; }
.fc-body { padding: 0.25rem 1rem 0.5rem 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.ico { border: 0; background: transparent; padding: 0.15rem 0.45rem; margin: 0; border-radius: 6px; color: var(--text-secondary); min-width: 1.6rem; }
.ico:hover:not(:disabled) { background: var(--bg-neutral); }
.ico.danger:hover:not(:disabled) { background: var(--bg-danger); color: var(--text-danger); }
.ico:disabled { opacity: 0.3; }
button.ghost { background: transparent; border: 1px dashed var(--border); color: var(--accent); }
button.ghost:hover:not(:disabled) { background: var(--bg-accent-muted); border-color: var(--accent); }
.empty { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; color: var(--text-muted); }
.opts { display: grid; gap: 0.35rem; }
.opt-row { display: grid; grid-template-columns: 1.4rem 1fr 1fr 1fr 5.4rem; gap: 0.4rem; align-items: center; }
.opt-head span { font-size: 0.72rem; color: var(--text-muted); }
.opt-n { color: var(--text-muted); font-size: 0.8rem; text-align: right; }
.opt-btns { display: flex; }
.opts > button.ghost { justify-self: start; }
.cond-line { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.cond-line select, .cond-line input[type="text"] { width: auto; min-width: 8rem; flex: 1 1 8rem; }
.cond-checks { display: inline-flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; font-size: 0.9rem; }
.palette { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; }
.pal-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.pal-title { width: 6.5rem; font-size: 0.8rem; color: var(--text-muted); }
.pal-btn { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.65rem 0.3rem 0.35rem; margin: 0; border-radius: 999px; background: var(--surface); }
.pal-btn .fc-glyph { min-width: 1.6rem; height: 1.6rem; border-radius: 999px; font-size: 0.7rem; }
.pal-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--bg-accent-muted); }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 0 0 0.75rem; font: inherit; }
