/* PreisWaechter – Dashboard. Hell/Dunkel über prefers-color-scheme, Layouts: iPhone, Duo/iPad, Mac. */
:root {
  color-scheme: light;
  --bg: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --ink: #121a24;
  --muted: #5a6575;
  --faint: #8a94a3;
  --line: #d9dfe6;
  --grid: #e7ebf0;
  --curve: #2f55d4;
  --curve-fill: rgba(47, 85, 212, .09);
  --target: #a86200;
  --good: #0f7f55;
  --good-bg: #e2f4ec;
  --warn: #9a5b00;
  --warn-bg: #fbf0dc;
  --bad: #b8402b;
  --bad-bg: #fbe8e4;
  --info-bg: #e7ecfb;
  --shadow: 0 1px 2px rgba(18, 26, 36, .06), 0 8px 24px rgba(18, 26, 36, .05);
  --round: ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sans: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --r-panel: 22px;
  --r-ctl: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f141b;
    --surface: #18202b;
    --surface-2: #1f2834;
    --ink: #e8edf4;
    --muted: #9aa5b5;
    --faint: #6f7a8a;
    --line: #2b3543;
    --grid: #232c38;
    --curve: #7d97ff;
    --curve-fill: rgba(125, 151, 255, .12);
    --target: #e3a13a;
    --good: #3dc48d;
    --good-bg: #133227;
    --warn: #e3a13a;
    --warn-bg: #362812;
    --bad: #f08770;
    --bad-bg: #3a1c17;
    --info-bg: #1d2747;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141b; --surface: #18202b; --surface-2: #1f2834; --ink: #e8edf4; --muted: #9aa5b5; --faint: #6f7a8a;
  --line: #2b3543; --grid: #232c38; --curve: #7d97ff; --curve-fill: rgba(125, 151, 255, .12); --target: #e3a13a;
  --good: #3dc48d; --good-bg: #133227; --warn: #e3a13a; --warn-bg: #362812; --bad: #f08770; --bad-bg: #3a1c17;
  --info-bg: #1d2747; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--sans);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--curve); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--round); font-variant-numeric: tabular-nums; }

/* ---------- Grundgerüst */
.wrap { max-width: 1440px; margin: 0 auto; padding: 20px 16px 48px; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 10px; flex: none; }
.brand h1 { font: 700 22px/1.1 var(--round); margin: 0; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
  font-size: 15px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 14px; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }

.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--r-ctl); background: var(--good-bg); color: var(--good); font-weight: 600; }
.flash.err { background: var(--bad-bg); color: var(--bad); }

/* ---------- Überblick (Merkliste oben) */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 10px; margin-bottom: 18px; }
.chip {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding: 12px 14px;
  background: var(--surface); border-radius: 16px; text-decoration: none; box-shadow: var(--shadow); min-width: 0;
}
.chip b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .num { font-size: 18px; font-weight: 700; text-align: right; white-space: nowrap; }
.chip small { color: var(--muted); font-size: 12px; grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.chip svg { grid-row: 1 / span 2; grid-column: 2; display: none; }

/* ---------- Produkt */
.product {
  background: var(--surface); border-radius: var(--r-panel); box-shadow: var(--shadow); margin-bottom: 18px;
  padding: 18px 16px 8px; scroll-margin-top: 16px;
}
.p-grid { display: grid; gap: 18px; }
.p-main, .p-side { display: grid; gap: 16px; align-content: start; min-width: 0; }
.p-side .facts { margin-top: 0; }
.p-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 16px; }
.p-title { flex: 1 1 220px; min-width: 0; }
.p-title h2 { margin: 0; font: 700 21px/1.2 var(--round); letter-spacing: -.01em; }
.p-title .meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.variant { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 13px; }

