:root {
  --g:      #2ca982;
  --gd:     #1f7f63;
  --mint:   #e9f7f3;
  --ink:    #17322c;
  --muted:  #62716d;
  --line:   #dce8e4;
  --soft:   #f6faf8;
  --warn:   #f0a33a;
  --err:    #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fff 0%, #f8fbfa 100%);
}

a { color: inherit; }

/* ── HEADER ─────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.app-header-inner {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 68px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 110px; height: auto; }
.brand-sub { font-size: 13px; color: var(--muted); }

/* ── NAV ────────────────────────────────────────────────── */
.app-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.app-nav a {
  min-height: 38px; display: inline-flex; align-items: center;
  padding: 0 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none;
  transition: background .15s, color .15s;
}
.app-nav a:hover, .app-nav a.active {
  background: var(--mint); color: var(--gd);
}
.app-nav a.nav-labor {
  background: var(--g); color: #fff; border-radius: 6px;
}
.app-nav a.nav-labor:hover { background: var(--gd); }

/* ── MAIN ───────────────────────────────────────────────── */
.main {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: clamp(26px, 4vw, 40px); line-height: 1.1; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.eyebrow { color: var(--gd); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }

/* ── CARDS / PANELS ─────────────────────────────────────── */
.card, .panel, .form-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 8px 24px rgba(23,50,44,.06);
  padding: clamp(16px,3vw,28px);
}

