@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --gkmb-red: #a3131e;
  --gkmb-red-dark: #7e0f17;
  --gkmb-red-soft: #f8e9ea;
  --gkmb-red-mid: #c42a35;
  --surface: #ffffff;
  --page-bg: #f3f4f6;
  --page-bg-2: #eef0f3;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text-dark: #111827;
  --text-muted: #6b7280;
  --text-label: #374151;
  --input-bg: #f3f4f6;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --gkmb-gray: #f3f4f6;
  --gkmb-border: var(--border);
  --gkmb-green: var(--gkmb-red);
}

* { box-sizing: border-box; }

body {
  font-family: "Manrope", sans-serif;
  color: var(--text-dark);
  background: var(--page-bg);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Shared shell ---------- */
.app-header {
  background: var(--gkmb-red);
  color: white;
  padding: 28px 32px 32px;
  border-bottom: none;
}
.app-header .brand { color: rgba(255,255,255,0.85); margin-bottom: 10px; }
.app-header .brand-sub { color: rgba(255,255,255,0.65); }
.app-header h1 {
  margin: 0 0 8px;
  color: white;
  font-size: clamp(1.5rem, 2.4vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.app-header .subtitle {
  color: rgba(255,255,255,0.88);
  margin: 0;
  max-width: 720px;
  font-size: 0.98rem;
}

.brand {
  font-weight: 800;
  color: var(--gkmb-red);
  letter-spacing: 0.04em;
  font-size: 13px;
  text-transform: uppercase;
}
.brand-sub { color: var(--text-muted); font-weight: 500; }

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h2 {
  color: var(--text-dark);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 8px;
  border-bottom: none;
  padding-bottom: 0;
  letter-spacing: -0.01em;
}
.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 18px;
  line-height: 1.55;
}
.hint code {
  background: var(--gkmb-red-soft);
  color: var(--gkmb-red-dark);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.84em;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin-bottom: 8px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px 16px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-label);
  gap: 7px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-dark);
  background: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  background: white;
  border-color: var(--gkmb-red);
  box-shadow: 0 0 0 3px rgba(163, 19, 30, 0.12);
}
textarea { resize: vertical; min-height: 48px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% + 2px), calc(100% - 12px) calc(50% + 2px); background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 36px; }

.models-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 900px) {
  .models-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .models-list { grid-template-columns: 1fr; }
}
.model-item,
label.model-item {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-height: 100px;
  height: 100%;
  background: #ffffff;
  margin: 0;
  font-size: inherit;
  font-weight: 500;
  color: inherit;
}
.model-item:has(input:checked),
label.model-item:has(input:checked) {
  background: var(--gkmb-red-soft);
  border-color: #e4b4b8;
}
.model-item.disabled,
label.model-item.disabled {
  opacity: 0.72;
  background: var(--page-bg);
}
.model-item input {
  appearance: none;
  -webkit-appearance: none;
  margin-top: 1px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transform: none;
}
.model-item input:checked {
  background: var(--gkmb-red);
  border-color: var(--gkmb-red);
}
.model-item input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.model-item input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.model-item > span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.model-item strong {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.3;
}
.model-item .model-note {
  font-size: 11px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 500;
  line-height: 1.35;
}

.prompt-row {
  display: grid;
  grid-template-columns: 36px 1fr 150px 44px;
  gap: 10px;
  align-items: start;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.prompt-row:last-child { margin-bottom: 0; }
.prompt-row > .prompt-enabled-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  min-height: 44px;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}
.prompt-row .prompt-context-label {
  grid-column: 2 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.prompt-row .prompt-context-label span {
  letter-spacing: 0.01em;
}
.prompt-row .prompt-context {
  width: 100%;
  min-height: 64px;
  height: auto;
  resize: none;
  overflow: hidden;
  font-weight: 400;
  font-size: 0.92rem;
  line-height: 1.45;
  background: #ffffff !important;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-dark);
}
.prompt-row .prompt-context:focus {
  outline: none;
  border-color: var(--gkmb-red);
  box-shadow: 0 0 0 3px rgba(163, 19, 30, 0.12);
}
.prompt-row .prompt-enabled {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  position: relative;
}
.prompt-row .prompt-enabled:hover {
  border-color: var(--gkmb-red);
}
.prompt-row .prompt-enabled:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(163, 19, 30, 0.15);
}
.prompt-row .prompt-enabled:checked {
  background: var(--gkmb-red);
  border-color: var(--gkmb-red);
}
.prompt-row .prompt-enabled:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.prompt-row .prompt-text,
.prompt-row .prompt-topic-input {
  background: #ffffff !important;
  border: 1px solid var(--border-strong);
  min-height: 44px !important;
  padding-top: 10px;
  padding-bottom: 10px;
  line-height: 1.35;
}
.prompt-row .prompt-text {
  height: auto;
  resize: none;
  overflow: hidden;
}
.prompt-row .prompt-topic-input {
  height: 44px;
  resize: none;
}
.prompt-row .prompt-text:focus,
.prompt-row .prompt-topic-input:focus {
  border-color: var(--gkmb-red);
  box-shadow: 0 0 0 3px rgba(163, 19, 30, 0.12);
}
.prompt-num {
  width: 28px;
  height: 28px;
  margin-top: 0;
  border-radius: 999px;
  background: var(--gkmb-red);
  color: white;
  font-weight: 700;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.prompt-topic-input { font-size: 0.85rem; }

button#runBtn,
#submitBtn,
.auth-card button {
  background: var(--gkmb-red);
  color: white;
  border: none;
  padding: 14px 28px;
  font-size: 0.98rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
button#runBtn:hover,
#submitBtn:hover,
.auth-card button:hover { background: var(--gkmb-red-dark); }
button#runBtn:active,
#submitBtn:active { transform: translateY(1px); }
button#runBtn:disabled,
#submitBtn:disabled,
.auth-card button:disabled {
  background: #c4c4c4;
  cursor: not-allowed;
  transform: none;
}

.action-card { text-align: center; }

.progress-bar {
  background: var(--page-bg);
  border-radius: 999px;
  height: 10px;
  margin: 16px auto 8px;
  max-width: 500px;
  overflow: hidden;
}
.progress-fill {
  background: linear-gradient(90deg, var(--gkmb-red), var(--gkmb-red-mid));
  height: 100%;
  width: 0%;
  transition: width 0.2s;
}
#progressText { color: var(--text-muted); font-size: 13px; }

.notice {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.92rem;
}
.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--gkmb-red-dark);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  font-size: 0.92rem;
}
.success {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  font-size: 0.92rem;
}
.banner-msg {
  margin-top: 0;
  margin-bottom: 18px;
  font-weight: 600;
}
.intro-copy {
  margin: 0 0 18px;
  padding: 22px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}
