:root {
  --bg: #f6f7f9;
  --card: #fff;
  --text: #1c2330;
  --muted: #6b7482;
  --line: #e3e6eb;
  --accent: #c8102e;
  --up: #0f8a4b;
  --down: #c62828;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }
main { padding: 1rem 1.5rem; }
footer { margin: 2rem 0; padding: 0 1.5rem; color: var(--muted); font-size: .85rem; }

.top { background: #16202e; color: #fff; padding: .9rem 1rem; display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.brand span { color: #ff5a6e; }
.sub { color: #aab3c0; font-size: .9rem; }

h1 { margin: .2rem 0; font-size: 1.5rem; }
h2 { margin-top: 2rem; font-size: 1.15rem; }

.modes { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.modes a { padding: .45rem .9rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); text-decoration: none; }
.modes a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .9rem; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }
.filters input, .filters select { font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
.filters input[type=number] { width: 7rem; }
.filters button { font: inherit; padding: .4rem 1rem; border: 0; border-radius: 6px; background: #16202e; color: #fff; cursor: pointer; }

.compare { color: var(--muted); margin: 1rem 0 .5rem; }
.stats { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .8rem; text-decoration: none; }
.stat.up strong { color: var(--up); }
.stat.down strong { color: var(--down); }

.notice { background: #fff8e1; border: 1px solid #f3e0a0; border-radius: 8px; padding: .8rem 1rem; }
.muted { color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
tbody tr:hover { background: #f9fafb; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .name { font-weight: 600; text-decoration: none; }
.changes td:nth-child(2) { white-space: normal; min-width: 14rem; }
td .name:hover { text-decoration: underline; }
.up { color: var(--up); }
.down { color: var(--down); }
.strong { font-weight: 700; }
.meta { display: inline-flex; gap: .35rem; margin-left: .4rem; align-items: center; flex-wrap: wrap; }
p.meta { margin-left: 0; }
.tag { font-size: .72rem; background: #eef1f5; color: #445; border-radius: 4px; padding: .05rem .4rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: 1rem 0; }
.cards div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.cards span { display: block; font-size: .78rem; color: var(--muted); }
.cards strong { font-size: 1.2rem; }

.chart { width: 100%; max-width: 1100px; display: block; height: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 1rem; }
.chart .grid { stroke: var(--line); }
.chart .axis { font-size: 11px; fill: var(--muted); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .trend { stroke: var(--accent); }
.chart .low { stroke: #2b6cb0; stroke-dasharray: 5 4; }
.chart .avg1 { stroke: #9aa3ae; stroke-width: 1.5; }
.legend { display: flex; gap: 1rem; font-size: .85rem; margin-bottom: .4rem; }
.legend span::before { content: ""; display: inline-block; width: 18px; height: 3px; margin-right: .35rem; vertical-align: middle; }
.legend .trend::before { background: var(--accent); }
.legend .low::before { background: #2b6cb0; }
.legend .avg1::before { background: #9aa3ae; }

/* Card images */
th.thumb, td.thumb { width: 60px; padding-right: 0; }
td.thumb img { display: block; width: 48px; height: 67px; object-fit: contain; border-radius: 3px; background: #eef1f5; }
.product-top { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; align-items: start; margin-top: 1rem; }
.product-top .cards { margin-top: 0; }
.card-image { margin: 0; }
.card-image img { width: 100%; height: auto; display: block; border-radius: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.15); }
.card-image figcaption { font-size: .8rem; color: var(--muted); margin-top: .4rem; text-align: center; }
.card-image.none img, .card-image .placeholder { display: none; }
.card-image.none::before, .card-image .placeholder { content: "Kein Bild"; display: flex; aspect-ratio: 5 / 7; align-items: center; justify-content: center; background: #eef1f5; border-radius: 12px; color: var(--muted); }
@media (max-width: 640px) { .product-top { grid-template-columns: 1fr; } .card-image { max-width: 260px; } }

.admin { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; margin-top: 1rem; }
.admin summary { cursor: pointer; font-weight: 600; }
.candidates { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; margin: .8rem 0; }
.candidate button { width: 100%; background: #fafbfc; border: 2px solid var(--line); border-radius: 8px; padding: .4rem; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: .25rem; align-items: center; }
.candidate button:hover { border-color: #16202e; }
.candidate.chosen button { border-color: var(--accent); background: #fff1f3; }
.candidate img { width: 100%; aspect-ratio: 5 / 7; object-fit: contain; }
.candidate span { font-size: .78rem; line-height: 1.25; text-align: center; }
.candidate small { font-size: .7rem; color: var(--muted); }
.none { display: none !important; }
.admin-forms { display: flex; flex-direction: column; gap: .6rem; }
.admin-forms .filters { padding: .6rem .8rem; }
.admin-forms input[type=url] { width: min(36rem, 70vw); }
button.secondary { background: #eef1f5 !important; color: var(--text) !important; }
form.inline { display: inline; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.small { font-size: .85rem; }
code { background: #eef1f5; padding: .1rem .3rem; border-radius: 4px; }

/* Hover preview (preview.js) */
.preview { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .12s; }
.preview.visible { opacity: 1; }
.preview img { display: block; width: 300px; height: auto; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.35); background: #fff; }
td.thumb img[data-preview] { cursor: zoom-in; }

/* Touch gallery (preview.js) */
body.no-scroll { overflow: hidden; }
.gallery { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 20, .94); display: grid; grid-template-rows: auto 1fr auto; color: #fff; touch-action: pan-y; }
.gallery[hidden] { display: none; }
.g-stage { margin: 0; grid-row: 2; display: flex; align-items: center; justify-content: center; padding: 0 .75rem; min-height: 0; }
.g-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 14px; transition: opacity .15s; }
.g-stage img.loading { opacity: .35; }
.g-count { grid-row: 1; text-align: center; padding: .9rem 3.5rem .4rem; font-size: .9rem; color: #aab3c0; }
.g-close { position: absolute; top: .4rem; right: .5rem; z-index: 2; }
.g-close, .g-prev, .g-next { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 999px; width: 2.6rem; height: 2.6rem; font-size: 1.3rem; line-height: 1; }
.g-prev, .g-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; font-size: 1.8rem; }
.g-prev { left: .4rem; }
.g-next { right: .4rem; }
.g-caption { grid-row: 3; display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .8rem 1rem calc(1rem + env(safe-area-inset-bottom)); text-align: center; }
.g-caption span.up { color: #4ade80; }
.g-caption span.down { color: #f87171; }
.g-caption a { margin-top: .3rem; color: #fff; background: var(--accent); padding: .45rem 1.1rem; border-radius: 999px; text-decoration: none; font-weight: 600; }

/* Sortable table headers */
th.sortable a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .15rem; cursor: pointer; user-select: none; }
th.sortable a:hover { color: var(--text); }
th.sorted { color: var(--text); }
th.sortable .arrow { font-size: .7rem; }
