/* Produktion erfassen — baut auf appTheme.css auf */
:root {
  --pe-ink: var(--app-ink, #12202c);
  --pe-text: var(--app-text, #1a2b38);
  --pe-muted: var(--app-muted, #5b6f7e);
  --pe-line: var(--app-line, rgba(18, 32, 44, 0.12));
  --pe-surface: rgba(255, 255, 255, 0.82);
  --pe-surface-solid: #f7fafb;
  --pe-panel: var(--app-panel, #ffffff);
  --pe-accent: var(--app-accent, #0f766e);
  --pe-accent-soft: var(--app-accent-soft, #ccfbf1);
  --pe-warn: #b45309;
  --pe-ok: var(--app-ok, #047857);
  --pe-danger: var(--app-danger, #b91c1c);
  --pe-radius: var(--app-radius, 14px);
  --pe-input-h: 44px;
  --pe-font: var(--app-font, "Sora", "Segoe UI", sans-serif);
  --pe-mono: var(--app-mono, "JetBrains Mono", ui-monospace, monospace);
  --pe-shadow: var(--app-shadow, 0 10px 30px rgba(18, 32, 44, 0.08));
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--pe-font);
  color: var(--pe-text);
  padding-bottom: 56px;
  min-height: 100vh;
}

.topnav,
.pe-wrap { position: relative; z-index: 1; }

.pe-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 0 8px;
}

.pe-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 6px;
  animation: pe-rise 0.45s ease-out;
}

.pe-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pe-accent);
  font-weight: 600;
}

.pe-title {
  margin: 2px 0 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--pe-ink);
  line-height: 1.15;
}

.pe-bar {
  background: var(--pe-panel);
  border: 1px solid var(--pe-line);
  border-radius: var(--pe-radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--pe-shadow);
  backdrop-filter: blur(8px);
}

.pe-bar-fields { display: flex; flex-wrap: wrap; gap: 10px; }
.pe-bar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.pe-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 150px;
  min-width: 130px;
}
.pe-field span {
  font-size: 11px;
  color: var(--pe-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pe-day-field {
  flex: 0 1 auto;
  min-width: 0;
}
.pe-day-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pe-day-btn {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 8px 12px;
  font-size: 18px;
  line-height: 1;
}
.pe-day-input {
  flex: 0 1 160px;
  min-width: 130px;
  width: auto !important;
}
.pe-day-label {
  font-size: 13px;
  color: var(--pe-muted);
  margin-top: 2px;
}

.pe-field input,
.pe-prod input,
.pe-prod select,
.pe-prod textarea,
.pe-table input,
.pe-table select,
.pe-table textarea {
  width: 100%;
  min-height: var(--pe-input-h);
  padding: 10px 12px;
  border: 1px solid var(--pe-line);
  border-radius: 10px;
  font-size: 16px;
  font-family: var(--pe-font);
  background: #fff;
  color: var(--pe-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pe-field input:focus,
.pe-prod input:focus,
.pe-prod select:focus,
.pe-prod textarea:focus,
.pe-table input:focus,
.pe-table select:focus,
.pe-table textarea:focus {
  outline: none;
  border-color: var(--pe-accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.time-simple,
input[data-field="quantity"],
input[data-field="line_ref"] {
  font-family: var(--pe-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.pe-btn {
  appearance: none;
  border: 1px solid var(--pe-line);
  background: #fff;
  color: var(--pe-text);
  border-radius: 10px;
  min-height: var(--pe-input-h);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--pe-font);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.pe-btn:hover { background: #f3f7f8; border-color: rgba(15, 118, 110, 0.35); }
.pe-btn:active { transform: translateY(1px); }
.pe-btn-primary {
  background: var(--pe-accent);
  border-color: var(--pe-accent);
  color: #fff;
}
.pe-btn-primary:hover { background: #0d9488; border-color: #0d9488; }
.pe-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.pe-mode-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--pe-accent);
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--pe-accent-soft);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.pe-status {
  min-height: 1.25em;
  margin: 10px 4px 4px;
  font-size: 13px;
  color: var(--pe-muted);
  font-weight: 500;
  transition: color 0.2s ease;
}
.pe-status.ok { color: var(--pe-ok); }
.pe-status.err { color: var(--pe-danger); }

.pe-station {
  background: var(--pe-panel);
  border: 1px solid var(--pe-line);
  border-top: none;
  border-radius: 0 0 var(--pe-radius) var(--pe-radius);
  margin-top: 0;
  padding: 14px 14px 18px;
  box-shadow: var(--pe-shadow);
}
.pe-station .pe-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--pe-muted);
}
.pe-empty {
  color: var(--pe-muted);
  font-size: 14px;
  padding: 10px 2px;
  font-weight: 500;
}
.invalid {
  outline: 2px solid #ef4444 !important;
  background: #fef2f2 !important;
}

.pe-remarks { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.pe-remark-row { display: flex; gap: 6px; align-items: flex-start; }
.pe-remark-row textarea { flex: 1 1 auto; min-width: 0; }
.pe-del-remark {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 0 10px !important;
  font-size: 18px !important;
  line-height: 1;
  color: var(--pe-danger);
}
.pe-add-remark,
.pe-add-line {
  align-self: flex-start;
  border-style: dashed !important;
  color: var(--pe-accent) !important;
  background: var(--pe-accent-soft) !important;
  border-color: rgba(15, 118, 110, 0.35) !important;
}

/* Stations-Unterreiter */
.pe-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  margin-top: 14px;
  padding: 4px 2px 0;
  border-bottom: 1px solid var(--pe-line);
}
.pe-tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: none;
  background: rgba(255, 255, 255, 0.45);
  color: var(--pe-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--pe-font);
  padding: 11px 16px;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  min-height: 46px;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.pe-tab:hover { color: var(--pe-ink); background: rgba(255, 255, 255, 0.75); }
.pe-tab .pe-tab-count {
  font-weight: 600;
  font-size: 12px;
  color: inherit;
  opacity: 0.65;
  margin-left: 6px;
}
.pe-tab.active {
  background: var(--pe-panel);
  color: var(--pe-ink);
  border-color: var(--pe-line);
  box-shadow: inset 0 -3px 0 var(--pe-accent);
}
.pe-tab-panel { display: none; }
.pe-tab-panel.active { display: block; animation: pe-fade 0.25s ease; }

/* ——— Handy: Karten ——— */
body.pe-mode-mobile .pe-desktop-only { display: none !important; }
body.pe-mode-mobile .pe-prod {
  border: 1px solid var(--pe-line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, #fff 0%, #f8fbfc 100%);
  box-shadow: 0 4px 14px rgba(18, 32, 44, 0.05);
}
body.pe-mode-mobile .pe-prod:last-child { margin-bottom: 0; }
body.pe-mode-mobile .pe-prod-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--pe-line);
}
body.pe-mode-mobile .pe-prod-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}
body.pe-mode-mobile .pe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
body.pe-mode-mobile .pe-grid .pe-span-2 { grid-column: 1 / -1; }
body.pe-mode-mobile .pe-label {
  display: block;
  font-size: 11px;
  color: var(--pe-muted);
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Strecken Master-Detail (Orientierung Streckenübersicht) */
.pe-stretch {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 0;
  margin-top: 14px;
  border: 1px solid var(--pe-line);
  border-radius: var(--pe-radius);
  background: var(--pe-panel);
  box-shadow: var(--pe-shadow);
  overflow: hidden;
  min-height: 320px;
}
.pe-stretch-nav {
  background: #f3f8f7;
  border-right: 1px solid var(--pe-line);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pe-stretch-nav-head h4 {
  margin: 0;
  font-size: 15px;
  color: var(--pe-ink);
  letter-spacing: -0.02em;
}
.pe-stretch-object {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--pe-line);
}
.pe-stretch-object-name {
  font-weight: 800;
  font-size: 17px;
  line-height: 1.25;
  color: var(--pe-ink);
  letter-spacing: -0.02em;
}
.pe-stretch-object-code {
  margin-top: 2px;
  font-size: 12px;
  color: var(--pe-muted);
  font-weight: 600;
}
.pe-stretch-nav-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--pe-muted);
  line-height: 1.35;
}
.pe-stretch-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
}
.pe-stretch-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--pe-text);
  border-left: 3px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pe-stretch-item:hover { background: rgba(15, 118, 110, 0.08); }
.pe-stretch-item.active {
  background: var(--pe-accent-soft);
  border-left-color: var(--pe-accent);
}
.pe-stretch-item-title {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: var(--pe-ink);
}
.pe-stretch-item-sub {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--pe-muted);
}
.pe-stretch-nav .pe-add-line {
  width: 100%;
  justify-content: center;
}
.pe-stretch-detail {
  padding: 16px 18px 18px;
  background: #fff;
}
.pe-line-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.pe-line-kicker { margin: 0; }
.pe-line-heading {
  margin: 2px 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--pe-ink);
  letter-spacing: -0.02em;
}
.pe-line-section {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--pe-ink);
}
.pe-hint {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--pe-accent-soft);
  color: var(--pe-accent);
  font-size: 12px;
  line-height: 1.4;
}
.pe-btn-danger {
  background: #fff !important;
  border: 1px solid rgba(185, 28, 28, 0.35) !important;
  color: var(--pe-danger) !important;
}
.pe-stretch-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.pe-line-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.pe-line-grid .pe-span-2 { grid-column: 1 / -1; }
.pe-line-grid .pe-label {
  display: block;
  font-size: 11px;
  color: var(--pe-muted);
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

@media (max-width: 820px) {
  .pe-stretch {
    grid-template-columns: 1fr;
  }
  .pe-stretch-nav {
    border-right: none;
    border-bottom: 1px solid var(--pe-line);
  }
  .pe-stretch-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .pe-stretch-item { flex: 1 1 140px; }
}

/* ——— Desktop ——— */
body.pe-mode-desktop .pe-mobile-only { display: none !important; }
body.pe-mode-desktop .pe-wrap { max-width: 1320px; }
body.pe-mode-desktop .pe-hero {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
body.pe-mode-desktop .pe-bar {
  flex: 1 1 auto;
  max-width: 760px;
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
}
body.pe-mode-desktop .pe-bar-actions { flex-shrink: 0; }
body.pe-mode-desktop { --pe-input-h: 36px; }
body.pe-mode-desktop .pe-field input,
body.pe-mode-desktop .pe-table input,
body.pe-mode-desktop .pe-table select,
body.pe-mode-desktop .pe-table textarea,
body.pe-mode-desktop .pe-btn {
  min-height: var(--pe-input-h);
  font-size: 13px;
  border-radius: 8px;
  padding: 6px 10px;
}
body.pe-mode-desktop .pe-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}
body.pe-mode-desktop .pe-table thead th {
  color: var(--pe-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: none;
  padding: 0 8px 4px;
  white-space: nowrap;
}
body.pe-mode-desktop .pe-table tbody tr.pe-prod {
  background: linear-gradient(180deg, #fff 0%, #f8fbfc 100%);
  box-shadow: 0 4px 16px rgba(18, 32, 44, 0.05);
}
body.pe-mode-desktop .pe-table tbody tr.pe-prod td {
  border: solid var(--pe-line);
  border-width: 1px 0;
  padding: 12px 8px;
  vertical-align: top;
  text-align: left;
  font-size: 13px;
  background: transparent;
}
body.pe-mode-desktop .pe-table tbody tr.pe-prod td:first-child {
  border-left-width: 1px;
  border-radius: 12px 0 0 12px;
  padding-left: 14px;
  box-shadow: inset 3px 0 0 var(--pe-accent);
}
body.pe-mode-desktop .pe-table tbody tr.pe-prod td:last-child {
  border-right-width: 1px;
  border-radius: 0 12px 12px 0;
  padding-right: 12px;
}
body.pe-mode-desktop .pe-table .pe-name-col {
  min-width: 160px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--pe-ink);
}
body.pe-mode-desktop .pe-table .pe-name-col .pe-sub {
  margin-top: 3px;
  font-weight: 500;
  font-size: 12px;
  color: var(--pe-muted);
}
body.pe-mode-desktop .pe-table textarea { min-height: 52px; resize: vertical; }
body.pe-mode-desktop .pe-lines-cell { padding-top: 4px; min-width: 320px; }
body.pe-mode-desktop .pe-line {
  border: 1px solid var(--pe-line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: #f2f7f8;
}
body.pe-mode-desktop .pe-line-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--pe-ink);
}
body.pe-mode-desktop .pe-line-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
body.pe-mode-desktop .pe-label {
  display: block;
  font-size: 10px;
  color: var(--pe-muted);
  margin-bottom: 3px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@keyframes pe-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pe-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .pe-hero,
  .pe-tab-panel.active,
  .pe-btn { animation: none; transition: none; }
}

.pe-photo {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.pe-photo-frame {
  position: relative;
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
}
.pe-photo-preview {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--pe-line);
  background: #fff;
  display: block;
}
.pe-del-photo {
  appearance: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  z-index: 2;
}
.pe-del-photo:hover {
  background: #b91c1c;
}
.pe-photo-empty {
  display: none;
}
.pe-photo-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.pe-photo-cam {
  appearance: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--pe-line);
  background: #fff;
  color: var(--pe-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.pe-photo-cam:hover {
  background: var(--pe-accent-soft);
  border-color: rgba(15, 118, 110, 0.35);
}
.pe-photo-cam:active {
  transform: translateY(1px);
}
.pe-photo-cam-icon {
  display: block;
}
