/* Renault OE - Ersetzungsketten
   Farbrollen nach dem validierten Standard-Datenviz-Palettenschema.        */

:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --plane:          #f4f4f1;
  --surface-2:      #ffffff;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, .10);
  --border-strong:  rgba(11, 11, 11, .18);

  --series-1: #2a78d6;  /* blau    */
  --series-2: #eb6834;  /* orange  */
  --series-3: #1baf7a;  /* aqua    */
  --series-4: #eda100;  /* gelb    */
  --series-5: #e87ba4;  /* magenta */
  --series-6: #008300;  /* gruen   */
  --series-7: #4a3aa7;  /* violett */
  --series-8: #e34948;  /* rot     */

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

  --wash-good:  rgba(12, 163, 12, .10);
  --wash-warn:  rgba(250, 178, 25, .16);
  --wash-crit:  rgba(208, 59, 59, .10);
  --wash-info:  rgba(42, 120, 214, .10);
  --wash-serious: rgba(236, 131, 90, .14);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 4px 16px rgba(11,11,11,.04);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --plane:          #0d0d0d;
    --surface-2:      #201f1e;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255,255,255,.10);
    --border-strong:  rgba(255,255,255,.18);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --good-text: #0ca30c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --plane:          #0d0d0d;
  --surface-2:      #201f1e;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255,255,255,.10);
  --border-strong:  rgba(255,255,255,.18);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --good-text: #0ca30c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .8em; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ------------------------------------------------------------- Kopfleiste */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 22px;
  padding: 0 22px; height: 56px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 660; letter-spacing: -.015em;
         color: var(--text-primary); font-size: .98rem; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--series-4);
              box-shadow: 0 0 0 3px rgba(237,161,0,.18); }
.brand small { color: var(--text-muted); font-weight: 450; }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a {
  padding: 7px 13px; border-radius: var(--radius-sm); color: var(--text-secondary);
  font-weight: 520; font-size: .9rem;
}
.nav a:hover { background: var(--plane); color: var(--text-primary); text-decoration: none; }
.nav a.on { background: var(--wash-info); color: var(--series-1); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-muted); font-size: .85rem; }
.iconbtn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:hover { border-color: var(--border-strong); color: var(--text-primary); }

/* Versionsanzeige in der Kopfleiste */
.verchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: 100px; border: 1px solid var(--border-strong); font-size: .78rem;
  font-weight: 600; color: var(--text-secondary); white-space: nowrap;
}
.verchip:hover { text-decoration: none; border-color: var(--text-muted); color: var(--text-primary); }
.verchip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.verchip.ok    .dot { background: var(--good); }
.verchip.warn  .dot { background: var(--warning); }
.verchip.crit  .dot { background: var(--critical); }
.verchip.crit { border-color: var(--critical); color: var(--critical); }

.pagefoot {
  max-width: 1360px; margin: 0 auto; padding: 18px 22px 40px;
  border-top: 1px solid var(--grid); color: var(--text-muted); font-size: .8rem;
}
.pagefoot code { color: var(--text-secondary); }

.wrap { max-width: 1360px; margin: 0 auto; padding: 24px 22px 40px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-secondary); font-size: .9rem; }

/* ------------------------------------------------------------------ Karten */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card > h2 { display: flex; align-items: center; gap: 10px; }
.hint { color: var(--text-muted); font-size: .85rem; font-weight: 450; margin-left: 4px; }
h3 .hint { font-size: .8rem; }
.grid { display: grid; gap: 16px; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) { .grid.k3, .grid.k4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .grid.k2, .grid.k3, .grid.k4 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- Kennzahl */
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 15px 17px; box-shadow: var(--shadow); }
.stat .label { color: var(--text-secondary); font-size: .8rem; text-transform: uppercase;
               letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 1.9rem; font-weight: 640; letter-spacing: -.02em; margin-top: 2px; }
.stat .foot { color: var(--text-muted); font-size: .82rem; }

