:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0d9488;
  --accent-dark: #0f766e;
  --accent-soft: #e6f5f3;
  --green: #15803d;
  --red: #b91c1c;
  --amber: #b45309;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.logo span { color: var(--accent); }
nav { display: flex; gap: 4px; margin-left: 12px; }
nav button {
  background: none; border: none; padding: 8px 14px; font-size: 14px;
  color: var(--muted); cursor: pointer; border-radius: 8px; font-weight: 600;
}
nav button.on { background: var(--accent-soft); color: var(--accent-dark); }
.spacer { flex: 1; }
.crawl-info { font-size: 13px; color: var(--muted); }

.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: none; color: var(--accent-dark); border: 1px solid var(--line); }
.btn.ghost:hover { background: #eef4f5; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--red); }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.tab { display: none; }
.tab.on { display: block; }

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px;
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.hl .num { color: var(--accent); }

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center;
}
.filters input[type=search], .filters select, input[type=text], input[type=password],
textarea, select {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  font-size: 14px; font-family: inherit; background: var(--card); color: var(--ink);
}
.filters input[type=search] { min-width: 220px; }
.filters label.chk, .form-grid label.chk { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; font-weight: 400; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.contents { display: contents; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 11px; border-bottom: 1px solid var(--line); }
.badge { white-space: nowrap; }

/* Stellen-Tabelle: festes Raster — verteilt sich immer auf 100 %, nichts wird abgeschnitten */
#tab-jobs table { table-layout: fixed; }
#tab-jobs th:nth-child(1) { width: 30%; }
#tab-jobs th:nth-child(2) { width: 17%; }
#tab-jobs th:nth-child(3) { width: 12%; }
#tab-jobs th:nth-child(4) { width: 12%; }
#tab-jobs th:nth-child(5) { width: 9%; }
#tab-jobs th:nth-child(6) { width: 11%; }
#tab-jobs th:nth-child(7) { width: 9%; }
#tab-jobs td { overflow-wrap: break-word; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafbfc; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafb; }
td .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.datum-erfasst { color: var(--muted); }

.badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px;
  border-radius: 99px; vertical-align: middle;
}
.badge.new { background: #dcfce7; color: var(--green); }
.badge.gone { background: #fee2e2; color: var(--red); }
.badge.err { background: #fee2e2; color: var(--red); }
.badge.ok { background: #dcfce7; color: var(--green); }
.badge.wait { background: #fef3c7; color: var(--amber); }
.badge.off { background: #e2e8f0; color: var(--muted); }
.badge.typ { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; white-space: normal; }
td select.mini { padding: 4px 6px; font-size: 12.5px; border-radius: 6px; max-width: 150px; }

.empty { padding: 46px; text-align: center; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: 180px 1fr; gap: 12px 16px; align-items: center; max-width: 780px; }
.form-grid label { font-size: 14px; font-weight: 600; }
.form-grid .hint { grid-column: 2; font-size: 12.5px; color: var(--muted); margin-top: -6px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 16px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }

/* Dialog */
dialog { border: none; border-radius: 14px; padding: 0; width: min(680px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
.dlg { padding: 24px; }
.dlg h3 { margin: 0 0 16px; }
.dlg .form-grid { max-width: none; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── Statistik ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.chart-sub { margin: -8px 0 16px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.hint-inline { font-size: 12.5px; color: var(--muted); }

#karte { height: 300px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.dist { font-size: 12px; color: var(--muted); white-space: nowrap; }

.segbar { display: inline-flex; background: #eef2f5; border-radius: 8px; padding: 3px; gap: 2px; }
.segbar button {
  border: none; background: none; padding: 6px 13px; border-radius: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.segbar button.on { background: var(--card); color: var(--accent-dark); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.key.arzt { background: #2a78d6; }
.key.pflege { background: #eb6834; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-stack { display: flex; height: 18px; gap: 2px; }
.bar-stack .seg { height: 18px; min-width: 2px; background: var(--accent); }
.bar-stack .seg.arzt { background: #2a78d6; }
.bar-stack .seg.pflege { background: #eb6834; }
.bar-stack .seg:last-child { border-radius: 0 4px 4px 0; }
.bar-row { display: grid; grid-template-columns: 185px 1fr auto; align-items: center; gap: 10px; }
.bar-row .bar-label {
  font-size: 12.5px; line-height: 1.3; color: var(--ink); text-align: right;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bar-track { background: #f1f5f9; border-radius: 3px; height: 18px; position: relative; }
.bar-fill {
  height: 18px; background: var(--accent);
  border-radius: 0 4px 4px 0; min-width: 3px; transition: width .35s ease;
}
.bar-row .bar-val { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); min-width: 42px; }
.bar-row .bar-val small { color: var(--muted); }
.bar-row:hover .bar-fill { filter: brightness(1.12); }
.bar-fill.ord1 { background: #8ad0c8; } .bar-fill.ord2 { background: #4fb5aa; }
.bar-fill.ord3 { background: #0d9488; } .bar-fill.ord4 { background: #0b6e65; }
.bar-fill.ord5 { background: #074a44; }

.viz-tip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0;
  background: var(--ink); color: #fff; font-size: 12.5px; line-height: 1.5;
  padding: 7px 10px; border-radius: 8px; max-width: 260px; transition: opacity .12s;
}
.viz-tip.show { opacity: 1; }
.viz-tip b { font-weight: 600; }

.trend-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-area { fill: var(--accent); opacity: .10; }
.trend-grid { stroke: var(--line); stroke-width: 1; }
.trend-axis { font-size: 11.5px; fill: var(--muted); }
.trend-dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }

.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.pill.hoch { background: #fee2e2; color: var(--red); }
.pill.mittel { background: #fef3c7; color: var(--amber); }
.pill.tief { background: #f1f5f9; color: var(--muted); }

@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }

.progress { font-size: 13px; color: var(--accent-dark); font-weight: 600; }
.pulse::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 7px; animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 36px; width: 340px; }
.login-box h1 { font-size: 19px; margin: 0 0 18px; }
.login-box input { width: 100%; margin-bottom: 12px; }
.login-box .btn { width: 100%; }
.login-err { color: var(--red); font-size: 13.5px; margin-bottom: 10px; display: none; }

@media (max-width: 800px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .hint { grid-column: 1; }
  header { flex-wrap: wrap; height: auto; padding: 10px 14px; }
  main { padding: 14px; }
}
