/* ---------- Design tokens ---------- */
:root {
  /* Farbkonzept angelehnt an katadyngroup.com */
  --brand-navy: #012169;
  --brand-navy-dark: #00184d;
  --brand-blue: #94b5e0;
  --brand-blue-light: #dfe9f6;
  --brand-blue-lighter: #f2f6fc;
  --brand-orange: #ef8200;
  --brand-orange-light: #fdf1e3;

  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e3e3e3;
  --border-strong: #d6d6d6;
  --text: #141414;
  --text-2: #4c4c4d;
  --text-3: #767676;
  --accent: var(--brand-navy);
  --accent-hover: var(--brand-navy-dark);
  --accent-soft: var(--brand-blue-light);
  --focus: var(--brand-blue);
  --sidebar: var(--brand-navy);
  --sidebar-text: #c9d6ec;
  --sidebar-active: rgba(255, 255, 255, .10);
  --sidebar-line: rgba(255, 255, 255, .14);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(1, 33, 105, .05), 0 1px 3px rgba(1, 33, 105, .06);

  /* Status-Farben: Marke für neutrale/aktive Zustände, Ampel nur wo semantisch nötig */
  --tone-neutral: #4c4c4d;  --tone-neutral-bg: #ececec;
  --tone-info: #1d4f91;     --tone-info-bg: var(--brand-blue-light);
  --tone-muted: #636363;    --tone-muted-bg: #f0f0f0;
  --tone-warning: #9a5200;  --tone-warning-bg: var(--brand-orange-light);
  --tone-success: #1e6b3a;  --tone-success-bg: #e2f2e7;
  --tone-danger: #a8231f;   --tone-danger-bg: #fbe5e4;
  --tone-won: #ffffff;      --tone-won-bg: var(--brand-navy);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 13px; font-weight: 600; margin: 16px 0 6px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hint { color: var(--text-3); font-size: 12px; margin: 12px 0 0; }
.empty { color: var(--text-3); text-align: center; padding: 24px 8px; margin: 0; list-style: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-text);
  padding: 20px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: #fff; color: var(--brand-navy); font-weight: 700; font-size: 13px;
}
.brand-name { font-weight: 650; font-size: 15px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500;
}
.nav-link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand-orange); }
.nav-badge {
  margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px;
  background: var(--sidebar-line); color: #fff; font-size: 11px; font-weight: 600; text-align: center; line-height: 20px;
}
.nav-link.active .nav-badge { background: var(--brand-blue); color: var(--brand-navy); }
.sidebar-footer {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 0; border-top: 1px solid var(--sidebar-line);
}
.sidebar-footer form { margin: 0; }
.sidebar .icon-button { color: var(--sidebar-text); }
.sidebar .icon-button:hover { background: var(--sidebar-active); color: #fff; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 6px; margin: -4px -6px; border-radius: var(--radius-sm); }
.user:hover, .user.active { background: var(--sidebar-active); text-decoration: none; }
.user.active .avatar { box-shadow: 0 0 0 2px var(--brand-orange); }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.avatar {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-blue-light); color: var(--brand-navy); font-weight: 600; font-size: 12px;
}
.main { padding: 28px 32px 48px; min-width: 0; max-width: 1440px; }

