:root {
  --seen: #7b4bb8;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --border: #dcd9cf;
  --text: #1d1c19;
  --muted: #6d6a60;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe7;
  --warn: #9a6400;
  --warn-soft: #fbf0d9;
  --err: #b3261e;
  --err-soft: #fbe3e1;
  --star: #d79b00;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151614;
    --surface: #1e201d;
    --surface-2: #272a26;
    --border: #363a34;
    --text: #e9e8e2;
    --muted: #9b9a91;
    --accent: #6cc59a;
    --accent-ink: #0f1a14;
    --accent-soft: #1f3529;
    --warn: #e5b34f;
    --warn-soft: #3a2f17;
    --err: #ff8a80;
    --err-soft: #3d1f1d;
    --star: #f2c14e;
    --seen: #b48ae8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h1 small { font-weight: 400; color: var(--muted); font-size: 15px; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 18px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.err { color: var(--err); }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.brand span { color: var(--accent); padding: 0 1px; }
.top nav { display: flex; gap: 14px; }
.top nav a { color: var(--muted); font-weight: 500; }
#jobpanel { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 8px; align-items: center; font-size: 12.5px; min-width: 0; }
.jobchip {
  display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text);
}
.jobchip.running { background: var(--accent-soft); }
.jobchip.fehler { background: var(--err-soft); }
.jobchip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