/* --------------------------------------------------------------- Statuschip */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 100px; font-size: .78rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok      { background: var(--wash-good); color: var(--good-text); }
.chip.info    { background: var(--wash-info); color: var(--series-1); }
.chip.warn    { background: var(--wash-warn); color: #8a5a00; }
.chip.serious { background: var(--wash-serious); color: #a2451f; }
.chip.crit    { background: var(--wash-crit); color: var(--critical); }
.chip.plain   { background: var(--plane); color: var(--text-secondary); border-color: var(--border); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .chip.warn { color: var(--warning); }
  :root:where(:not([data-theme="light"])) .chip.serious { color: var(--serious); }
}
:root[data-theme="dark"] .chip.warn { color: var(--warning); }
:root[data-theme="dark"] .chip.serious { color: var(--serious); }

.delta.up   { color: var(--critical); font-weight: 600; }
.delta.down { color: var(--good-text); font-weight: 600; }
.delta.flat { color: var(--text-muted); }

/* -------------------------------------------------------------- Formulare */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-secondary);
        margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--text-primary);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); outline: none;
}
textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace;
           font-size: .9rem; line-height: 1.7; }
input:focus, textarea:focus, select:focus {
  border-color: var(--series-1); box-shadow: 0 0 0 3px var(--wash-info);
}
.field { margin-bottom: 14px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; font: inherit;
  font-weight: 600; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  background: var(--series-1); color: #fff;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--plane); filter: none; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.danger { background: var(--critical); }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.toolbar .field { margin-bottom: 0; }

/* --------------------------------------------------------------- Tabellen */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th {
  text-align: left; font-weight: 640; color: var(--text-secondary); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px;
  border-bottom: 1px solid var(--axis); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:hover { background: var(--plane); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .87rem; }
.muted { color: var(--text-muted); }
.small { font-size: .82rem; }

/* ------------------------------------------------------------ Ergebnisblock */
.result {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.result > header {
  display: flex; gap: 14px; align-items: center; padding: 14px 18px; flex-wrap: wrap;
  border-bottom: 1px solid var(--grid); background: var(--surface-2);
}
.result > header .pn { font-family: ui-monospace, "SF Mono", Menlo, monospace;
                       font-size: 1.05rem; font-weight: 640; letter-spacing: -.01em; }
.result > header .desc { color: var(--text-secondary); }
.result .body { padding: 16px 18px; }
.result.miss > header { background: var(--wash-crit); }

/* Bestellt A, geliefert B - der Fall, auf den es ankommt */
.result.alert {
  border-color: var(--critical);
  box-shadow: 0 0 0 3px var(--wash-crit), var(--shadow);
}
.result.alert > header { background: var(--wash-crit); }
.result.alert-soft { border-color: var(--warning); box-shadow: 0 0 0 3px var(--wash-warn), var(--shadow); }
.result.alert-soft > header { background: var(--wash-warn); }

.alertbox {
  border: 1px solid var(--critical); border-left-width: 5px; border-radius: var(--radius-sm);
  background: var(--wash-crit); padding: 14px 16px; margin-bottom: 16px;
}
.alertbox.soft { border-color: var(--warning); background: var(--wash-warn); }
.alertbox .head {
  display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1rem;
  color: var(--critical); margin-bottom: 8px;
}
.alertbox.soft .head { color: #8a5a00; }
:root[data-theme="dark"] .alertbox.soft .head { color: var(--warning); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .alertbox.soft .head { color: var(--warning); }
}
.alertbox .swap {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.alertbox .swap .box {
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 12px; min-width: 150px;
}
.alertbox .swap .box .lbl {
  font-family: var(--font); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-secondary); font-weight: 640;
}
.alertbox .swap .box .no { font-weight: 700; font-size: 1.02rem; }
.alertbox .swap .arrow { color: var(--critical); font-size: 1.4rem; font-weight: 700; }

tr.order-other td { background: var(--wash-crit); }
tr.order-other td:first-child { box-shadow: inset 3px 0 0 var(--critical); }

.jumpbar {
  border: 1px solid var(--critical); border-radius: var(--radius); background: var(--wash-crit);
  padding: 13px 16px; margin-bottom: 16px;
}
.jumpbar b { color: var(--critical); }
.jumpbar a.pill {
  display: inline-block; margin: 4px 6px 0 0; padding: 3px 11px; border-radius: 100px;
  background: var(--surface-2); border: 1px solid var(--critical); font-weight: 640;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85rem;
  color: var(--critical);
}
.jumpbar a.pill:hover { background: var(--critical); color: #fff; text-decoration: none; }

/* ------------------------------------------------------------------- Kette */
.chainflow { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.chainstep {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 13px; min-width: 168px; background: var(--surface-2);
}
.chainstep.is-query { border-color: var(--series-1); box-shadow: 0 0 0 3px var(--wash-info); }
.chainstep.is-head  { border-color: var(--good); box-shadow: 0 0 0 3px var(--wash-good); }
.chainstep .pn { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 640; }
.chainstep .meta { font-size: .78rem; color: var(--text-muted); }
.chainarrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 12px; color: var(--text-muted); font-size: .72rem; min-width: 92px; text-align: center;
}
.chainarrow .glyph { font-size: 1.1rem; color: var(--series-2); line-height: 1; }

/* ------------------------------------------------------------------ Timeline */
.tl { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--grid); }
.tl li { position: relative; padding: 0 0 14px 16px; }
.tl li::before {
  content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--series-1); box-shadow: 0 0 0 3px var(--surface-1);
}
.tl li.warn::before { background: var(--warning); }
.tl li.crit::before { background: var(--critical); }
.tl li.ok::before   { background: var(--good); }
.tl .when { font-weight: 640; font-size: .85rem; }
.tl .what { color: var(--text-secondary); font-size: .88rem; }

/* -------------------------------------------------------------- Chart-Hülle */
.chartbox { position: relative; background: var(--surface-1); border-radius: var(--radius-sm); }
.chartbox svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0 0; font-size: .82rem;
          color: var(--text-secondary); }
.legend span.k { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 20; opacity: 0; transition: opacity .1s;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 8px 11px; font-size: .82rem; min-width: 150px;
}
.tooltip .t-date { font-weight: 640; margin-bottom: 4px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .t-row i { width: 9px; height: 9px; border-radius: 2px; display: inline-block;
                    margin-right: 6px; }

/* ----------------------------------------------------------------- Meldungen */
.note { padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; margin-bottom: 14px;
        border: 1px solid var(--border); }
.note.ok   { background: var(--wash-good); border-color: rgba(12,163,12,.3); }
.note.err  { background: var(--wash-crit); border-color: rgba(208,59,59,.3); }
.note.warn { background: var(--wash-warn); border-color: rgba(250,178,25,.4); }
.note.info { background: var(--wash-info); border-color: rgba(42,120,214,.25); }

.empty { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty .big { font-size: 2.2rem; margin-bottom: 8px; opacity: .5; }

/* --------------------------------------------------------------- Login-Seite */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
             background: var(--plane); }
.loginbox { width: 100%; max-width: 380px; background: var(--surface-1);
            border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
            padding: 30px 28px; }
.loginbox .brand { justify-content: center; margin-bottom: 6px; font-size: 1.05rem; }
.loginbox p.lead { text-align: center; color: var(--text-secondary); font-size: .88rem;
                   margin-bottom: 22px; }

.filterchips { display: flex; flex-wrap: wrap; gap: 6px; }
.filterchips a {
  padding: 4px 11px; border-radius: 100px; border: 1px solid var(--border-strong);
  font-size: .8rem; color: var(--text-secondary); font-weight: 560;
}
.filterchips a:hover { background: var(--plane); text-decoration: none; }
.filterchips a.on { background: var(--series-1); border-color: var(--series-1); color: #fff; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; font-size: .88rem; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }
.bar-mini { height: 6px; border-radius: 3px; background: var(--series-1); min-width: 2px; }
