:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #5d6573;
  --border: #e1e4ea;
  --accent: #1f6feb;          /* an die go4future-Farbe anpassen */
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --ok-bg: #e7f5ec;
  --fail: #b42318;
  --fail-bg: #fdecea;
  --hit-row: #f1f8f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --border: #2a2f3a;
    --accent: #4c8dff;
    --accent-text: #0b0d12;
    --ok: #4ac26b;
    --ok-bg: #12261a;
    --fail: #f47067;
    --fail-bg: #2d1514;
    --hit-row: #13201a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 16px 48px; }

.page-head h1 { margin: 0 0 4px; font-size: 1.75rem; letter-spacing: -.01em; }
.lede { margin: 0 0 24px; color: var(--muted); max-width: 62ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.card-head h2 { margin: 0; font-size: 1.1rem; }
.card-actions { display: flex; gap: 12px; }

.btn-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; font-size: .9rem;
}
.btn-link:hover { text-decoration: underline; }

.btn-primary {
  background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 8px; padding: 10px 20px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn-primary:disabled { opacity: .6; cursor: progress; }

/* Watchlist */
.chips { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty::before { content: "Noch keine Aktien ausgewählt."; color: var(--muted); font-size: .9rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: .9rem; font-weight: 500;
}
.chip button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%; font-size: 1rem; line-height: 1;
}
.chip button:hover { background: var(--border); color: var(--text); }

.search { position: relative; }
.search input, .crit input {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
}
.search input:focus, .crit input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.suggestions {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
  max-height: 320px; overflow-y: auto;
}
.suggestions li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--bg); }
.sugg-symbol { font-weight: 600; white-space: nowrap; }
.sugg-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sugg-exch { color: var(--muted); font-size: .8rem; white-space: nowrap; }

.hint { margin: 8px 0 0; color: var(--muted); font-size: .85rem; }
code { font-size: .85em; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

/* Kriterien */
.criteria { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.crit { display: flex; flex-direction: column; gap: 4px; }
.crit-label { font-weight: 600; font-size: .9rem; }
.crit-help { color: var(--muted); font-size: .8rem; }

.run-row { display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.status { color: var(--muted); font-size: .9rem; }

/* Ergebnis */
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.summary { margin: 0 0 12px; }
.summary strong { font-variant-numeric: tabular-nums; }

.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.results { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 720px; }
.results th, .results td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.results th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.results .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.results tr.hit { background: var(--hit-row); }
.results tbody tr:last-child td { border-bottom: 0; }

.stock-ticker { font-weight: 600; }
.stock-name { display: block; color: var(--muted); font-size: .82rem; }

.v-ok { color: var(--ok); }
.v-fail { color: var(--fail); }
.v-missing { color: var(--muted); }
.v-ok::after, .v-fail::after { margin-left: 4px; font-weight: 700; }
.v-ok::after { content: "✓"; }
.v-fail::after { content: "✗"; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-fail { background: var(--fail-bg); color: var(--fail); }

.errors { list-style: none; margin: 12px 0 0; padding: 0; color: var(--fail); font-size: .88rem; }
.errors li { margin-top: 4px; }

.foot { color: var(--muted); font-size: .8rem; margin-top: 24px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 560px) {
  .wrap { padding-top: 20px; }
  .card { padding: 16px; }
  .table-scroll { margin: 0 -16px; padding: 0 16px; }
}

/* ---------- Anmeldung und Benutzerverwaltung ---------- */
.wrap.narrow { max-width: 440px; padding-top: 48px; }
.auth h2 { margin: 0 0 16px; font-size: 1.2rem; }
.auth form { margin: 0; }
.auth-intro { margin: 0 0 16px; color: var(--muted); }
.auth .btn-primary { width: 100%; margin-top: 4px; }
.auth-links { margin: 16px 0 0; font-size: .9rem; text-align: center; color: var(--muted); }

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

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); font-size: .8rem; }
.field input, .inline-form input {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
}
.field input[readonly] { background: var(--bg); color: var(--muted); }
.field input:focus, .inline-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.notice { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; font-size: .92rem; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-error { background: var(--fail-bg); color: var(--fail); }

.userbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-bottom: 16px; margin-bottom: 24px; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.userbar-home { font-weight: 600; color: var(--text); }
.userbar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.userbar-email { color: var(--muted); }
.userbar form { margin: 0; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 240px; width: auto; }

.btn-danger { color: var(--fail); }
table.users { min-width: 560px; }
.users .actions { text-align: right; white-space: nowrap; }
.users .actions form { display: inline; margin-left: 12px; }
.users .badge { margin-left: 8px; vertical-align: 1px; }
/* Watchlist-Einträge mit Name und ISIN */
.chip-name { font-weight: 600; }
.chip-code { color: var(--muted); font-size: .8rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.watch-msg { margin: 8px 0 0; font-size: .88rem; color: var(--muted); }
.watch-msg:empty { display: none; }
.watch-msg.is-error { color: var(--fail); }