:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667481;
  --line: #d7dde3;
  --surface: #f3f5f7;
  --panel: #ffffff;
  --nav: #17212b;
  --nav-soft: #253240;
  --blue: #255f99;
  --green: #2f7d4f;
  --amber: #a36b16;
  --red: #a23a32;
  --shadow: 0 16px 42px rgba(23, 32, 42, 0.11);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}
button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}
button:disabled { cursor: not-allowed; opacity: 0.55; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: var(--nav);
  color: #f1f5f8;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #e4e9ee;
  color: var(--nav);
  font-weight: 800;
}
.brand strong, .brand span { display: block; }
.brand span, .side-note, .nav-item { color: #b9c4cf; }
.nav-list { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
}
.nav-item.active, .nav-item:hover { background: var(--nav-soft); color: #fff; }
.side-note {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.14);
  padding-top: 18px;
  line-height: 1.45;
}
.side-note span { display: block; color: #fff; font-weight: 700; margin-bottom: 6px; }
.workspace { padding: 28px; min-width: 0; }
.auth-view {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}
.auth-card {
  width: min(920px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}
form {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  padding: 18px;
  background: #fbfcfd;
}
label { display: grid; gap: 6px; }
label span, .search span, .select span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
input, select, textarea {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
}
.form-message { min-height: 22px; color: var(--blue); }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; line-height: 1.15; letter-spacing: 0; }
h2 { margin-bottom: 8px; font-size: 22px; line-height: 1.2; letter-spacing: 0; }
h3 { margin-bottom: 8px; font-size: 15px; letter-spacing: 0; }
.user-box {
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
  box-shadow: var(--shadow);
}
.user-box span, .user-box strong { display: block; }
.user-box span { color: var(--muted); font-size: 12px; }
.text-button {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--blue);
  min-height: auto;
  padding: 0;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.metrics article, .notice, .directory, .profile, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.metrics article { padding: 18px; }
.metrics span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metrics strong { display: block; font-size: 24px; }
.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.notice span { color: var(--muted); }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(370px, 0.75fr);
  gap: 18px;
  align-items: start;
}
.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 190px;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.search, .select { display: grid; gap: 6px; }
.table-wrap { max-height: calc(100vh - 330px); overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th:nth-child(1), td:nth-child(1) { width: 36%; }
th:nth-child(2), td:nth-child(2) { width: 22%; }
th:nth-child(3), td:nth-child(3) { width: 28%; }
th:nth-child(4), td:nth-child(4) { width: 14%; }
th, td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  z-index: 1;
}
td { font-size: 14px; }
.company-row { cursor: pointer; }
.company-row:hover, .company-row.selected { background: #eef4f8; }
.company-main { display: grid; gap: 4px; }
.company-main span, .small { color: var(--muted); font-size: 12px; }
.profile, .panel { padding: 18px; }
.profile-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}
.status-pill.kunde { color: var(--green); background: #edf7f1; border-color: #b9ddc8; }
.status-pill.wettbewerber { color: var(--red); background: #fff0ef; border-color: #efb9b4; }
.status-pill.potenzieller_kunde { color: var(--blue); background: #eef6ff; border-color: #bdd8f2; }
.status-pill.nichtkunde, .status-pill.unklar, .status-pill.neu { color: var(--amber); background: #fff8e8; border-color: #ead295; }
.status-pill.in_pruefung, .status-pill.firma_vorgeschlagen { color: var(--blue); background: #eef6ff; border-color: #bdd8f2; }
.status-pill.processing { color: var(--blue); background: #eef6ff; border-color: #bdd8f2; }
.status-pill.uebernommen, .status-pill.extracted { color: var(--green); background: #edf7f1; border-color: #b9ddc8; }
.status-pill.nicht_relevant, .status-pill.fehler, .status-pill.fetch_error, .status-pill.no_impressum { color: var(--red); background: #fff0ef; border-color: #efb9b4; }
.facts { display: grid; gap: 10px; margin: 0 0 18px; }
.facts div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; overflow-wrap: anywhere; }
.action-panel, .submit-panel, .comments {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}
.import-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 14px;
  margin: 14px 0 6px;
}
.action-panel p, .submit-panel p { color: var(--muted); line-height: 1.45; }
.action-panel { display: grid; gap: 10px; }
.submit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.queue-toolbar {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
}
.queue-actions {
  display: grid;
  grid-template-columns: 180px minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.company-create-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.scout-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 14px;
  margin-top: 14px;
}
.scout-status {
  display: grid;
  gap: 4px;
}
.scout-status span { color: var(--muted); font-size: 13px; }
.scout-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.section-title { display: flex; justify-content: space-between; gap: 12px; }
.section-title span { color: var(--muted); font-size: 12px; }
.comments ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.comments li { border-left: 3px solid var(--blue); padding-left: 10px; }
.comments strong { display: block; font-size: 13px; }
.comments span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.comment-form { display: grid; gap: 8px; margin-top: 12px; }
.edit-comment { justify-self: start; }
.list { display: grid; gap: 10px; margin-top: 14px; }
.audit-title { margin-top: 24px; }
.list-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px;
}
.list-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .nav-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .workspace, .sidebar { padding: 18px; }
  .topbar, .metrics, .toolbar, .nav-list, .notice, .auth-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
  th:nth-child(3), td:nth-child(3) { display: none; }
  .facts div, .submit-row, .queue-toolbar, .queue-actions, .company-create-row { grid-template-columns: 1fr; }
  .scout-actions { display: grid; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .metrics, .notice, .directory, .action-panel, .submit-panel, .comment-form, .edit-comment {
    display: none !important;
  }
  .app-shell, .content-grid {
    display: block;
    min-height: auto;
  }
  .workspace { padding: 0; }
  .profile {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
  .profile-header, .facts div, .comments li {
    break-inside: avoid;
  }
}