.intro-copy p {
  margin: 0 0 12px;
}
.intro-copy p:last-child {
  margin-bottom: 0;
}
.hidden { display: none !important; }

/* ---------- Report ---------- */
.report {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-top: 10px;
  box-shadow: var(--shadow);
}
.report h2 { color: var(--gkmb-red); border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.report h3 { color: var(--gkmb-red); margin-top: 28px; }
.report h4 { margin-bottom: 6px; }

.score-badge {
  display: inline-block;
  font-size: 28px;
  font-weight: 800;
  color: var(--gkmb-red);
  margin: 4px 0 14px;
}

table.report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 22px;
  font-size: 13.5px;
}
table.report-table th {
  background: var(--gkmb-red);
  color: white;
  text-align: left;
  padding: 10px 12px;
}
table.report-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  vertical-align: top;
}
table.report-table tr:nth-child(even) td { background: #fafafa; }

.tag-ja { color: var(--gkmb-red); font-weight: 700; }
.tag-nein { color: var(--gkmb-red-dark); font-weight: 700; }
.tag-fehler { color: #b36b00; font-weight: 700; }
.sentiment-positiv { color: var(--gkmb-red); }
.sentiment-negativ { color: var(--gkmb-red-dark); }
.sentiment-neutral { color: #b8860b; }

.report-actions { margin: 14px 0 24px; text-align: right; }
.report-actions button {
  background: white;
  border: 1px solid var(--gkmb-red);
  color: var(--gkmb-red);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
}
.report-actions button:hover { background: var(--gkmb-red); color: white; }

.raw-toggle { font-size: 12px; color: var(--text-muted); cursor: pointer; text-decoration: underline; }
.raw-text {
  white-space: pre-wrap;
  font-size: 12.5px;
  background: var(--page-bg);
  padding: 10px;
  border-radius: 8px;
  margin-top: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.app-footer {
  text-align: center;
  color: #4b5563;
  font-size: 13px;
  font-weight: 500;
  padding: 28px 20px 40px;
  margin: 28px 20px 0;
  border-top: 1px solid #d1d5db;
  background: transparent;
}
.app-footer div {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.06);
  color: #374151;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.btn-secondary {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
}
.btn-secondary:hover {
  background: white;
  color: var(--gkmb-red);
}

.checkbox-row {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 12px;
  margin-top: 18px;
  color: var(--text-dark);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.5;
  padding: 14px;
  background: var(--page-bg);
  border-radius: var(--radius-sm);
}
.checkbox-row input {
  appearance: none;
  -webkit-appearance: none;
  margin-top: 2px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  accent-color: var(--gkmb-red);
}
.checkbox-row input:checked {
  background: var(--gkmb-red);
  border-color: var(--gkmb-red);
}
.checkbox-row input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.hp-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Order page (Lead+KEEP inspired) ---------- */
.order-page {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(163, 19, 30, 0.08), transparent 55%),
    radial-gradient(900px 400px at 90% 0%, rgba(163, 19, 30, 0.05), transparent 50%),
    var(--page-bg);
  min-height: 100vh;
}

.order-page .page-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

.order-page .hero-banner {
  background: linear-gradient(135deg, var(--gkmb-red) 0%, #8a1019 100%);
  color: white;
  border-radius: 18px;
  padding: 28px 28px 26px;
  margin-bottom: 20px;
  box-shadow: 0 12px 32px rgba(163, 19, 30, 0.22);
}
.order-page .hero-banner .brand {
  color: rgba(255,255,255,0.8);
  margin-bottom: 12px;
}
.order-page .hero-banner .brand-sub { color: rgba(255,255,255,0.55); }
.order-page .hero-banner h1 {
  margin: 0 0 10px;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: white;
}
.order-page .hero-banner .subtitle {
  margin: 0;
  color: rgba(255,255,255,0.9);
  font-size: 0.98rem;
  max-width: 560px;
}

.order-page .form-shell {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.order-page .form-section {
  padding: 26px 28px;
  border-bottom: 1px solid var(--border);
}
.order-page .form-section:last-child { border-bottom: none; }

.order-page .form-section h2 {
  margin: 0 0 6px;
  font-size: 1.08rem;
  font-weight: 750;
  color: var(--text-dark);
}

.order-page .form-section .hint { margin-bottom: 16px; }

.order-page .form-section label { margin-bottom: 12px; }
.order-page .form-section .grid-2 label { margin-bottom: 0; }
.order-page .competitor-stack {
  display: grid;
  gap: 12px;
}

.order-page .action-bar {
  padding: 24px 28px 32px;
  background: linear-gradient(180deg, #fafafa 0%, white 100%);
}
.order-page #submitBtn {
  width: 100%;
  padding: 15px 20px;
  border-radius: 12px;
  font-size: 1rem;
}

/* ---------- Login ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(163, 19, 30, 0.14), transparent 60%),
    var(--page-bg);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 30px 28px;
  box-shadow: var(--shadow);
}
.auth-card .brand { margin-bottom: 14px; }
.auth-card h1 {
  color: var(--text-dark);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
.auth-card .hint { margin-bottom: 20px; }
.auth-card label { margin-bottom: 14px; }
.auth-card button {
  width: 100%;
  margin-top: 8px;
  border-radius: 12px;
}

/* ---------- Admin analysis page ---------- */
body:not(.order-page):not(.auth-page) .app-header {
  border-radius: 0;
  margin: 0;
  box-shadow: none;
}

@media print {
  .app-header, #input-section, #models-section, #prompts-section, .action-card, .app-footer, .report-actions { display: none !important; }
  body { background: white; }
  .report { border: none; padding: 0; box-shadow: none; }
}

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .order-page .page-wrap {
    padding: 12px 12px 40px;
    max-width: 100%;
  }
  .order-page .hero-banner {
    border-radius: 14px;
    padding: 20px 16px 18px;
    margin-bottom: 14px;
  }
  .order-page .hero-banner h1 {
    font-size: 1.35rem;
  }
  .order-page .hero-banner .subtitle {
    font-size: 0.92rem;
  }
  .order-page .intro-copy {
    padding: 16px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    border-radius: 14px;
  }
  .order-page .intro-copy p {
    margin-bottom: 10px;
  }
  .order-page .form-shell {
    border-radius: 14px;
  }
  .order-page .form-section,
  .order-page .action-bar {
    padding: 18px 16px;
  }
  .order-page .form-section h2 {
    font-size: 1.02rem;
  }
  .order-page .form-section .hint {
    font-size: 0.88rem;
    margin-bottom: 12px;
  }
  .order-page .action-bar {
    padding-bottom: 24px;
  }
  .order-page #submitBtn {
    padding: 16px 18px;
    font-size: 1.02rem;
    min-height: 52px;
  }
  /* iOS: kein Auto-Zoom beim Fokus */
  .order-page input,
  .order-page textarea,
  .order-page select {
    font-size: 16px !important;
    max-width: 100%;
  }
  .order-page .checkbox-row {
    align-items: flex-start;
    gap: 12px;
  }
  .order-page .checkbox-row span {
    font-size: 0.88rem;
    line-height: 1.45;
  }

  /* Prompt-Karten: Frage oben, Thema + Aktiv nebeneinander, Kontext unten */
  .prompt-row {
    grid-template-columns: 32px 1fr auto;
    gap: 8px 10px;
    padding: 12px;
    align-items: center;
  }
  .prompt-row .prompt-num {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    margin-top: 8px;
  }
  .prompt-row .prompt-text {
    grid-column: 2 / -1;
    grid-row: 1;
    width: 100%;
    min-height: 48px !important;
  }
  .prompt-row .prompt-topic-input {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }
  .prompt-row .prompt-enabled-wrap {
    grid-column: 3;
    grid-row: 2;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    align-self: stretch;
  }
  .prompt-row .prompt-context-label {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 2px;
  }
  .prompt-row .prompt-context {
    min-height: 72px;
    font-size: 16px !important;
  }

  body:not(.order-page):not(.auth-page) .app-header { margin: 0; border-radius: 0; }
}

@media (max-width: 400px) {
  .order-page .page-wrap {
    padding: 10px 10px 32px;
  }
  .order-page .hero-banner,
  .order-page .form-section,
  .order-page .action-bar,
  .order-page .intro-copy {
    padding-left: 14px;
    padding-right: 14px;
  }
  .prompt-row {
    padding: 10px;
  }
}
