/* =========================================================================
   Chatbot-Verwaltung — Gestaltung nach der Designsprache von
   webdesign-zoning.de (Farben, Radien, Schatten, Schriften aus css/styles.css).

   Zwei getrennte Farbwelten, bewusst:
   - Oberflaeche: die Markenfarben (Dunkelblau #1b2c50, Rot #b23f42).
   - Diagramme:   eigens gepruefte Datenfarben. Das Markenblau faellt als
                  Datenfarbe durch die Pruefung (zu dunkel, zu grau) — als
                  Balken auf hellem Grund waere es nicht unterscheidbar genug.
                  Geprueft mit dem Palettenpruefer: hell #2f5aa8 / #b23f42,
                  dunkel #5b8ad4 / #d06b6e (Helligkeitsband, Chroma,
                  Farbfehlsichtigkeit, Kontrast — alle bestanden).
   ========================================================================= */

@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('fonts/source-sans-3-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('fonts/source-sans-3-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('fonts/source-serif-4-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Marke — 1:1 aus css/styles.css der Website */
  --blue: #1b2c50;
  --blue-dark: #13203f;
  --blue-light: #eaeff7;
  --red: #b23f42;
  --red-dark: #913235;
  --ink: #1a2438;
  --muted: #5b6678;
  --white: #fff;
  --bg-soft: #f5f7fb;
  --border: #e4e9f1;
  --radius: 10px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(19, 32, 63, .04), 0 2px 6px rgba(19, 32, 63, .04);
  --shadow-md: 0 8px 22px rgba(19, 32, 63, .07);
  --shadow-lg: 0 16px 38px rgba(19, 32, 63, .09);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --font-sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  /* Flaechen der Oberflaeche */
  --surface: var(--white);
  --surface-soft: var(--bg-soft);
  --surface-sunken: #eef1f7;
  --rail: var(--blue);
  --rail-ink: #fff;
  --rail-muted: rgba(255, 255, 255, .62);
  --rail-active: rgba(255, 255, 255, .12);

  /* Diagrammfarben (geprueft) */
  --data: #2f5aa8;
  --data-soft: #dce6f6;
  --data-warn: #b23f42;
  --grid: #e9edf4;

  /* Zustaende */
  --ok: #2f7a4d;
  --ok-soft: #e6f2ea;
  --warn: #8a6414;
  --warn-soft: #fbf2dd;
  --bad: #a8322f;
  --bad-soft: #fbeceb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8ebf2;
    --muted: #98a3b8;
    --border: #263043;
    --white: #151b28;
    --bg-soft: #0f141d;
    --blue-light: #1d2941;
    --surface: #151b28;
    --surface-soft: #0f141d;
    --surface-sunken: #1a2130;
    --rail: #101724;
    --rail-active: rgba(255, 255, 255, .08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, .34);
    --shadow-lg: 0 16px 38px rgba(0, 0, 0, .42);
    --data: #5b8ad4;
    --data-soft: #23324c;
    --data-warn: #d06b6e;
    --grid: #222b3c;
    --ok: #5fb884;
    --ok-soft: #16281f;
    --warn: #d3a343;
    --warn-soft: #2a2314;
    --bad: #e07a7d;
    --bad-soft: #2b1a1b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -.005em; margin: 0; }
a { color: var(--data); }

/* ---------- Bedienelemente ---------------------------------------------- */

button {
  font-family: var(--font-sans);
  font-size: .93rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.2;
  padding: 10px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease),
              color .2s var(--ease), transform .2s var(--ease);
}
button:hover { border-color: var(--blue); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }

button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); box-shadow: var(--shadow-md); }
button.cta { background: var(--red); border-color: var(--red); color: #fff; }
button.cta:hover { background: var(--red-dark); border-color: var(--red-dark); }
button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
button.quiet:hover { color: var(--ink); border-color: var(--border); }
button.small { padding: 5px 11px; font-size: .82rem; font-weight: 500; }
button[disabled] { opacity: .5; cursor: default; transform: none; }

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: .93rem;
  line-height: 1.5;
  transition: border-color .2s var(--ease);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--data); }
textarea { min-height: 92px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }
select { cursor: pointer; }

/* ---------- Grundgeruest ------------------------------------------------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.rail {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.rail .brand { padding: 0 10px; }
.rail .brand .name {
  font-family: var(--font-serif);
  font-size: 1.16rem;
  font-weight: 600;
  letter-spacing: .01em;
  display: block;
}
.rail .brand .role {
  font-size: .74rem;
  color: var(--rail-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 2px;
  display: block;
}
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--rail-muted);
  font-weight: 500;
  font-size: .92rem;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.rail nav button:hover { background: var(--rail-active); color: #fff; transform: none; }
.rail nav button[aria-current='page'] { background: var(--rail-active); color: #fff; font-weight: 600; }
.rail nav button .dot {
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
  opacity: 0; transition: opacity .18s;
}
.rail nav button[aria-current='page'] .dot { opacity: 1; }
.rail nav button .count {
  margin-left: auto; font-size: .74rem; font-weight: 600;
  background: rgba(255,255,255,.16); border-radius: 999px; padding: 1px 7px;
}
.rail .foot { margin-top: auto; padding: 0 10px; }
.rail .foot button { width: 100%; justify-content: center; color: var(--rail-muted); border-color: rgba(255,255,255,.18); background: transparent; }
.rail .foot button:hover { color: #fff; border-color: rgba(255,255,255,.4); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 30px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.32rem; }
.topbar .spacer { flex: 1; }

.content { padding: 26px 30px 60px; max-width: 1220px; }

/* ---------- Karten ------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card > header { margin-bottom: 18px; }
.card h2 { font-size: 1.06rem; }
.card .hint { color: var(--muted); font-size: .87rem; margin: 5px 0 0; max-width: 68ch; }
.card .hint a { color: var(--data); }

.section-gap { margin-top: 30px; }

/* ---------- Zahlen ------------------------------------------------------- */

