/* ---------------------------------------------------------------------------
   Monster Preis-Dashboard — Design-Tokens
   Die Serienfarben --series-1..8 sind die geprüfte kategoriale Palette
   (CVD-getestet in hell und dunkel); --series-other ist der neutrale Ton für
   gebündelte Serien. Texte tragen nie eine Serienfarbe.
--------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --plane: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f1f1ec;
  --surface-3: #e7e7e0;

  --text-1: #0b0b0b;
  --text-2: #52514e;
  --muted: #7d7b75;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.12);
  --border-strong: rgba(11, 11, 11, 0.22);

  --accent: #4f7d11;
  --accent-strong: #3f6a06;
  --accent-ink: #ffffff;
  --accent-wash: rgba(110, 168, 26, 0.14);

  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #898781;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 24px rgba(11, 11, 11, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;

    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2c2c2a;

    --text-1: #ffffff;
    --text-2: #c3c2b7;
    --muted: #918f88;
    --grid: #2c2c2a;
    --axis: #3d3d3a;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);

    --accent: #8fd41a;
    --accent-strong: #a6e630;
    --accent-ink: #0d0d0d;
    --accent-wash: rgba(143, 212, 26, 0.16);

    --good-text: #0ca30c;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --series-other: #898781;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c2a;
  --text-1: #ffffff;
  --text-2: #c3c2b7;
  --muted: #918f88;
  --grid: #2c2c2a;
  --axis: #3d3d3a;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);
  --accent: #8fd41a;
  --accent-strong: #a6e630;
  --accent-ink: #0d0d0d;
  --accent-wash: rgba(143, 212, 26, 0.16);
  --good-text: #0ca30c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #898781;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ Shell */

.shell { max-width: 1440px; margin: 0 auto; padding: 0 16px 64px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, var(--accent-strong), var(--accent));
  display: grid; place-items: center;
  color: var(--accent-ink); font-weight: 800; font-size: 17px;
  box-shadow: 0 0 0 1px var(--border);
}
.brand-title { font-size: 16px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }

.tabs {
  display: flex; gap: 3px; background: var(--surface-2); padding: 3px; border-radius: 11px;
  border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; color: var(--text-2); text-decoration: none;
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-3); color: var(--text-1); }
.tab[aria-current="page"] { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow); }

.icon-button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; display: grid; place-items: center;
}
.icon-button:hover { color: var(--text-1); border-color: var(--border-strong); }

/* ----------------------------------------------------------------- Filter */

.filterbar {
  display: flex; align-items: flex-end; gap: 10px 12px; flex-wrap: wrap;
  padding: 14px 0 18px;
}
.filterbar .segmented button { padding: 6px 9px; font-size: 12.5px; }
.filterbar input[type="date"] { width: 150px; }
.filterbar .control { min-height: 36px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.control, select.control, input.control {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-1);
  border-radius: var(--radius-sm); padding: 8px 11px; min-height: 38px; cursor: pointer;
}
.control:focus-visible, .tab:focus-visible, .icon-button:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input.control, textarea.control { cursor: text; }

.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  padding: 6px 11px; border-radius: 6px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.segmented button:hover { color: var(--text-1); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text-1); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }

.button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-1);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 13.5px;
  min-height: 38px; display: inline-flex; align-items: center; gap: 7px;
}
.button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.button--primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.button--primary:hover { background: var(--accent-strong); }
.button--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.button--ghost:hover { background: var(--surface-2); color: var(--text-1); }
.button--danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 35%, transparent); background: transparent; }
.button--danger:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Mehrfachauswahl als Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.chip:hover { border-color: var(--border-strong); color: var(--text-1); }
.chip[aria-pressed="true"] { background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text-1); }
.chip-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ------------------------------------------------------------------ Cards */

.grid { display: grid; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12.5px; color: var(--muted); }
.card-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Hero + KPI */
.hero { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; }
.hero-figure { font-size: 54px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.hero-meta { display: flex; flex-direction: column; gap: 3px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 15px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi-foot { font-size: 12.5px; color: var(--text-2); margin-top: 3px; display: flex; align-items: center; gap: 5px; }

.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 12.5px; }
.delta--down { color: var(--good-text); }
.delta--up { color: var(--critical); }
.delta--flat { color: var(--muted); }

/* ------------------------------------------------------------------ Tabellen */

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 2px 8px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge--promo { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--text-1); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.badge--best { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--text-1); border-color: color-mix(in srgb, var(--good) 45%, transparent); }