.tag { flex: 0 1 auto; text-align: right; }
.tag .price { font: 800 44px/1 var(--round); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tag .price small { font-size: .5em; font-weight: 700; margin-left: 2px; letter-spacing: 0; }
.tag .where { margin-top: 4px; color: var(--muted); font-size: 14px; }
.tag .where a { color: var(--ink); font-weight: 600; text-decoration-color: var(--line); text-underline-offset: 3px; }
.tag .none { font: 700 20px/1.2 var(--round); color: var(--muted); }

.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); }
.verdict .badge { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--info-bg); color: var(--curve); }
.verdict .badge svg { width: 18px; height: 18px; }
.verdict b { display: block; font: 700 16px/1.25 var(--round); }
.verdict p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.verdict.good .badge, .verdict.low .badge { background: var(--good-bg); color: var(--good); }
.verdict.high .badge { background: var(--bad-bg); color: var(--bad); }
.verdict.falling .badge { background: var(--warn-bg); color: var(--warn); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.fact { padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); min-width: 0; }
.fact span { display: block; color: var(--muted); font-size: 12px; }
.fact strong { font: 700 17px/1.3 var(--round); font-variant-numeric: tabular-nums; }
.fact.hit { border-color: var(--good); background: var(--good-bg); }
.fact.hit strong { color: var(--good); }
.fact button { all: unset; cursor: pointer; display: block; width: 100%; }
.fact button:focus-visible { outline: 2px solid var(--curve); outline-offset: 4px; border-radius: 6px; }
.fact .edit { color: var(--curve); font-size: 12px; font-weight: 600; }

