/* Berichte-Automat — funktionales, designneutrales Styling.
   Das visuelle Konzept entsteht separat: ALLE Farben/Radien/Schatten hängen an
   den Custom Properties unten. Umskinnen = Token tauschen, kein JS anfassen.
   Chart-Farben = validierte Referenzpalette (siehe Dataviz-Validator-Läufe). */

:root, [data-theme="hell"] {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f4f3ef;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #006300;
  --bad: #b3261e;
  --warn-dot: #ec835a;
  --good-dot: #0ca30c;
  --info-dot: #898781;
  --s1:#2a78d6; --s2:#1baf7a; --s3:#eda100; --s4:#008300;
  --s5:#4a3aa7; --s6:#e34948; --s7:#e87ba4; --s8:#eb6834;
  --seq-lo:#cde2fb; --seq-hi:#104281;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11,11,11,.04), 0 4px 14px rgba(11,11,11,.05);
  color-scheme: light;
}

[data-theme="dunkel"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --bad: #e66767;
  --s1:#3987e5; --s2:#199e70; --s3:#c98500; --s4:#008300;
  --s5:#9085e9; --s6:#e66767; --s7:#d55181; --s8:#d95926;
  --seq-lo:#184f95; --seq-hi:#9ec5f4;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.3);
  color-scheme: dark;
}

[data-theme="akzent"] {
  --page: #eef2f7;
  --surface: #fcfdfe;
  --surface-2: #e7edf5;
  --accent: #1c5cab;
  --border: rgba(16, 42, 67, 0.14);
  --shadow: 0 1px 2px rgba(16,42,67,.06), 0 6px 18px rgba(16,42,67,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page); color: var(--ink);
  font-size: 15px; line-height: 1.5;
  transition: background .25s ease, color .25s ease;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); }
[hidden] { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px clamp(14px, 3vw, 32px) 80px; }

/* ---------- Start-Ansicht ---------- */
.start { max-width: 760px; margin: 8vh auto 0; }
.start h1 { font-size: clamp(26px, 4vw, 38px); letter-spacing: -0.02em; line-height: 1.15; }
.start .lede { color: var(--ink-2); margin: 12px 0 30px; max-width: 56ch; }

.usecase-row { display: flex; gap: 10px; }
.usecase-row input {
  flex: 1; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); outline: none;
}
.usecase-row input:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); white-space: nowrap;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 7px 12px; font-size: 13px; box-shadow: none; }

.actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

.chips { margin-top: 34px; }
.chips .chips-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 10px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); font-size: 13.5px;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }

.dropzone {
  margin-top: 12px; border: 1.5px dashed var(--baseline); border-radius: var(--radius);
  padding: 18px; text-align: center; color: var(--ink-2); background: var(--surface);
}
.dropzone.dragover { border-color: var(--accent); background: var(--surface-2); }
.dropzone .file-name { color: var(--ink); font-weight: 600; }
.privacy-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; max-width: 62ch; }

/* ---------- Fortschritt ---------- */
.progress-view { max-width: 560px; margin: 18vh auto 0; text-align: center; }
.progress-step { font-size: 17px; margin-bottom: 18px; color: var(--ink); min-height: 26px; }
.progress-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 3px;
  transition: width .4s ease; }
.progress-hint { margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------- Fehler / Hinweise ---------- */
.banner {
  border: 1px solid var(--border); border-left: 3px solid var(--warn-dot);
  background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px; margin: 18px 0; color: var(--ink-2);
}
.banner strong { color: var(--ink); }
.banner .banner-actions { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--page); padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60;
  max-width: min(92vw, 560px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Dashboard-Kopf ---------- */
.dash-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
  justify-content: space-between; margin-bottom: 6px; }
.dash-title h2 { font-size: clamp(20px, 3vw, 28px); letter-spacing: -0.015em; }
.dash-title .sub { color: var(--ink-2); margin-top: 2px; }
.dash-title .meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); padding: 3px; box-shadow: var(--shadow);
}
.seg button { padding: 6px 13px; border-radius: 999px; font-size: 13px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: none;
}
.menu.open { display: block; }
.menu button { display: flex; width: 100%; text-align: left; padding: 9px 12px;
  border-radius: 7px; gap: 10px; align-items: baseline; }
.menu button:hover { background: var(--surface-2); }
.menu button .fmt { font-weight: 650; min-width: 44px; }
.menu button .desc { color: var(--muted); font-size: 12px; }

/* ---------- KPI-Zeile ---------- */
.kpis { display: grid; gap: 12px; margin: 18px 0 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px 12px; min-width: 0;
}
.kpi .k-label { font-size: 12.5px; color: var(--ink-2); }
.kpi .k-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.kpi .k-foot { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 6px; min-height: 22px; }
.kpi .k-delta { font-size: 12.5px; color: var(--muted); }
.kpi .k-delta.up { color: var(--good); }
.kpi .k-delta.down { color: var(--bad); }
.kpi .k-window { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi svg.spark { width: 76px; height: 22px; flex: none; }
.kpi svg.spark polyline { fill: none; stroke: var(--muted); stroke-width: 1.4; }
.kpi svg.spark circle { fill: var(--accent); }

/* ---------- Insights ---------- */
.insights {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 18px;
}
.insights h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 8px; }
.insight { position: relative; padding: 5px 0 5px 18px; color: var(--ink-2); }
.insight::before { content: ""; position: absolute; left: 2px; top: 13px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--info-dot); }
.insight.positive::before { background: var(--good-dot); }
.insight.warning::before { background: var(--warn-dot); }

/* ---------- Widget-Raster ---------- */
/* dense: kleinere Karten füllen Lücken hinter XL-Karten auf */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: dense; }
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px 10px; min-width: 0;
  display: flex; flex-direction: column;
}

