:root {
  --color-text: #1f2933;
  --color-muted: #52606d;
  --color-bg: #f7f8fa;
  --color-surface: #ffffff;
  --color-border: #d3d9e0;

  --color-begriff-bg: #eaf2fb;
  --color-begriff-border: #4a7fb5;

  --color-icd-bg: #f0f1f2;
  --color-icd-border: #7a8592;

  --color-gds-bg: #eaf7f0;
  --color-gds-border: #3f9d6e;

  --color-fall3-bg: #fdf3e3;
  --color-fall3-border: #c98a2b;

  --color-fall4-bg: #fdf3e3;
  --color-fall4-border: #c98a2b;

  --radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

.site-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.site-subtitle {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ---------- Suche ---------- */

.search-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.search-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-field-number {
  flex-shrink: 0;
  min-width: 1.4rem;
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: right;
}

.search-input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.search-input:focus {
  outline: 2px solid var(--color-begriff-border);
  outline-offset: 1px;
}

.remove-field-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius);
  width: 2.25rem;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--color-muted);
}

.search-actions {
  display: flex;
  gap: 0.5rem;
}

#add-field-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  cursor: pointer;
  color: var(--color-text);
}

#search-submit-btn {
  background: var(--color-begriff-border);
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.5rem;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.load-status {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--color-muted);
  min-height: 1.1em;
}

#add-field-btn:hover,
#search-submit-btn:hover,
.remove-field-btn:hover {
  filter: brightness(0.95);
}

/* ---------- Ergebnis-Aktionen ---------- */

.results-actions {
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

#show-all-codes-btn,
#view-toggle-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-icd-border);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}

#show-all-codes-btn:hover,
#view-toggle-btn:hover {
  filter: brightness(0.96);
}

.all-codes-liste {
  margin: 0.5rem 0 1rem;
  padding-left: 1.2rem;
}

.all-codes-liste li {
  margin-bottom: 0.5rem;
}

.all-codes-notiz {
  color: var(--color-muted);
  font-size: 0.85rem;
}

/* ---------- Tabs ---------- */

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 2px solid var(--color-border);
}

.tab-btn {
  padding: 0.6rem 1rem;
  border: 1px solid var(--color-border);
  border-bottom: none;
  background: #e9ecf0;
  color: var(--color-muted);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  font-size: 0.95rem;
}

.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
}

.tab-panels {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.25rem;
  min-height: 200px;
}

.tab-panel[hidden] {
  display: none;
}

/* ---------- Gesamtübersicht (Grid aller Diagnose-Tabs) ---------- */

.tab-panels.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
  min-height: 0;
  align-items: start;
}

.grid-view .tab-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--color-bg);
}

.grid-view .diagnose-panel,
.grid-view .box-fall3,
.grid-view .box-fall4 {
  gap: 0.6rem;
}

.grid-view .box {
  padding: 0.55rem 0.7rem;
}

.grid-view .box h2 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.grid-view .box h3 {
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.grid-view .box p {
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}

.grid-view .reveal-btn,
.grid-view .fall4-option {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
}

.grid-view .fall3-liste,
.grid-view .gds-tabelle,
.grid-view .gds-fussnoten {
  font-size: 0.8rem;
}

.grid-view .panel-no-match {
  font-size: 0.85rem;
}

.diagnose-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---------- Kästen ---------- */

.box {
  border: 1px solid var(--color-border);
  border-left-width: 5px;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.box h2 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
}

.box h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-muted);
}

.box p {
  margin: 0 0 0.6rem;
}

.box p:last-child {
  margin-bottom: 0;
}

.box-begriff {
  background: var(--color-begriff-bg);
  border-left-color: var(--color-begriff-border);
}

.box-icd {
  background: var(--color-icd-bg);
  border-left-color: var(--color-icd-border);
}

.box-gds {
  background: var(--color-gds-bg);
  border-left-color: var(--color-gds-border);
}