.hero { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero .figure { font-size: 3.1rem; font-weight: 600; line-height: 1; letter-spacing: -.025em; }
.hero .caption { color: var(--muted); font-size: .93rem; }

.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.tile {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
}
.tile .value { font-size: 1.72rem; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; }
.tile .label { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.tile .value.is-warn { color: var(--warn); }
.tile .value.is-bad { color: var(--bad); }

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

/* Trichter — waagerechte Balken */
.funnel { display: flex; flex-direction: column; gap: 9px; }
.frow { display: grid; grid-template-columns: minmax(96px, 168px) 1fr auto; align-items: center; gap: 14px; }
.flabel { color: var(--muted); font-size: .85rem; }
.ftrack {
  position: relative; display: block; height: 22px;
  background: var(--data-soft); border-radius: 3px; cursor: default;
}
.fbar {
  position: absolute; inset: 0 auto 0 0; display: block;
  background: var(--data); border-radius: 3px;
  transition: width .45s var(--ease);
}
.ftrack:hover .fbar { opacity: .86; }
.fvalue { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 3.2ch; text-align: right; }

/* Säulen je Tag */
.cols-chart { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.cols-axis {
  display: flex; flex-direction: column; justify-content: space-between;
  height: 140px; color: var(--muted); font-size: .74rem;
  font-variant-numeric: tabular-nums; text-align: right; padding-top: 1px;
}
.cols-plot { position: relative; height: 140px; }
.cols-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.cols-grid i { display: block; border-top: 1px solid var(--grid); }
.cols {
  position: absolute; inset: 0; display: flex; align-items: flex-end;
  gap: 2px; padding-bottom: 1px;
}
.col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; min-width: 0; cursor: default; }
.col-stack { position: relative; width: 100%; height: 100%; display: flex; align-items: flex-end; }
.col-bar {
  width: 100%; background: var(--data);
  border-radius: 3px 3px 0 0; transition: opacity .18s;
}
.col-err {
  position: absolute; left: 0; bottom: 0; width: 100%;
  background: var(--data-warn); border-radius: 3px 3px 0 0;
}
.col:hover .col-bar { opacity: .82; }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: .82rem; color: var(--muted); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend .swatch { width: 11px; height: 11px; border-radius: 2px; }

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--ink); color: var(--surface);
  border-radius: var(--radius-sm); padding: 7px 11px;
  font-size: .8rem; line-height: 1.45; white-space: nowrap;
  box-shadow: var(--shadow-md); opacity: 0; transition: opacity .12s;
}
.tooltip.show { opacity: 1; }
.tooltip b { font-weight: 600; }

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

.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  color: var(--muted); font-weight: 600; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom-width: 1.5px; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-soft); }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
td.actions { white-space: nowrap; }
td.actions .row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Kleinteile --------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-sunken); color: var(--muted);
  border: 1px solid var(--border);
}
.pill .led { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.note {
  background: var(--warn-soft);
  border: 1px solid transparent;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 12px 15px; font-size: .87rem; color: var(--ink);
  margin-bottom: 18px;
}
.note strong { font-weight: 600; }

.field { margin-bottom: 17px; }
.field label { display: block; font-size: .87rem; font-weight: 600; margin-bottom: 6px; }
.field .desc { color: var(--muted); font-size: .82rem; margin: 6px 0 0; max-width: 64ch; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

.empty {
  color: var(--muted); font-size: .9rem;
  padding: 26px 4px; text-align: center;
}
code {
  background: var(--surface-sunken); padding: 2px 6px;
  border-radius: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem;
}

.msg { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--surface-soft); }
.msg.user { border-left: 3px solid var(--data); }
.msg .meta { color: var(--muted); font-size: .76rem; margin-top: 7px; }

.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 80;
  background: var(--blue); color: #fff;
  border-radius: var(--radius-sm); padding: 13px 18px;
  font-size: .89rem; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); transition: .2s var(--ease);
  pointer-events: none; max-width: 380px;
}
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--red); }

/* ---------- Anmeldung ---------------------------------------------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--surface-soft); }
.login {
  width: 100%; max-width: 372px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 34px 32px;
}
.login .name { font-family: var(--font-serif); font-size: 1.42rem; font-weight: 600; }
.login .role { color: var(--muted); font-size: .87rem; margin: 4px 0 24px; }
.login .err { color: var(--bad); font-size: .85rem; margin-top: 12px; min-height: 1.2em; }

/* ---------- Schmale Fenster ---------------------------------------------- */

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 14px; padding: 12px 16px; overflow-x: auto;
  }
  .rail .brand { flex: 0 0 auto; }
  .rail .brand .role { display: none; }
  .rail nav { flex-direction: row; gap: 4px; }
  .rail nav button .count { display: none; }
  .rail .foot { margin: 0; padding: 0; flex: 0 0 auto; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
}

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