@font-face { font-family: 'ERAG MinervaModern'; src: url('minerva.woff2') format('woff2'); font-display: swap; }
:root {
  --petrol: #1792a9; --petrol-strong: #0f6f80; --petrol-soft: #eaf5f7; --gold: #e2b26e; --gold-soft: #fbf3e4;
  --text: #173e46; --muted: #5a6c70; --line: #d5e1e3; --bg: #f2f5f4; --white: #fff; --warn: #7a4f10; --error: #9b3a2a; --error-soft: #fbeeec;
  --ok: #2d6a3e; --ok-soft: #e8f3eb; --radius: 8px; --focus: 0 0 0 3px #fff, 0 0 0 5px #0f6f80;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif; }
h1, h2, h3 { font-family: 'ERAG MinervaModern', Georgia, serif; font-weight: 500; margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 18px; }
a { color: var(--petrol-strong); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.top { display: flex; align-items: center; gap: 16px; background: var(--white); border-bottom: 1px solid var(--line); padding: 10px 20px; position: sticky; top: 0; z-index: 5; }
.top img { height: 40px; }
.top .product { font-family: 'ERAG MinervaModern', Georgia, serif; font-size: 18px; color: var(--petrol-strong); border-left: 1px solid var(--line); padding-left: 16px; }
.top .spacer { flex: 1; }
.top .user { font-size: 14px; color: var(--muted); }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 61px); }
nav.side { background: var(--white); border-right: 1px solid var(--line); padding: 16px 10px; }
nav.side a { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 6px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
nav.side a:hover { background: var(--petrol-soft); }
nav.side a[aria-current="page"] { background: var(--petrol-soft); color: var(--petrol-strong); font-weight: 600; }
main { padding: 24px 28px 60px; min-width: 0; }
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; }
.banner.warn { background: var(--gold-soft); color: var(--warn); border: 1px solid #e8cf9f; }
.banner.error { background: var(--error-soft); color: var(--error); border: 1px solid #e9c2bb; }
.banner.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #c4dfcb; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }

/* Formulare */
label.f { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
label.f span.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  font-weight: 400;
  border: 1px solid #b9cacd; border-radius: 6px; padding: 8px 10px; min-height: 40px; background: var(--white); width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--petrol-strong); box-shadow: 0 0 0 3px rgba(15, 111, 128, .25); }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; }
.err { color: var(--error); font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--white); border-radius: 6px; padding: 8px 14px; min-height: 40px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text); }
.btn:hover { border-color: var(--petrol); }
.btn.primary { background: var(--petrol-strong); color: var(--white); border-color: var(--petrol-strong); }
.btn.primary:hover { background: #0b5966; }
.btn.danger { color: var(--error); border-color: #e3b9b1; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; background: var(--white); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #edf2f2; vertical-align: top; font-size: 14px; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: #f8fafa; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7fbfb; }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef2f3; color: #3f5a60; }
.badge.new { background: var(--gold-soft); color: var(--warn); }
.badge.in_review, .badge.info_requested { background: var(--petrol-soft); color: var(--petrol-strong); }
.badge.offer_created, .badge.accepted { background: var(--ok-soft); color: var(--ok); }
.badge.rejected, .badge.withdrawn, .badge.excluded { background: var(--error-soft); color: var(--error); }
.badge.manual_review { background: var(--gold-soft); color: var(--warn); }
.badge.eligible_preliminary { background: var(--ok-soft); color: var(--ok); }
.badge.draft { background: var(--gold-soft); color: var(--warn); }
.badge.approved { background: var(--petrol-soft); color: var(--petrol-strong); }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: var(--white); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.tabs button[aria-pressed="true"] { background: var(--petrol-strong); color: var(--white); border-color: var(--petrol-strong); }

/* Detail */
dl.kv { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr); gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 14px; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos a { display: block; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #eef2f2; }
.photos img { width: 100%; height: 110px; object-fit: cover; display: block; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.timeline li.call { border-color: var(--gold); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.head h1 { margin: 0; }

/* Regel-Editor */
.rule { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fcfdfd; }
.rule.inactive { opacity: .7; }
.rule header { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cond { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: 8px; margin-bottom: 6px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 14px; }
pre.json { background: #f6f8f8; border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow: auto; font-size: 12px; max-height: 300px; }

/* Login */
.login { max-width: 400px; margin: 8vh auto; background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login img { height: 54px; margin-bottom: 8px; }
.login form { display: grid; gap: 14px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 18px; letter-spacing: .08em; background: var(--petrol-soft); padding: 10px 12px; border-radius: 6px; word-break: break-all; }

#toast { position: fixed; bottom: 20px; right: 20px; max-width: 360px; }
#toast div { background: var(--text); color: var(--white); padding: 10px 14px; border-radius: 8px; margin-top: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
#toast div.error { background: var(--error); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { display: flex; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  nav.side a { white-space: nowrap; }
  main { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .cond { grid-template-columns: 1fr; }
  .top .product { display: none; }
}
.mt { margin-top: 12px; }
.noteform { margin-top: 12px; display: grid; gap: 8px; }
.seal-preview { max-width: 140px; max-height: 140px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fff; }
dialog.dialog { max-width: 520px; width: 92vw; border: 1px solid var(--line); }
dialog::backdrop { background: rgba(23, 62, 70, .35); }
@media (max-width: 560px) {
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
}