.box-fall3,
.box-fall4 {
  background: var(--color-fall3-bg);
  border-left-color: var(--color-fall3-border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.box-fall3 .box-gds {
  margin-top: 0.25rem;
}

.placeholder-hint {
  color: var(--color-muted);
  font-style: italic;
}

.schweregrad-hinweis {
  font-size: 0.85rem;
  font-weight: 600;
}

.reveal-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.reveal-btn:hover {
  filter: brightness(0.96);
}

.quelle-hinweis {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.fall3-liste {
  margin: 0;
  padding-left: 1.2rem;
}

.fall3-liste li {
  margin-bottom: 0.3rem;
}

.fall3-sammelcode strong,
.fall4-intro {
  color: var(--color-text);
}

.fall4-optionen {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fall4-option {
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-fall4-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 1rem;
}

.fall4-option:hover {
  background: #fff8ec;
}

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

.panel-no-match {
  color: var(--color-muted);
  padding: 1rem 0;
}

.load-error {
  color: #a4402a;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: 900px;
  margin: 2rem auto 0;
  padding: 1rem 1.25rem 2rem;
  font-size: 0.8rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

.site-footer p {
  margin: 0.25rem 0;
}

.stats-link {
  margin-top: 0.5rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--color-muted);
  text-decoration: underline;
  font-size: 0.8rem;
  cursor: pointer;
}

.stats-link:hover {
  color: var(--color-text);
}

/* ---------- Modal (Ebene 2 — offizieller Referenzbereich) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  position: relative;
  background: var(--color-surface);
  border: 2px solid var(--color-icd-border);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2.25rem 1.5rem 1.5rem;
}

.referenzbereich-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--color-icd-border);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius) 0 var(--radius) 0;
}

.modal-close {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-muted);
}

.modal-code {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.modal-eigener-begriff {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--color-border);
}

/* ---------- Statistik-Panel (eigener Inhalt, kein offizieller Referenzbereich) ---------- */

.stats-box {
  border-color: var(--color-begriff-border);
  padding-top: 1.5rem;
}

.stats-info,
.stats-encourage {
  font-size: 0.9rem;
}

.stats-encourage {
  font-weight: 600;
}

.stats-liste {
  margin: 0.75rem 0;
  padding-left: 1.2rem;
}

.stats-liste li {
  margin-bottom: 0.4rem;
}

.stats-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.gds-spektrum-kurz {
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.gds-tabelle {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
}

.gds-tabelle th,
.gds-tabelle td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.gds-tabelle th {
  color: var(--color-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gds-tabelle td:last-child {
  white-space: nowrap;
  font-weight: 600;
}

.gds-fussnoten {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.gds-fussnoten li {
  margin-bottom: 0.35rem;
}

.versmedv-hinweis {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 1rem;
}

.pflicht-quelle {
  font-size: 0.8rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .search-field-row {
    flex-direction: column;
  }
  .remove-field-btn {
    align-self: flex-end;
  }
}

/* ---------- Statische Diagnose-Inhaltsseiten (SSG, §9) ---------- */

.content-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.content-breadcrumb {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 1rem;
}

.content-breadcrumb a {
  color: var(--color-muted);
}

.content-page h1 {
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
}

.content-lastmod {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

.content-answer {
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
}

.content-page section {
  margin-bottom: 1.75rem;
}

.content-page h2 {
  font-size: 1.2rem;
  margin: 0 0 0.6rem;
}

.icd-details,
.gds-details {
  border: 1px solid var(--color-icd-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: var(--color-icd-bg);
}

.icd-details summary,
.gds-details summary {
  cursor: pointer;
  font-weight: 600;
}

.icd-details[open],
.gds-details[open] {
  padding-bottom: 1rem;
}

.icd-details p,
.gds-details p {
  margin: 0.5rem 0 0;
}

.content-fall3-liste,
.content-fall4-liste {
  padding-left: 1.2rem;
}

.content-fall4-liste li {
  margin-bottom: 0.4rem;
}

.content-pflichthinweis {
  font-weight: 600;
}

.faq-list dt {
  font-weight: 600;
  margin-top: 1rem;
}

.faq-list dd {
  margin: 0.3rem 0 0;
}

.content-referenzbereich {
  border: 2px solid var(--color-icd-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

.content-referenzbereich .referenzbereich-badge {
  position: static;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.content-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-muted);
}

.content-tool-link {
  display: inline-block;
  margin-top: 1.5rem;
  font-weight: 600;
}

/* ---------- Verbesserungsvorschlag (mailto, kein Server) ---------- */
.feedback-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 2rem;
}
.feedback-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.feedback-hinweis {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}
.feedback-label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.feedback-text {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  resize: vertical;
}
.feedback-btn {
  margin-top: 0.5rem;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  background: var(--color-begriff-bg);
  border: 1px solid var(--color-begriff-border);
  border-radius: var(--radius);
  cursor: pointer;
}
.feedback-btn:hover {
  background: #dceaf8;
}
.feedback-datenschutz {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--color-muted);
}

/* ---------- Pflichtlinks im Footer (max. 2 Klicks erreichbar) ---------- */
.footer-rechtliches {
  margin-top: 0.75rem !important;
}
.content-rechtliches {
  margin-top: 0.75rem;
}
.footer-quellen {
  margin-top: 0.75rem !important;
  font-size: 0.72rem;
  line-height: 1.5;
}
