/* =========================================================================
   Creator-Affiliate-Portal – Stylesheet
   Ein Farbsystem, in Rollen definiert, damit Hell/Dunkel an einer Stelle
   umgeschaltet wird. Serienfarbe für den Chart nach Kontrast validiert.
   ========================================================================= */

:root {
  color-scheme: light;
  --surface-0: #f6f5f2;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dedcd6;
  --border-strong: #c4c2ba;
  --text-primary: #171614;
  --text-secondary: #52514e;
  --text-muted: #7b7a75;
  --series-1: #2a78d6;
  --series-1-soft: #e8f0fd;
  --good: #1b7f4d;
  --good-soft: #e2f3ea;
  --warn: #9a6400;
  --warn-soft: #fbf0d9;
  --danger: #b32d2c;
  --danger-soft: #fbe8e7;
  --focus: #2a78d6;
  --shadow: 0 1px 2px rgba(20, 20, 18, .06), 0 6px 18px rgba(20, 20, 18, .05);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --border: #333331;
    --border-strong: #4a4a47;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #918f86;
    --series-1: #3987e5;
    --series-1-soft: #1d2b3e;
    --good: #4bb47c;
    --good-soft: #16281f;
    --warn: #d9a441;
    --warn-soft: #2a2214;
    --danger: #e66767;
    --danger-soft: #2d1a1a;
    --focus: #6da7ec;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --border: #333331;
  --border-strong: #4a4a47;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #918f86;
  --series-1: #3987e5;
  --series-1-soft: #1d2b3e;
  --good: #4bb47c;
  --good-soft: #16281f;
  --warn: #d9a441;
  --warn-soft: #2a2214;
  --danger: #e66767;
  --danger-soft: #2d1a1a;
  --focus: #6da7ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "tnum" 0;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Layout --------------------------------------------------------------- */

.topbar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 650;
  letter-spacing: -.01em;
  color: var(--text-primary);
  font-size: 15px;
}
.brand:hover { text-decoration: none; }

.topnav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}

.topnav a {
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.topnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }
.topnav a.is-active { background: var(--surface-2); color: var(--text-primary); font-weight: 550; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}
.wrap--narrow { max-width: 620px; }

.page-head { margin-bottom: 22px; }
.page-head h1 {
  font-size: 24px;
  letter-spacing: -.02em;
  margin: 0 0 4px;
  font-weight: 640;
}
.page-head p { margin: 0; color: var(--text-secondary); }

h2 { font-size: 17px; letter-spacing: -.01em; margin: 0 0 12px; font-weight: 620; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card--flush { padding: 0; overflow: hidden; }
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; }
.card-head .sub { color: var(--text-muted); font-size: 13px; margin-left: auto; }
.card-body { padding: 20px; }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.empty { color: var(--text-muted); font-size: 14px; margin: 0; padding: 8px 0; }

/* --- Kennzahlkacheln ------------------------------------------------------ */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 560;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 26px;
  font-weight: 620;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-delta { font-size: 13px; margin-top: 4px; font-weight: 550; }
.stat-delta.up { color: var(--good); }
.stat-delta.down { color: var(--danger); }
.stat-delta.flat { color: var(--text-muted); }

/* --- Chart ---------------------------------------------------------------- */

.chart-scroll { overflow-x: auto; padding-bottom: 4px; }
.chart { display: block; width: 100%; min-width: 620px; height: auto; }
.c-grid { stroke: var(--border); stroke-width: 1; }
.c-baseline { stroke: var(--border-strong); stroke-width: 1; }
.c-axis { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.c-peak { fill: var(--text-secondary); font-size: 11px; font-weight: 600; font-family: inherit; }
.c-bar { fill: var(--series-1); }
.c-bar--zero { fill: var(--border-strong); }
.c-hit { fill: transparent; }
.c-col:hover .c-bar { fill: var(--text-primary); }
.c-col:hover .c-hit { fill: color-mix(in srgb, var(--series-1) 8%, transparent); }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--surface-1);
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -130%);
  transition: opacity .1s;
  z-index: 50;
}
.tooltip.is-visible { opacity: 1; }

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

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  font-weight: 570;
  color: var(--text-secondary);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* --- Formulare ------------------------------------------------------------ */

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-weight: 560;
  margin-bottom: 5px;
  font-size: 14px;
}
.field .hint { color: var(--text-muted); font-size: 13px; margin: 0 0 6px; }
.optional { color: var(--text-muted); font-weight: 400; font-size: 13px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
  border-color: var(--focus);
}
input[aria-invalid=true] { border-color: var(--danger); }
textarea { min-height: 80px; resize: vertical; }

.input-prefix { display: flex; align-items: stretch; }
.input-prefix span {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
}
.input-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.field-error { color: var(--danger); font-size: 13px; margin-top: 5px; font-weight: 500; }

.checkline { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.checkline input { margin-top: 3px; flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--series-1); }
.checkline label { font-size: 14px; font-weight: 400; line-height: 1.5; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--series-1);
  color: #fff;
  font: inherit;
  font-weight: 560;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--ghost { background: var(--surface-1); color: var(--text-primary); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }
.btn--danger { background: var(--danger); }
.btn--sm { padding: 6px 12px; font-size: 13.5px; }
.btn--wide { width: 100%; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --- Hinweise ------------------------------------------------------------- */

.note {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.note--info { background: var(--series-1-soft); border-color: color-mix(in srgb, var(--series-1) 25%, transparent); }
.note--good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.note--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.note--danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.note p { margin: 0 0 6px; }
.note p:last-child { margin-bottom: 0; }
.note strong { font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 570;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge--good { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.badge--neutral { background: var(--surface-2); color: var(--text-secondary); border-color: var(--border); }

/* --- Code-Anzeige --------------------------------------------------------- */

.code-display {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 620;
  letter-spacing: .06em;
}

/* --- Regelliste ----------------------------------------------------------- */

.rules { margin: 0; padding: 0; list-style: none; }
.rules li {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}
.rules li:last-child { border-bottom: 0; }
.rules .mark { flex-shrink: 0; font-weight: 700; width: 18px; }
.rules .yes .mark { color: var(--good); }
.rules .no .mark { color: var(--danger); }

.steps { counter-reset: step; margin: 0; padding: 0; list-style: none; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 18px 38px;
  border-left: 1px solid var(--border);
  margin-left: 12px;
}
.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: -12px;
  top: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 620;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps li.done::before {
  content: "✓";
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--good);
}
.steps li.current::before { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.steps li > strong { display: block; font-weight: 570; margin-bottom: 2px; }
.steps p strong { font-weight: 620; }
.steps p { margin: 0; color: var(--text-secondary); font-size: 14px; }

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--text-muted);
  font-size: 13px;
}
.footer a { color: var(--text-secondary); }