/* ---------- Generic components ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.count { font-size: 12px; font-weight: 500; color: var(--text-2); background: var(--tone-neutral-bg); border-radius: 999px; padding: 0 8px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-header p { margin: 4px 0 0; }
.header-meta { display: flex; gap: 8px; }
.count-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; color: var(--text-2); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > .card { margin-bottom: 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.button:hover { background: var(--surface-2); text-decoration: none; }
.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-hover); }
.button-ghost { background: transparent; }
.button-starred { background: var(--brand-orange-light); border-color: #f5c27f; color: var(--tone-warning); }
.button-starred .icon { fill: var(--brand-orange); stroke: var(--brand-orange); }
.button-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.button-block { width: 100%; }
.icon-button {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-button:hover { background: var(--tone-neutral-bg); color: var(--text); }
.star.is-active { color: var(--brand-orange); }
.star.is-active .icon { fill: var(--brand-orange); }

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; height: 36px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  font: inherit; color: var(--text);
}
textarea { height: auto; padding: 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=file] { font: inherit; font-size: 13px; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span:first-child { font-size: 12px; font-weight: 500; color: var(--text-2); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--tone-c, var(--tone-neutral)); background: var(--tone-bg, var(--tone-neutral-bg));
}
.chip {
  display: inline-block; padding: 1px 8px; margin: 1px 4px 1px 0; border-radius: 6px;
  background: var(--accent-soft); color: var(--brand-navy); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip-soft { background: var(--tone-neutral-bg); color: var(--text-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--tone-solid, var(--tone-c)); margin-right: 8px; }

.tone-neutral { --tone-c: var(--tone-neutral); --tone-bg: var(--tone-neutral-bg); }
.tone-info { --tone-c: var(--tone-info); --tone-bg: var(--tone-info-bg); }
.tone-muted { --tone-c: var(--tone-muted); --tone-bg: var(--tone-muted-bg); }
.tone-warning { --tone-c: var(--tone-warning); --tone-bg: var(--tone-warning-bg); }
.tone-success { --tone-c: var(--tone-success); --tone-bg: var(--tone-success-bg); }
.tone-danger { --tone-c: var(--tone-danger); --tone-bg: var(--tone-danger-bg); }
.tone-danger-soft { --tone-c: var(--tone-danger); --tone-bg: #f6eded; }
.tone-won { --tone-c: var(--tone-won); --tone-bg: var(--tone-won-bg); --tone-solid: var(--tone-won-bg); }
.tone-accent { --tone-c: var(--accent); --tone-bg: var(--accent-soft); }

.fit {
  display: inline-grid; place-items: center; min-width: 38px; height: 26px; padding: 0 8px; border-radius: 7px;
  font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums;
}
.fit-high { background: var(--tone-success-bg); color: var(--tone-success); }
.fit-mid { background: var(--tone-warning-bg); color: var(--tone-warning); }
.fit-low { background: var(--tone-danger-bg); color: var(--tone-danger); }
.fit-none { background: var(--tone-neutral-bg); color: var(--text-3); }

.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.message { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.message-success { background: var(--tone-success-bg); border-color: #b9dcc4; color: var(--tone-success); }
.message-info { background: var(--brand-blue-lighter); border-color: var(--brand-blue); color: var(--brand-navy); }
.message-error, .message-warning { background: var(--tone-danger-bg); border-color: #f0bcb9; color: var(--tone-danger); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 0%, var(--brand-blue-light), transparent 50%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; padding: 32px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .muted { margin-bottom: 20px; }
.brand-auth { padding: 0 0 24px; color: var(--text); }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { display: flex; flex-direction: column; gap: 6px; margin: 0; color: var(--text); transition: border-color .15s; }
.kpi:hover { text-decoration: none; border-color: var(--brand-blue); }
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bar-row {
  display: grid; grid-template-columns: 160px 1fr 44px; align-items: center; gap: 12px;
  padding: 6px 8px; margin: 0 -8px; border-radius: var(--radius-sm); color: var(--text);
}
.bar-row:hover { background: var(--surface-2); text-decoration: none; }
.bar-label { display: flex; align-items: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 999px; background: var(--tone-neutral-bg); overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 2px; border-radius: 999px; background: var(--tone-solid, var(--tone-c)); }
.bar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 8px; margin: 0 -8px; border-radius: var(--radius-sm); color: var(--text);
}
.list li + li .list-row { border-top: 1px solid var(--border); border-radius: 0; }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list-meta { color: var(--text-2); font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }

/* ---------- Lists ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.filters .field { min-width: 150px; }
.filters .field-grow { flex: 1 1 240px; }
.input-icon { position: relative; display: block; }
.input-icon .icon { position: absolute; left: 10px; top: 10px; color: var(--text-3); }
.input-icon input { padding-left: 32px; }
.range { display: flex; align-items: center; gap: 6px; }
.range input { width: 72px; }
.filter-actions { display: flex; gap: 8px; }
.form-errors { flex-basis: 100%; color: var(--tone-danger); font-size: 13px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2);
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th.sortable a { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.table th.sortable a:hover { color: var(--accent); text-decoration: none; }
.table th.is-sorted { color: var(--accent); }
.sort-indicator { font-size: 9px; color: var(--text-3); }
.table th.sortable a:hover .sort-indicator, .table th.is-sorted .sort-indicator { color: var(--brand-orange); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--brand-blue-lighter); }
.col-fit { width: 56px; white-space: nowrap; }
.fit-pair { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 3px; white-space: nowrap; }
.fit-pair .fit { min-width: 30px; padding: 0 6px; }
.fit-sep { color: var(--text-3); font-weight: 600; }
.col-number { width: 72px; }
.tender-no {
  display: inline-block; padding: 1px 7px; border-radius: 6px; white-space: nowrap;
  font: 600 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums;
  color: var(--brand-navy); background: var(--brand-blue-light);
}
button.tender-no { border: 0; cursor: copy; }
button.tender-no:hover { background: var(--brand-blue); }
.tender-no.is-copied::after { content: " ✓ kopiert"; font-family: inherit; font-weight: 500; }
.col-title { min-width: 280px; max-width: 520px; }
.col-procurer { max-width: 220px; color: var(--text-2); }
.col-actions { width: 80px; white-space: nowrap; text-align: right; }
.col-actions form { display: inline; margin: 0; }
.title-link { color: var(--text); font-weight: 550; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sub { display: block; color: var(--text-3); font-size: 12px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px; border-top: 1px solid var(--border); }

/* ---------- Detail ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; margin-bottom: 14px; }
.detail-header { display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; }
.detail-header h1 { margin: 10px 0 6px; font-size: 24px; }
.detail-header p { margin: 0; }
.detail-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.detail-head-actions { display: flex; align-items: flex-start; gap: 8px; }
.detail-head-actions form { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.watch-meta { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.status-bar {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-top: 16px; border-top: 1px solid var(--border);
}
.status-bar form { margin: 0; }
.status-bar-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-right: 4px; }
.status-button { color: var(--tone-c); background: var(--tone-bg); border-color: transparent; }
.status-button:hover { background: var(--tone-bg); filter: brightness(.96); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.detail-aside { position: sticky; top: 20px; }
.version-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 20px; border-radius: var(--radius); background: var(--brand-blue-lighter); border: 1px solid var(--brand-blue-light);
}
.lang-switch { display: flex; align-items: center; gap: 8px; margin: 0; }
.lang-switch label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.lang-switch select { width: auto; height: 32px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.fact { padding: 12px 14px; box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border); }
.fact dt { font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.fact dd { margin: 0; font-weight: 550; word-break: break-word; }
.fact-highlight { background: var(--brand-orange-light); }
.links { display: flex; flex-direction: column; gap: 2px; font-weight: 500; }
.prose { color: var(--text); max-width: 80ch; }
.prose p { margin: 0 0 10px; }
.cpv { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.cpv li { display: flex; align-items: baseline; gap: 8px; }
.cpv code { flex: none; }
.cpv-label { min-width: 0; }
.criteria { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.criteria li span + span { margin-left: 12px; }
.lots { display: flex; flex-direction: column; gap: 8px; }
.lot { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.lot summary { cursor: pointer; font-weight: 550; }
.lot[open] summary { margin-bottom: 8px; }
.lot-id { display: inline-block; min-width: 28px; padding: 0 6px; margin-right: 6px; border-radius: 6px; background: var(--tone-neutral-bg); color: var(--text-2); font-size: 12px; text-align: center; }

.files { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.files a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.files-inline { flex-direction: row; flex-wrap: wrap; margin: 6px 0 0; }
.files-inline li { padding: 4px 8px; }
.upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; border: 1px dashed var(--brand-blue); border-radius: var(--radius-sm); background: var(--brand-blue-lighter); margin: 0; }
.upload input[type=file] { flex: 1; }

.comment-form { margin-bottom: 18px; }
.ai-usage { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 8px 0 0; padding: 0; border: 0; }
.ai-usage[hidden] { display: none; }
.ai-usage legend { float: left; margin-right: 6px; padding: 0; font-size: 12px; font-weight: 600; color: var(--text-2); }
.ai-usage label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.file-name { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.file-name a { overflow-wrap: anywhere; }
.badge .icon { width: 12px; height: 12px; }
.comment-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.file-label { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.comments { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 16px; }
.comment { display: flex; gap: 12px; }
.comment-body { flex: 1; min-width: 0; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) var(--radius); }
.comment-meta { margin-bottom: 4px; }
.comment-body .prose p:last-child { margin-bottom: 0; }

.timeline, .history { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before, .history::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li, .history li { position: relative; padding-left: 22px; }
.timeline li::before, .history li::before {
  content: ""; position: absolute; left: 1px; top: 10px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline li.is-current::before, .history li.is-current::before { border-color: var(--accent); background: var(--accent); }
.timeline-item { display: flex; flex-direction: column; padding: 6px 10px; margin-bottom: 4px; border-radius: var(--radius-sm); color: var(--text); }
.timeline-item:hover { background: var(--surface-2); text-decoration: none; }
.timeline li.is-current .timeline-item { background: var(--accent-soft); }
.timeline-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.history { max-height: 420px; overflow-y: auto; }
.history li { display: flex; flex-direction: column; padding-top: 6px; padding-bottom: 8px; }
.history-action { font-weight: 550; }
.history-details { color: var(--text-2); font-size: 13px; }
.history .empty { padding-left: 0; }
.history .empty::before { display: none; }

/* ---------- Portfolio (Markdown) ---------- */
.markdown-editor { font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 360px; }
.portfolio-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.portfolio-actions .buttons { display: flex; gap: 8px; }
.markdown { max-width: 80ch; color: var(--text); }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 1.4em 0 .5em; color: var(--brand-navy); text-transform: none; letter-spacing: 0; display: block; }
.markdown h1 { font-size: 20px; }
.markdown h2 { font-size: 17px; }
.markdown h3 { font-size: 15px; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown table, .markdown pre { margin: 0 0 12px; }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown li + li { margin-top: 3px; }
.markdown blockquote { padding: 4px 14px; border-left: 3px solid var(--brand-blue); color: var(--text-2); }
.markdown pre { padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow-x: auto; }
.markdown pre code { border: 0; padding: 0; background: none; }
.markdown table { border-collapse: collapse; display: block; max-width: 100%; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.markdown th { background: var(--surface-2); }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.preview-label { margin: 0 0 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-aside { position: static; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; }
  .brand { padding: 0; }
  .brand-name, .user-name { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
  .nav-link { padding: 8px 10px; white-space: nowrap; }
  .nav-link.active { box-shadow: none; }
  .sidebar-footer { margin: 0; padding: 0; border: 0; gap: 4px; }
  .main { padding: 20px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-header { grid-template-columns: minmax(0, 1fr); }
  .detail-head-actions { flex-wrap: wrap; }
  .page-header { flex-wrap: wrap; align-items: flex-start; }
  .bar-row { grid-template-columns: 110px 1fr 36px; }
}
@media (max-width: 560px) {
  .nav-link span:not(.nav-badge) { display: none; }
  /* sechs Menüpunkte (mit Logs) passen so ohne Scrollen auf 375 px */
  .nav-link { padding: 8px 7px; }
}

/* ---------- Einstellungen: CPV-Codes & Keywords ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px;
  color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--brand-orange); }
.rule-form-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.rule-form-grid .field-key { flex: 0 1 220px; }
.rule-form-grid .field-grow { flex: 1 1 240px; }
.rule-form-grid .field-narrow { flex: 0 1 200px; }
.rule-form-actions { display: flex; gap: 8px; margin-top: 16px; }
.rule-form .form-errors { margin-top: 10px; display: flex; flex-direction: column; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; height: 36px; color: var(--text-2); font-weight: 500; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface-2); }
.segment { position: relative; cursor: pointer; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span { display: inline-flex; align-items: center; height: 28px; padding: 0 14px; border-radius: var(--radius-pill); color: var(--text-2); font-weight: 500; }
.segment input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.segment-include input:checked + span { background: var(--tone-success-bg); color: var(--tone-success); }
.segment-exclude input:checked + span { background: var(--tone-danger-bg); color: var(--tone-danger); }
.rule-column-header { padding: 14px 16px; margin: 0; border-bottom: 1px solid var(--border); }
.rule-column-include { box-shadow: var(--shadow), inset 0 3px 0 var(--tone-success); }
.rule-column-exclude { box-shadow: var(--shadow), inset 0 3px 0 var(--tone-danger); }
.rule-table td { padding: 8px 14px; }
.rule-table .col-actions { width: 120px; }
.rule-table tr.is-inactive td:not(.col-actions) { opacity: .55; }
.rule-table tr:hover td { background: var(--surface-2); }
.icon-button-danger:hover { background: var(--tone-danger-bg); color: var(--tone-danger); }
.rule-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 0 20px; }
.rule-table .icon-button { width: 28px; height: 28px; }
.rule-table .sub { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.rule-table .sub .badge { padding: 0 7px; font-size: 11px; }
.rule-table .sub .icon { width: 12px; height: 12px; }
.translate-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 20px; align-items: start; }
.translate-form fieldset { border: 0; padding: 0; margin: 0; }
.translate-form legend { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 16px; max-height: 360px; overflow-y: auto; }
.checkbox-list .checkbox { height: 30px; }
.legend-row { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.legend-actions { display: flex; gap: 10px; }
.link-button { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 500; color: var(--accent); cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.hint-list { margin: 14px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.chip-exclude { background: var(--tone-danger-bg); color: var(--tone-danger); }
.button:disabled { opacity: .6; cursor: default; }
@media (max-width: 900px) { .translate-grid { grid-template-columns: minmax(0, 1fr); } }

/* Fit-Analyse (Detailansicht) */
a.fit:hover { text-decoration: none; filter: brightness(.96); }
.fit-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.fit-toggle::-webkit-details-marker { display: none; }
.fit-toggle h2 { white-space: nowrap; }
.fit-toggle-label { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 560px) { .fit-toggle-label .when-closed, .fit-toggle-label .when-open { display: none !important; } }
.fit-toggle:hover .fit-toggle-label { color: var(--accent); }
.fit-toggle .chevron { transition: transform .15s; }
.fit-analysis[open] .fit-toggle .chevron { transform: rotate(180deg); }
.fit-analysis .when-open, .fit-analysis[open] .when-closed { display: none; }
.fit-analysis[open] .when-open { display: inline; }
.fit-details { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.fit-meta { margin: 0 0 8px; }
.fit-summary { margin: 0 0 16px; }
.subscores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.subscore-head {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr 36px 72px; align-items: center; gap: 12px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; list-style: none;
}
.subscore-head::-webkit-details-marker { display: none; }
.subscore-head:hover { background: var(--surface-2); }
.subscore-head .badge { justify-self: start; }
.subscore-body { padding: 4px 8px 12px; border-left: 2px solid var(--border); margin: 0 0 8px 8px; }
.subscore-body p { margin: 0 0 8px; }
.subscore-body h4 { margin: 8px 0 4px; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.subscore-body ul, .open-questions, .requirements ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.evidence .chip { margin-right: 4px; }
.requirements { margin-top: 16px; }
.requirements summary { cursor: pointer; font-weight: 550; margin-bottom: 8px; }
@media (max-width: 640px) {
  .subscore-head { grid-template-columns: 1fr 36px; }
  .subscore-head .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .subscore-head .badge { display: none; }
}

/* Einstellungen → Fit-Score */
.weights-table td, .weights-table th { vertical-align: middle; }
.col-weight { width: 130px; text-align: right; white-space: nowrap; }
.weight-input { width: 72px; text-align: right; }
.weight-sum { font-weight: 600; font-variant-numeric: tabular-nums; }
.weight-sum.is-invalid { color: var(--tone-danger); }

/* Fit pro Los */
.fit-sm { height: 20px; min-width: 0; padding: 0 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.lot summary .fit-sm { margin-left: 6px; vertical-align: middle; }
.fit-lots-title { margin-top: 20px; }
.fit-lots { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.fit-lot-head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; list-style: none;
}
.fit-lot-head::-webkit-details-marker { display: none; }
.fit-lot-head:hover { background: var(--surface-2); }
.fit-lot-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fit-lot[open] .fit-lot-title { white-space: normal; }
.lot-subscores { list-style: none !important; padding-left: 0 !important; gap: 6px !important; margin-bottom: 4px !important; }
.lot-subscore { display: grid; grid-template-columns: minmax(150px, 220px) 1fr 36px 72px; align-items: center; gap: 4px 12px; }
.lot-subscore .badge { justify-self: start; }
.lot-subscore-reason { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .lot-subscore { grid-template-columns: 1fr 36px; }
  .lot-subscore .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .lot-subscore .badge { display: none; }
}

/* Deep-Analyse */
.deep-analysis .fit-toggle .badge { white-space: nowrap; }
.deep-start { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.deep-start p { margin: 0; flex: 1; }
.deep-start .icon { vertical-align: -2px; }
@media (max-width: 640px) { .deep-start { flex-direction: column; align-items: stretch; } }
.deep-analysis h3 { margin-top: 24px; display: flex; align-items: center; gap: 6px; }
.deep-analysis h4 { margin: 12px 0 4px; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.deep-block { padding: 4px 8px 12px; }
.deep-block ul, .deep-list, .deep-changes ul, .deep-table ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.deep-list li .sub, .deep-table .sub { display: block; }
.facts-compact { margin: 8px 0; }
.deep-table td { vertical-align: top; }
.deep-contacts { margin-top: 0; }
.deep-contact + .deep-contact { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.deep-contact p { margin: 0 0 2px; overflow-wrap: anywhere; }
.deep-changes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.deep-changes > li { padding-left: 12px; border-left: 2px solid var(--border); }
.deep-changes p { margin: 4px 0; }
.deep-documents { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.deep-documents summary .badge { margin-left: 6px; }
.deep-translation { max-height: 600px; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.deep-analysis .message { margin: 8px 0; }

/* ---------- Logs ---------- */
.log-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; margin-bottom: 20px; }
.log-service { margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.log-service .card-header { margin-bottom: 0; }
.log-service h2 { overflow-wrap: anywhere; }
.log-service h2 a { color: inherit; }
.log-service-latest { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; }
.log-service-latest .icon { width: 14px; height: 14px; }
.log-days { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.log-days .chip { margin: 0; font-variant-numeric: tabular-nums; }
.log-days .chip:hover { text-decoration: none; background: var(--brand-blue); }
.log-dashboard-header { padding: 18px 20px 0; align-items: flex-start; flex-wrap: wrap; }
.log-dashboard-header p { margin: 4px 0 0; }
.log-dashboard-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.log-files .log-hour th { background: var(--surface-2); color: var(--text-2); font-size: 12px; text-align: left; }
.log-files .icon { width: 16px; height: 16px; }
.log-file-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.log-level-counts { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.log-level-counts .badge:hover { text-decoration: none; filter: brightness(.95); }
.log-summary { margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.log-entries { margin: 0; padding: 0; list-style: none; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.log-entry {
  display: grid; grid-template-columns: max-content 76px minmax(0, 1fr); gap: 10px; align-items: baseline;
  padding: 5px 16px; border-bottom: 1px solid var(--border); border-left: 3px solid transparent;
}
.log-entry:last-child { border-bottom: 0; }
.log-entry .badge { font-family: inherit; font-size: 11px; justify-content: center; }
.log-warning { border-left-color: var(--tone-warning); background: color-mix(in srgb, var(--tone-warning-bg) 40%, transparent); }
.log-danger { border-left-color: var(--tone-danger); background: color-mix(in srgb, var(--tone-danger-bg) 55%, transparent); }
.log-muted { color: var(--text-2); }
.log-time { color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-body { min-width: 0; overflow-wrap: anywhere; }
.log-message { white-space: pre-wrap; }
.log-logger { color: var(--brand-navy); font-weight: 600; margin-right: 6px; }
.log-body .chip { font-family: inherit; }
.log-extra { margin: 4px 0 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow-x: auto; white-space: pre; }
@media (max-width: 640px) {
  .log-entry { grid-template-columns: max-content minmax(0, 1fr); }
  .log-entry .log-body { grid-column: 1 / -1; }
}

/* ---------- Profil ---------- */
.profile-grid { align-items: start; }
.profile-data { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.profile-data dt { color: var(--text-2); font-size: 13px; }
.profile-data dd { margin: 0; overflow-wrap: anywhere; }
.profile-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.profile-form .form-errors { display: flex; flex-direction: column; }
.field-error { color: var(--tone-danger); font-size: 12px; }
.profile-form .hint-list { margin: 0; }

/* Einstellungen → Fit-Score: Schwellwert «Kein Treffer» */
.threshold { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.threshold h3 { margin: 0 0 4px; }
.threshold-field { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; }
.threshold-field input { width: 72px; text-align: right; }