/* ------------------------------------------------------------------ Galerie */

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 12px; }
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 9px; box-shadow: var(--shadow);
  position: relative; min-width: 0;
}
.product-card.is-inactive { opacity: 0.55; }
.product-shot {
  height: 132px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 30%, var(--surface-2), transparent 72%);
  border-radius: var(--radius-sm);
}
.product-shot img { height: 132px; width: auto; max-width: 100%; object-fit: contain; }
/* Echte Produktfotos sind fast immer vor Weiß aufgenommen. Eine reinweiße
   Platte lässt den Bildhintergrund nahtlos aufgehen — eine getönte Fläche
   würde als Kante um das Foto sichtbar. */
.product-shot--photo {
  background: #ffffff;
  padding: 6px;
  box-shadow: inset 0 0 0 1px var(--border);
}
.product-shot--photo img { height: 120px; width: 100%; object-fit: contain; }
.product-name { font-size: 14px; font-weight: 700; line-height: 1.25; }
.product-line { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.product-price { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.product-meta { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.product-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------------------ Diagramme */

.chart { width: 100%; display: block; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer; border: 0; background: none; padding: 2px 0; }
.legend-item[aria-pressed="false"] { opacity: 0.4; }
.legend-key { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.legend-key--rect { width: 11px; height: 11px; border-radius: 3px; }

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 9px 11px; box-shadow: var(--shadow); font-size: 12.5px; min-width: 150px;
  opacity: 0; transition: opacity 0.1s ease;
}
.tooltip[data-open="true"] { opacity: 1; }
.tooltip-title { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.tooltip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tooltip-row .legend-key { margin-right: 0; }
.tooltip-value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-1); }
.tooltip-name { color: var(--text-2); }

/* Matrix */
.matrix-cell { font-variant-numeric: tabular-nums; }
.matrix-cell.is-best { font-weight: 700; }
.matrix-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.matrix-scale-bar { height: 10px; width: 120px; border-radius: 3px; }

/* ------------------------------------------------------------------ Formular */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.switch input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--text-1); }

.list { display: flex; flex-direction: column; gap: 10px; }
.row-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px;
}
.row-card.is-inactive { opacity: 0.6; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.row-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.row-sub { font-size: 12.5px; color: var(--muted); }
.row-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.row-stat { display: flex; flex-direction: column; gap: 1px; min-width: 88px; }
.row-stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.row-stat span { font-size: 11.5px; color: var(--muted); }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text-1); margin-bottom: 6px; font-size: 16px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
}
.notice--warn { background: color-mix(in srgb, var(--warning) 14%, transparent); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.notice--error { background: color-mix(in srgb, var(--critical) 12%, transparent); border-color: color-mix(in srgb, var(--critical) 40%, transparent); color: var(--text-1); }
.notice--ok { background: color-mix(in srgb, var(--good) 12%, transparent); border-color: color-mix(in srgb, var(--good) 40%, transparent); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 11px 13px; box-shadow: var(--shadow); font-size: 13.5px; }
.toast--error { border-color: color-mix(in srgb, var(--critical) 55%, transparent); }
.toast--ok { border-color: color-mix(in srgb, var(--good) 55%, transparent); }

.is-loading { opacity: 0.55; transition: opacity 0.15s ease; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin: 26px 0 10px; }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; }

@media (max-width: 1000px) { .cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .shell { padding: 0 12px 56px; }
  .hero-figure { font-size: 42px; }
  .topbar { gap: 10px; padding: 10px 0; }
  .brand-sub { display: none; }
  /* Navigation rutscht unter den Titel und scrollt seitlich, statt die Seite zu verbreitern. */
  .brand { flex: 1 1 auto; min-width: 0; margin-right: 0; }
  .brand-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tabs { order: 3; width: 100%; }
  .filterbar { padding: 12px 0 14px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .product-shot, .product-shot img { height: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------- Balkenliste */

.barlist { display: flex; flex-direction: column; gap: 2px; }
.barlist-row {
  display: grid; grid-template-columns: minmax(92px, 150px) minmax(0, 1fr) auto;
  gap: 12px; align-items: center; border-radius: 7px; outline-offset: 2px;
}
.barlist-row:hover, .barlist-row:focus-visible { background: var(--surface-2); }
.barlist-label { display: flex; flex-direction: column; min-width: 0; }
.barlist-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barlist-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barlist-track { height: 22px; display: flex; align-items: center; }
.barlist-bar { height: 20px; border-radius: 0 4px 4px 0; min-width: 3px; }
.barlist-value { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; padding-right: 2px; }

.spark { display: block; }

/* ------------------------------------------------------------------ Matrix */

table.matrix { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12.5px; }
table.matrix th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-align: center; padding: 4px 6px; white-space: nowrap; }
table.matrix th.row-head { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; max-width: 190px; }
table.matrix td {
  text-align: center; padding: 6px 8px; border-radius: 6px; font-variant-numeric: tabular-nums;
  white-space: nowrap; cursor: default;
}
table.matrix td.is-empty { background: var(--surface-2); color: var(--muted); }