/* ── KPI GRID ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px; margin-bottom: 24px;
}
.kpi-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; padding: 18px;
  box-shadow: 0 4px 16px rgba(23,50,44,.05);
}
.kpi-card .kpi-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi-card .kpi-value { display: block; margin-top: 8px; font-size: 34px; font-weight: 820; color: var(--gd); line-height: 1; }
.kpi-card .kpi-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* ── DASHBOARD GRID ─────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dash-grid .span2 { grid-column: span 2; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 18px; border-radius: 6px; border: 1px solid transparent;
  font: inherit; font-weight: 780; font-size: 15px;
  text-decoration: none; cursor: pointer;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(23,50,44,.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--g); color: #fff; }
.btn-primary:hover { background: var(--gd); }
.btn-secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.btn-ghost { background: var(--mint); color: var(--gd); }
.btn-danger { background: var(--err); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 750; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; border: 1px solid #ceded9; border-radius: 8px;
  padding: 10px 12px; font: inherit; font-size: 15px; color: var(--ink); background: #fff;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--g); box-shadow: 0 0 0 4px rgba(44,169,130,.14);
}
.field-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── TABLE ──────────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.data-table th { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: var(--soft); cursor: pointer; white-space: nowrap; }
.data-table th:hover { color: var(--gd); }
.data-table tr:hover td { background: var(--soft); }
.data-table td { color: var(--ink); }
.data-table .no-data { text-align: center; color: var(--muted); padding: 32px; }

/* ── BADGES / PILLS ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; min-height: 24px;
  padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800; white-space: nowrap;
}
.badge-green  { background: #d4f5ea; color: #1a6b48; }
.badge-blue   { background: #dceeff; color: #1a4a8a; }
.badge-orange { background: #fff1db; color: #7a4e00; }
.badge-gray   { background: #eef0ef; color: var(--muted); }
.badge-red    { background: #fde8e8; color: #7a1f1f; }

/* ── NOTICE / TOAST ─────────────────────────────────────── */
.notice {
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--soft); color: var(--muted); font-size: 14px; line-height: 1.5;
}
#toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  z-index: 9999; pointer-events: none;
}
.toast {
  min-width: 220px; max-width: 420px; padding: 12px 18px;
  border-radius: 8px; background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 700; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: toast-in .25s ease;
}
.toast.toast-ok  { background: var(--g); }
.toast.toast-err { background: var(--err); }
@keyframes toast-in { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

/* ── FILTER BAR ─────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 16px; background: var(--soft); border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 18px;
}
.filter-bar .field { min-width: 160px; flex: 1; }
.filter-bar .field label { font-size: 12px; }
.filter-bar .field input, .filter-bar .field select {
  min-height: 38px; font-size: 14px;
}

/* ── PAGINATION ─────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.pagination button {
  min-height: 34px; min-width: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; font: inherit; font-size: 13px; cursor: pointer;
}
.pagination button.active { background: var(--g); color: #fff; border-color: var(--g); }
.pagination button:hover:not(.active) { background: var(--soft); }
.page-size-select { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; height: 34px; }

/* ── SCANNER ─────────────────────────────────────────────── */
.scanner-wrap {
  position: relative; overflow: hidden; border-radius: 12px;
  background: #10231f; min-height: 62svh;
  display: grid; place-items: center;
}
.scanner-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: none;
}
.scanner-wrap.active .scanner-video { display: block; }
.scan-box {
  position: relative; z-index: 2;
  width: min(280px, 76vw); aspect-ratio: 1.6;
  border: 4px solid var(--g); border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(16,35,31,.4);
}
.scan-line {
  position: absolute; left: 0; right: 0; height: 3px;
  background: var(--g); box-shadow: 0 0 14px rgba(44,169,130,.8);
  animation: scanline 2.4s ease-in-out infinite;
}
@keyframes scanline { 0%,100%{top:8%} 50%{top:88%} }
.scanner-wrap.active .scan-box { background: transparent; }
.scan-overlay-text {
  position: absolute; z-index: 3; bottom: 18px; left: 16px; right: 16px;
  text-align: center; color: rgba(255,255,255,.9); font-size: 14px; font-weight: 700;
}
.scanner-wrap:not(.active) { background: var(--soft); border: 2px dashed rgba(44,169,130,.4); }
.scanner-wrap:not(.active) .scan-box { background: rgba(255,255,255,.6); }
.scan-success .scan-box { border-color: #15c27a !important; animation: pulse .5s ease; }
@keyframes pulse { 0%{transform:scale(.94)} 60%{transform:scale(1.04)} 100%{transform:scale(1)} }

/* ── ART-TOGGLE (Labor Eingabe) ──────────────────────────── */
.art-group { margin-bottom: 8px; }
.art-group-title {
  font-size: 12px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; padding: 10px 0 6px;
}
.art-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; margin-bottom: 6px;
}
.art-name { font-size: 15px; font-weight: 600; flex: 1; }
.art-toggle-group { display: flex; gap: 4px; }
.art-toggle-btn {
  min-width: 36px; min-height: 36px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-size: 18px; cursor: pointer; line-height: 1;
  transition: background .12s, border-color .12s;
}
.art-toggle-btn.sel-yes  { background: #d4f5ea; border-color: #2ca982; }
.art-toggle-btn.sel-no   { background: #fde8e8; border-color: #c0392b; }
.art-toggle-btn.sel-skip { background: #eef0ef; border-color: #b0bbb8; }
.art-custom-row { display: flex; gap: 8px; margin-top: 8px; }
.art-custom-row input { flex: 1; }

/* ── PROBE INFO CARD (Labor Detail) ──────────────────────── */
.probe-info {
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; overflow: hidden; margin-bottom: 16px;
}
.probe-info-head {
  padding: 14px 18px; background: var(--mint);
  border-bottom: 1px solid var(--line);
}
.probe-info-head .probe-id { font-size: 20px; font-weight: 820; color: var(--gd); font-family: ui-monospace, monospace; }
.probe-info-head .probe-type { font-size: 14px; color: var(--gd); margin-top: 2px; }
.probe-info-body { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; padding: 14px 18px; }
.probe-info-body dt { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.probe-info-body dd { margin: 0; font-size: 14px; color: var(--ink); }
.target-highlight {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: #fffbe6; border: 1px solid #f0d060; color: #7a5500;
  font-size: 13px; font-weight: 700;
}

/* ── MATRIX TABLE ────────────────────────────────────────── */
.matrix-wrap { overflow-x: auto; }
.matrix-table { border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.matrix-table th, .matrix-table td { padding: 8px 10px; border: 1px solid var(--line); text-align: center; }
.matrix-table th { background: var(--soft); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.matrix-table .art-col { text-align: left; font-weight: 600; white-space: normal; min-width: 140px; }
.matrix-table .gruppe-sep td { background: var(--mint); font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--gd); }
.matrix-table .cell-yes  { background: #d4f5ea; color: #1a6b48; font-weight: 800; }
.matrix-table .cell-no   { background: #fde8e8; color: #7a1f1f; }
.matrix-table .cell-none { background: #f5f5f5; color: #aaa; }

/* ── MAP ─────────────────────────────────────────────────── */
#map { width: 100%; height: 520px; border-radius: 10px; z-index: 0; }
.map-filter { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

/* ── ENTNAHMESTELLEN LIST ────────────────────────────────── */
.stelle-list { display: grid; gap: 14px; }
.stelle-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px;
  background: #fff; display: grid; grid-template-columns: 1fr auto; gap: 12px;
}
.stelle-card h3 { margin: 0 0 4px; font-size: 17px; }
.stelle-card p  { margin: 0; font-size: 14px; color: var(--muted); }
.stelle-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.stelle-card .card-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

/* ── MOBILE-ONLY PAGES ───────────────────────────────────── */
.mobile-page {
  max-width: 520px; margin: 0 auto;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
}
.mobile-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.mobile-header .back-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 22px; cursor: pointer; text-decoration: none; color: var(--ink);
  flex: 0 0 auto;
}
.mobile-header h1 { margin: 0; font-size: 18px; flex: 1; }

/* ── FOOTER ──────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); background: #fff; margin-top: auto; }
.footer-inner {
  width: min(1200px, calc(100% - 32px)); margin: 0 auto;
  padding: 20px 0; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; color: var(--muted); font-size: 13px;
}

/* ── UTILS ───────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-green { color: var(--gd); }
.text-small { font-size: 13px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.section-title { font-size: 18px; font-weight: 800; margin: 0 0 14px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .span2 { grid-column: span 1; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card .kpi-value { font-size: 26px; }
  .app-nav { display: none; }
  .main { width: 100%; padding: 14px 12px 48px; }
  #map { height: 360px; }
  .stelle-card { grid-template-columns: 1fr; }
}