/* ---------- Diagramm */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 6px; }
.chart-head h3 { margin: 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.chart-head h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.seg { flex: none; }
.seg button { white-space: nowrap; border: 0; background: none; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chart { position: relative; height: 220px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .ax { fill: var(--faint); font: 11px var(--sans); font-variant-numeric: tabular-nums; }
.chart .ln { fill: none; stroke: var(--curve); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ar { fill: var(--curve-fill); }
.chart .tg { stroke: var(--target); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .tgl { fill: var(--target); font: 600 11px var(--sans); }
.chart .uvp { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .uvpl { fill: var(--faint); font: 11px var(--sans); }
.chart .dot { fill: var(--curve); stroke: var(--surface); stroke-width: 2; }
.chart .lowdot { fill: var(--good); stroke: var(--surface); stroke-width: 2; }
.chart .lowl { fill: var(--good); font: 600 11px var(--sans); }
.chart .xh { stroke: var(--faint); stroke-width: 1; }
.chart .hv { visibility: hidden; }
.chart.on .hv { visibility: visible; }
.tip {
  position: absolute; top: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 10px;
  font-size: 12px; line-height: 1.35; white-space: nowrap; transform: translateX(-50%); box-shadow: var(--shadow);
}
.tip b { font: 700 15px var(--round); font-variant-numeric: tabular-nums; display: block; }
.chart-empty { height: 160px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px;
  border: 1px dashed var(--line); border-radius: 16px; padding: 16px; }

/* ---------- Shops */
.shops h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.trust { display: inline-flex; gap: 3px; width: 26px; }
.trust i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.trust.t3 i { background: var(--good); }
.trust.t2 i:nth-child(-n+2) { background: var(--good); }
.trust.t1 i:first-child { background: var(--warn); }
.row .who { min-width: 0; }
.row .who a, .row .who span.n { font-weight: 600; text-decoration: none; }
.row .who a:hover { text-decoration: underline; text-underline-offset: 3px; }
.row .who small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .val { text-align: right; }
.row .val .num { font-size: 17px; font-weight: 700; }
.row .val small { display: block; color: var(--muted); font-size: 12px; }
.row.best .val .num { color: var(--good); }
.row .bestpill { margin-left: 6px; font-size: 11px; font-weight: 700; color: var(--good); background: var(--good-bg); padding: 1px 7px; border-radius: 999px; vertical-align: 1px; }
.row .st { font-size: 13px; color: var(--muted); }
.row .st.blocked { color: var(--warn); }
.more { margin-top: 2px; }
.more summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 10px 0; border-top: 1px solid var(--line); list-style: none; display: flex; align-items: center; gap: 6px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
.more[open] summary::before { transform: rotate(45deg); }
.p-foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 8px; border-top: 1px solid var(--line); margin-top: 4px; }

/* ---------- Shop-Übersicht unten */
.section-title { font: 700 18px/1.2 var(--round); margin: 30px 0 10px; }
.shoplist { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.shopcard { background: var(--surface); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.shopcard header { display: flex; align-items: center; gap: 8px; }
.shopcard header b { margin-right: auto; }
.shopcard p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--good-bg); color: var(--good); }
.pill.no { background: var(--warn-bg); color: var(--warn); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.status { margin-top: 28px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); color: var(--muted); font-size: 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.status p { margin: 0; margin-right: auto; }
.status .err { color: var(--bad); font-weight: 600; }

.empty { text-align: center; padding: 48px 20px; background: var(--surface); border-radius: var(--r-panel); box-shadow: var(--shadow); }
.empty h2 { font: 700 22px var(--round); margin: 12px 0 6px; }
.empty p { color: var(--muted); margin: 0 auto 18px; max-width: 40ch; }

/* ---------- Dialog Produkt hinzufügen */
dialog {
  border: 0; padding: 0; border-radius: 24px; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 14, 20, .45); }
.dlg { padding: 20px 18px 18px; display: grid; gap: 14px; }
.dlg header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dlg h2 { margin: 0; font: 700 20px var(--round); }
.dlg p.hint { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.dlg p.hint.small { margin: 8px 0 0; font-size: 13px; }
#a-fields { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface-2);
}
.field input:focus { border-color: var(--curve); outline: none; box-shadow: 0 0 0 3px var(--curve-fill); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.variants { display: grid; gap: 8px; }
.vopt { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.vopt:has(input:checked) { border-color: var(--curve); background: var(--info-bg); }
.vopt input { accent-color: var(--curve); width: 18px; height: 18px; margin: 0; }
.vopt b { font-weight: 600; }
.vopt small { grid-column: 2; color: var(--muted); font-size: 12px; }
.vopt .num { grid-row: 1 / span 2; grid-column: 3; font-weight: 700; }
.msg { padding: 10px 12px; border-radius: var(--r-ctl); font-size: 14px; background: var(--bad-bg); color: var(--bad); }
.msg.info { background: var(--surface-2); color: var(--muted); }
.dlg footer { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.linkbtn { border: 0; background: none; color: var(--curve); font-weight: 600; cursor: pointer; padding: 6px 0; font-size: 14px; }
.small-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 0 10px; }
.small-form input { min-height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); min-width: 0; flex: 1 1 160px; }

/* ---------- Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(380px, 100%); display: grid; gap: 12px; text-align: center; background: var(--surface); padding: 28px 22px; border-radius: var(--r-panel); box-shadow: var(--shadow); }
.login img { margin: 0 auto; border-radius: 14px; }
.login h1 { margin: 0; font: 700 26px var(--round); }
.login p { margin: 0; color: var(--muted); }
.login input { min-height: 46px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface-2); padding: 0 14px; text-align: center; }

@media (max-width: 699px) {
  .tag { text-align: left; flex-basis: 100%; }
}
@media (max-width: 420px) {
  .seg button { padding: 4px 8px; }
  .facts { gap: 6px; }
  .fact { padding: 9px 10px; }
}
/* ---------- Breiter: Duo offen, iPad */
@media (min-width: 700px) {
  .wrap { padding: 28px 24px 56px; }
  .product { padding: 22px 22px 10px; }
  .tag .price { font-size: 52px; }
  .chart { height: 250px; }
  .chip svg { display: block; }
  .chip { grid-template-columns: 1fr 72px auto; }
  .chip .num { grid-column: 3; grid-row: 1 / span 2; }
  .chip small { grid-column: 1; }
  .chip svg { grid-column: 2; grid-row: 1 / span 2; }
}
/* ---------- Mac-Fenster: Kurve links, Shops rechts */
@media (min-width: 1080px) {
  .p-grid { grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); column-gap: 32px; align-items: start; }
  .p-side { border-left: 1px solid var(--line); padding-left: 28px; }
  .chart { height: 270px; }
}
@media (prefers-reduced-motion: no-preference) {
  .ln.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw .9s ease-out forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}