main { padding: 20px; max-width: 1800px; margin: 0 auto; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { margin: 0 0 8px; }

/* controls */
button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  display: inline-block; line-height: 1.2; text-decoration: none !important;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, .button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.ghost:hover:not(:disabled), .button.ghost:hover { background: var(--surface-2); }
button.danger, .button.danger { border-color: var(--err); background: var(--err); color: #fff; }
button.ghost.danger { background: transparent; color: var(--err); border-color: var(--border); }
button.icon { padding: 7px 10px; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 500; }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 9px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=number] { width: 7em; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
label { display: inline-flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
form.inline { display: inline; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 220px; }
.range { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.range input { width: 6.5em; }

.notice { background: var(--warn-soft); color: var(--text); padding: 10px 14px; border-radius: var(--radius); }
.notice.err { background: var(--err-soft); }

/* home */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  color: var(--text); text-decoration: none !important; position: relative;
}
a.card:hover { border-color: var(--accent); }
.card h2 { font-size: 17px; margin: 0; }
.card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.card dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.card.new { border-style: dashed; justify-content: center; }
.card .badge { align-self: flex-start; }

/* collection */
.runbar, .filters, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
}
.runbar { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.runopts, .runbuttons { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.runopts select { max-width: 340px; }
.fieldfilters { margin-top: 10px; }
.fieldfilters summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.flabel { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
label.check.strict { font-size: 11.5px; color: var(--muted); gap: 4px; font-weight: 400; white-space: nowrap; }
label.check.strict input { margin: 0; }
.fieldfilters .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 2px 12px; }
.preset {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 12px; background: var(--surface);
}
.preset a { color: var(--text); font-weight: 600; font-size: 13px; }
.preset.active { border-color: var(--accent); background: var(--accent-soft); }
.preset .x { background: none; border: 0; color: var(--muted); padding: 2px 6px; font-size: 11px; font-weight: 400; }
.preset .x:hover { color: var(--err); }
.presetsave { display: inline-flex; gap: 6px; margin-left: auto; }
.presetsave input { width: 230px; }
.tablemeta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); margin: 0 2px 6px; flex-wrap: wrap; }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
/* The listings table scrolls inside its own box so the column header row stays visible. */
.tablewrap.scrollbox { overflow: auto; max-height: calc(100vh - 72px); max-height: calc(100dvh - 72px); }
.listings thead th { box-shadow: inset 0 -1px 0 var(--border); }
table { border-collapse: collapse; width: 100%; }
.listings th, .listings td, .jobs th, .jobs td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.listings thead th, .jobs thead th {
  position: sticky; top: 0; background: var(--surface-2); font-size: 12px; font-weight: 600; white-space: nowrap; z-index: 1;
}
.listings th a { color: var(--text); }
.listings th a.sorted::after { content: " ▾"; color: var(--accent); }
.listings th a.sorted.asc::after { content: " ▴"; }
.listings tbody tr:hover { background: var(--surface-2); }
.listings tr.changed { box-shadow: inset 3px 0 0 var(--warn); }
.listings tr.st-gelöscht, .listings tr.st-verkauft { opacity: .55; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
td.empty { color: var(--muted); }
td.bool-true { color: var(--accent); font-weight: 600; }
.listings td.title { min-width: 260px; max-width: 460px; }
.listings td.title a.t { font-weight: 600; color: var(--text); }
.listings td.title a.t.seen { color: var(--seen); font-weight: 500; }
.listings td.title .interest { font-size: 12px; margin-right: 3px; cursor: help; }
.listings tr.dismissed { opacity: .4; }
.listings tr.returned td { animation: returned 1.6s ease-out; }
@keyframes returned { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }
.listings tr.dismissed:hover { opacity: .8; }
.dismiss { background: none; border: 0; padding: 2px 3px; font-size: 13px; line-height: 1; filter: grayscale(1); opacity: .35; }
.dismiss:hover { opacity: .8; }
.dismiss.on { filter: none; opacity: 1; }
.listings td.w, .listings th.w { white-space: nowrap; width: 58px; }
.listings td.title a.ka { font-size: 12px; margin-left: 4px; padding: 0 3px; color: var(--muted); }
.listings td.title a.ka:hover { color: var(--accent); text-decoration: none; }
.listings td.img { width: 64px; padding: 4px 6px; }
.listings td.img img { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; display: block; background: var(--surface-2); }
.listings td.w, .listings th.w { padding-right: 0; }
.emptyrow { text-align: center; color: var(--muted); padding: 30px !important; }
.star { background: none; border: 0; padding: 2px 4px; font-size: 18px; color: var(--muted); line-height: 1; }
.star.on { color: var(--star); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 4px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.status, .jobstatus { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.status.aktiv, .jobstatus.fertig { background: var(--accent-soft); color: var(--accent); }
.status.reserviert, .jobstatus.running, .jobstatus.queued { background: var(--warn-soft); color: var(--warn); }
.status.gelöscht, .status.verkauft, .jobstatus.fehler { background: var(--err-soft); color: var(--err); }
.pager { display: flex; gap: 8px; justify-content: center; margin: 14px; flex-wrap: wrap; }

/* setup */
.fieldlist { display: flex; flex-direction: column; gap: 6px; }
.fieldrow {
  display: grid; grid-template-columns: minmax(140px, 1.2fr) 110px minmax(120px, 1.2fr) minmax(140px, 1.6fr) 80px auto;
  gap: 8px; align-items: center;
}
.fieldrow.header span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.fieldrow.new { margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }
.rowbtns { display: flex; gap: 4px; justify-content: flex-end; }
.searchrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.searchrow.new { border-bottom: 0; }
.searchrow .url { flex: 1 1 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.searchrow label { flex-direction: row; align-items: center; gap: 6px; }
.searchrow input[name=max_pages] { width: 4.5em; }
.settings { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.dangerzone h2 { color: var(--err); }

/* listing */
.facts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 14px; color: var(--muted); }
.facts .price { font-size: 20px; font-weight: 700; color: var(--text); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; }
.kv { width: 100%; }
.kv th, .kv td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv th { color: var(--muted); font-weight: 500; width: 40%; }
.desc { white-space: pre-wrap; margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-2); }
.panel.highlight { border-color: var(--warn); }
.change + .change { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.diff { width: 100%; }
.diff th, .diff td { padding: 4px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.diff th { color: var(--muted); font-weight: 500; width: 22%; }
.diff .old { color: var(--err); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff .new { color: var(--accent); }
.diff pre { white-space: pre-wrap; font: inherit; margin: 0; }
.diff pre.old { text-decoration: none; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }

.fieldgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.fieldgrid > div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.fieldgrid .k { font-size: 11.5px; color: var(--muted); }
.fieldgrid .v { font-size: 15px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.fieldgrid .v.empty { color: var(--muted); font-weight: 400; }
.kaview .kahead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.kaview .kahead h2 { margin: 0; }
.kagrid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.viewer { position: relative; }
.viewer .main { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #000; border-radius: 10px; display: block; cursor: zoom-in; }
.viewer .stage { position: relative; }
/* Each arrow owns a third of the image so a click anywhere near it works; the middle zooms. */
.viewer .nav {
  position: absolute; top: 0; bottom: 0; width: 33%; padding: 0; border: 0; border-radius: 0;
  background: transparent; color: #fff; display: flex; align-items: center; cursor: pointer;
}
.viewer .nav.prev { left: 0; justify-content: flex-start; padding-left: 10px; }
.viewer .nav.next { right: 0; justify-content: flex-end; padding-right: 10px; }
.viewer .nav span {
  width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.55);
  font-size: 22px; line-height: 40px; text-align: center; transition: background .15s, transform .15s;
}
.viewer .nav:hover span { background: rgba(0,0,0,.8); transform: scale(1.1); }
.viewer .nav.prev:hover { background: linear-gradient(90deg, rgba(0,0,0,.18), transparent); }
.viewer .nav.next:hover { background: linear-gradient(270deg, rgba(0,0,0,.18), transparent); }
.viewer .count { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; }
.thumbs button { padding: 0; border: 2px solid transparent; background: none; border-radius: 6px; flex: 0 0 auto; }
.thumbs button.on { border-color: var(--accent); }
.thumbs img { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; display: block; }
.kainfo .price { font-size: 26px; font-weight: 700; }
.kainfo h3 { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 4px 0 10px; }
.kainfo .meta { color: var(--muted); display: flex; flex-direction: column; gap: 3px; margin-bottom: 14px; }
.kaview .desc { margin-top: 6px; font-size: 14.5px; line-height: 1.55; }
.viewer.zoom .main { position: fixed; inset: 0; width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; z-index: 30; cursor: zoom-out; }
.viewer.zoom .nav { position: fixed; z-index: 31; top: 0; bottom: 0; }
.viewer.zoom .count { position: fixed; z-index: 31; }

td.deal { color: var(--accent); font-weight: 600; }
td.deal .pct { font-size: 11px; font-weight: 500; color: var(--muted); }
.dealbadge { background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 999px; }
.dealpanel { border-color: var(--accent); }
.dealvalue { font-size: 15px; margin: 0 0 6px; }
.dealvalue b { font-size: 24px; color: var(--accent); margin-right: 6px; }

td.match { position: relative; font-weight: 600; min-width: 64px; }
td.match .matchbar {
  position: absolute; left: 8px; right: 8px; bottom: 4px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) calc(var(--m) * 1%), var(--surface-2) 0);
}
.matchscore { color: var(--accent); font-size: 22px; }
.why { margin: 4px 0 8px; padding-left: 18px; }
.why li.pos { color: var(--accent); }
.why li.neg { color: var(--err); }
.searchrow.suggestion .url { display: block; max-width: 100%; }

/* jobs */
.logrow td { padding: 0 !important; border-bottom: 0 !important; }
.log { margin: 0; padding: 10px 14px; max-height: 340px; overflow: auto; background: var(--surface-2); font: 12px/1.5 var(--mono); white-space: pre-wrap; }

/* together */
.together { display: inline-flex; gap: 8px; align-items: center; }
.presence { display: inline-flex; gap: 6px; }
.pres { font-size: 12px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 999px; background: var(--surface-2); display: inline-flex; align-items: center; gap: 5px; }
.pres::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.pres.together { background: var(--accent-soft); color: var(--accent); }
.pres.together::after { content: "⇄"; }
button.small { padding: 4px 10px; font-size: 12.5px; }
#together-toggle.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
body.together-on .top { box-shadow: inset 0 -2px 0 var(--accent); }
body.together-on .listings tbody tr { cursor: pointer; }
.listings tr.focus-me { box-shadow: inset 3px 0 0 var(--muted); }
.listings tr.focus-other { background: var(--accent-soft) !important; box-shadow: inset 4px 0 0 var(--accent); }
.focus-tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 0 7px; margin-right: 6px; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25); max-width: calc(100vw - 32px);
}
.toast button { margin-left: 8px; padding: 3px 10px; font-size: 12px; }

/* login */
.userbox { display: inline-flex; gap: 8px; align-items: center; font-size: 12.5px; }
#jobpanel + .userbox { margin-left: 4px; }
.login {
  max-width: 340px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px;
}
.login label { font-size: 12.5px; }
.login input { width: 100%; }
.login button { margin-top: 4px; }

@media (max-width: 760px) {
  main { padding: 12px 16px; }
  .top { padding: 10px 16px; gap: 10px; }
  #jobpanel { margin-left: 0; width: 100%; }
  .split, .cols, .kagrid { grid-template-columns: 1fr; }
  .fieldrow { grid-template-columns: 1fr 1fr; }
  .fieldrow.header { display: none; }
  .runopts select { max-width: 100%; }
  .presetsave { margin-left: 0; width: 100%; }
  .presetsave input { flex: 1; width: auto; }
}
