/* Design-System uebernommen vom Tacto-Reporting (nikolausridder1301/tacto),
   damit beide internen Tools optisch als eine Familie wirken. */
:root {
  color-scheme: light;
  --bg: #e7ebf1;
  --surface: #ffffff;
  --border: #dce1ea;
  --text: #161b26;
  --text-muted: #5a6577;
  --accent: #2563c9;
  --accent-bg: #e7f0ff;
  --dark: #161b26;
  --dark-surface: #222b3a;
  --rot: #dc2626;
  --rot-bg: #fde3e2;
  --rot-text: #b3261e;
  --gelb-bg: #fdecc8;
  --gelb-text: #92580a;
  --gruen-bg: #dcf3e2;
  --gruen-text: #157a3d;
  --radius-card: 16px;
  --radius-sm: 8px;
  --shadow-card:
    0 1px 2px rgba(20, 30, 50, 0.05),
    0 8px 24px rgba(20, 30, 50, 0.06);
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

h1, h2 { margin: 0 0 0.5rem; font-weight: 700; letter-spacing: -0.01em; }

.meta-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.app { max-width: 640px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 1rem;
  z-index: 20;
}

.header-title { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.header-title h1 { margin: 0; font-size: 1.35rem; }

.header-logo {
  height: 44px;
  width: 44px;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  margin: 0;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.panel-header { margin-bottom: 0.75rem; }
.panel-header h2 { margin: 0; font-size: 1.05rem; }

.privacy-banner {
  background: var(--accent-bg);
  border: 1px solid #bcd4f7;
  border-radius: var(--radius-card);
  padding: 0.9rem 1.1rem;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
  color: var(--text);
}

.status-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1rem 1.2rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-card);
}

.status-box.error { background: var(--rot-bg); border-color: #f5c2c0; color: var(--rot-text); }

.field { margin-bottom: 1.25rem; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.field .required {
  color: var(--rot-text);
  background: var(--rot-bg);
  font-weight: 600;
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input[type="text"], select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
}

input[type="text"]:focus, select:focus, .dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.88rem;
}

.dropzone:hover, .dropzone.dragover { background: var(--accent-bg); border-color: var(--accent); }

.dropzone.has-file {
  background: var(--gruen-bg);
  border-color: var(--gruen-text);
  border-style: solid;
  color: var(--text);
  font-weight: 600;
}

/* Checkliste: was hochzuladen ist. Steht bewusst ganz oben - wer den Link
   geteilt bekommt, soll ohne Rueckfrage wissen, welche Exporte er braucht. */
.was-brauche-ich {
  background: var(--accent-bg);
  border: 1px solid #bcd4f7;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin: 0 0 1.5rem;
  font-size: 0.85rem;
  line-height: 1.6;
}

.was-brauche-ich strong:first-child { display: block; margin-bottom: 0.4rem; }
.was-brauche-ich span { display: block; }
.was-brauche-ich code { font-family: var(--font-mono); font-size: 0.8rem; }
.was-brauche-ich .nebenbei {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Betriebsparameter: Status, ob die lokalen Werte hinterlegt sind */
.param-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  background: var(--gelb-bg);
  color: var(--gelb-text);
}

.param-badge.ok { background: var(--gruen-bg); color: var(--gruen-text); }

#parameter-field .hinweis {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 0.6rem;
  font-weight: 400;
}

#parameter-field .dropzone { padding: 0.9rem 1rem; }

#param-loeschen {
  margin-top: 0.5rem;
  padding: 0.35rem 0.7rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

#param-loeschen:hover { border-color: var(--rot-text); color: var(--rot-text); }

.erweitert {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  margin-bottom: 1.25rem;
  background: #fbfcfd;
}

.erweitert > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent);
  padding: 0.25rem 0;
}

.erweitert[open] > summary { margin-bottom: 0.75rem; }

.erweitert .hinweis {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 1rem;
}

.erweitert .dropzone { padding: 0.9rem 1rem; }

button[type="submit"] {
  width: 100%;
  padding: 0.8rem;
  background: var(--dark);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

button[type="submit"]:hover:not(:disabled) { background: var(--dark-surface); }
button[type="submit"]:disabled { background: #a9b0bd; cursor: not-allowed; }

#result h2 { font-size: 1.1rem; }
#result .summary-line {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
#result .summary-line:last-of-type { border-bottom: none; }
#result .summary-line span:last-child { font-weight: 600; font-family: var(--font-mono); }

.warning-box {
  background: var(--gelb-bg);
  color: var(--gelb-text);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  margin-top: 1rem;
}

.download-btn {
  display: block;
  text-align: center;
  margin-top: 1.2rem;
  padding: 0.85rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(20,30,50,0.08), 0 6px 16px rgba(37,99,201,0.3);
}
.download-btn:hover { background: #1e50a8; }

/* Manuelle Zuordnung nicht zuordenbarer Fertigungsauftraege */
.zuordnung {
  margin-top: 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  background: #fbfcfd;
}

.zuordnung > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent);
}

.zuordnung[open] > summary { margin-bottom: 0.75rem; }

.zuordnung-tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 0.9rem;
}

.zuordnung-tabelle th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid var(--border);
  padding: 0.35rem 0.4rem;
}

.zuordnung-tabelle td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.zuordnung-tabelle select {
  padding: 0.25rem 0.4rem;
  font-size: 0.78rem;
  width: auto;
  min-width: 6.5rem;
}

#neu-berechnen,
#param-sichern {
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

#neu-berechnen:hover:not(:disabled),
#param-sichern:hover { background: #1e50a8; }
#neu-berechnen:disabled { background: #a9b0bd; cursor: not-allowed; }

.legend { margin-top: 1.1rem; font-size: 0.8rem; color: var(--text-muted); }
.legend .status-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: 0.4rem;
}
.legend .badge-rot { background: var(--rot-bg); color: var(--rot-text); }
.legend .badge-gelb { background: var(--gelb-bg); color: var(--gelb-text); }
.legend .badge-gruen { background: var(--gruen-bg); color: var(--gruen-text); }

footer { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding-bottom: 2rem; }
footer a { color: var(--accent); }

@media (max-width: 640px) {
  .app { padding: 1.25rem 1rem 3rem; }
  .panel { padding: 1rem; }
  .app-header { flex-direction: column; align-items: flex-start; position: static; }
}