/* „Neu"-Overlay auf frisch ergänzten Widgets — bewusst KEIN Kunden-Look,
   sondern dauerschicht-Signal (frosted glass, weicher Verlauf). Verschwindet
   mit einem Klick und lässt das neutrale Dashboard unangetastet. */
.card-overlay {
  position: absolute; inset: 0; z-index: 5;
  border: 0; border-radius: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 20px; text-align: center; color: #fff;
  background: linear-gradient(115deg,
    rgba(42, 120, 214, 0.60), rgba(116, 78, 214, 0.55) 40%,
    rgba(226, 116, 164, 0.55) 75%, rgba(42, 120, 214, 0.60));
  background-size: 300% 300%;
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  animation: overlay-drift 8s ease-in-out infinite alternate;
  opacity: 1; transition: opacity .45s ease;
}
.card-overlay:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }
.card-overlay.leaving { opacity: 0; pointer-events: none; }
.card-overlay .ov-badge {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.45);
}
.card-overlay .ov-title {
  font-size: 17px; font-weight: 650; letter-spacing: -0.01em; max-width: 34ch;
  text-shadow: 0 1px 10px rgba(20, 30, 80, 0.35);
}
.card-overlay .ov-hint { font-size: 13px; color: rgba(255, 255, 255, 0.88); }
@keyframes overlay-drift {
  from { background-position: 0% 25%; }
  to   { background-position: 100% 75%; }
}
@supports not (backdrop-filter: blur(1px)) {
  /* Ohne backdrop-filter (alte Browser): Verlauf dichter, weiterhin lesbar */
  .card-overlay { background-color: rgba(60, 80, 180, 0.82); }
}
.card.size-xl { grid-column: 1 / -1; }
.card.dragging { opacity: .35; }
.card.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }

.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.card-head h4 { font-size: 14.5px; font-weight: 650; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tools { display: flex; gap: 2px; align-items: center; opacity: 0; transition: opacity .15s; }
.card:hover .card-tools, .card:focus-within .card-tools { opacity: 1; }
.tool-btn {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--muted);
}
.tool-btn:hover { background: var(--surface-2); color: var(--ink); }
.tool-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--accent); }
.tool-btn svg { width: 15px; height: 15px; }
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.tool-sep { width: 1px; height: 16px; background: var(--grid); margin: 0 4px; }

.chart-box { min-height: 240px; flex: 1; }
.card.size-xl .chart-box { min-height: 280px; }

.card-note { font-size: 12px; color: var(--muted); padding: 4px 2px 2px; }

/* Inline-Editor „Was soll hier anders sein?" */
.card-edit { display: flex; gap: 8px; margin: 6px 0 10px; }
.card-edit input {
  flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); outline: none; font-size: 13.5px;
}
.card-edit input:focus { border-color: var(--accent); }

/* Widget-Tabelle */
.viz-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.viz-table th { text-align: left; color: var(--ink-2); font-weight: 600; padding: 7px 10px;
  border-bottom: 1.5px solid var(--baseline); position: sticky; top: 0; background: var(--surface); }
.viz-table td { padding: 6px 10px; border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums; }
.viz-table td.num, .viz-table th.num { text-align: right; }
.table-scroll { overflow: auto; max-height: 320px; }

/* Info-Tooltip */
.tip {
  position: fixed; z-index: 70; max-width: 280px; background: var(--ink); color: var(--page);
  padding: 8px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.45;
  pointer-events: none; opacity: 0; transition: opacity .12s;
}
.tip.show { opacity: 1; }

/* Ausgeblendete Widgets */
.hidden-row { margin-top: 14px; font-size: 13px; color: var(--muted);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hidden-row .chip { font-size: 12.5px; padding: 6px 12px; }

/* Refine-Zeile */
.refine {
  display: flex; gap: 10px; margin-top: 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px;
}
.refine input { flex: 1; border: 0; outline: none; background: none; padding: 4px 8px; }
.refine .hint { display: none; }

/* CTA-Fuß */
.cta {
  margin-top: 26px; padding: 20px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2);
}
.cta strong { color: var(--ink); }
.cta a { color: var(--accent); }

/* ---------- Layout-Varianten ---------- */
[data-layout="kompakt"] .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
[data-layout="kompakt"] .card.size-xl { grid-column: span 2; }
[data-layout="kompakt"] .chart-box { min-height: 200px; }
[data-layout="kompakt"] .card.size-xl .chart-box { min-height: 220px; }
[data-layout="kompakt"] .kpi .k-value { font-size: 21px; }

[data-layout="praesentation"] .grid { grid-template-columns: minmax(0, 1fr); }
[data-layout="praesentation"] .card { padding: 22px 26px 16px; }
[data-layout="praesentation"] .chart-box,
[data-layout="praesentation"] .card.size-xl .chart-box { min-height: 340px; }
[data-layout="praesentation"] .card-head h4 { font-size: 18px; }
[data-layout="praesentation"] .kpi .k-value { font-size: 32px; }

@media (max-width: 860px) {
  .grid, [data-layout="kompakt"] .grid { grid-template-columns: minmax(0, 1fr); }
  .card.size-xl, [data-layout="kompakt"] .card.size-xl { grid-column: auto; }
  .dash-head { align-items: flex-start; flex-direction: column; }
  .card-tools { opacity: 1; }
  .drag-handle { display: none; }
}

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

/* Ausklappbare Aufbereitungs-Notizen (Ehrlichkeits-Banner) */
.banner .banner-more { margin-top: 6px; }
.banner button.small { margin-left: 6px; vertical-align: baseline; }
