/* Ticker-Radar – schlichtes Dashboard-Design. Farben als Variablen, Dunkelmodus automatisch. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1a1d23;
  --muted: #667085;
  --accent: #e4002b;
  --accent-soft: #fde7eb;
  --ok: #15803d;
  --ok-soft: #e6f4ea;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --err: #b91c1c;
  --err-soft: #fdecec;
  --info: #1d4ed8;
  --info-soft: #e8effd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --border: #2a2f3a;
    --text: #e7e9ee;
    --muted: #98a2b3;
    --accent: #ff4d6a;
    --accent-soft: #3a1820;
    --ok: #4ade80;
    --ok-soft: #13291b;
    --warn: #fbbf24;
    --warn-soft: #2e2410;
    --err: #f87171;
    --err-soft: #331616;
    --info: #93b4ff;
    --info-soft: #18223a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
a:hover { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* Kopfzeile + Navigation */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; height: 56px;
}
.brand { font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500;
}
.nav a.active, .nav a:hover { background: var(--surface-2); color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.user-menu form { margin: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* Karten, Raster */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi.accent .value { color: var(--accent); }

/* Tabellen: auf dem Handy horizontal scrollbar innerhalb der Karte */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.item-row { display: flex; gap: 12px; align-items: flex-start; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.score {
  min-width: 46px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-2); border-radius: 8px; padding: 4px 6px; font-size: .9rem;
}

/* Badges */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle;
}
.badge.trend { background: var(--info-soft); color: var(--info); }
.badge.thema { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Tabs / Filter */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  text-decoration: none; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: .9rem;
}
.tabs a.active { background: var(--text); color: var(--surface); border-color: var(--text); }

/* Formulare */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 220px; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.inline-form { display: inline; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; font-size: .9rem;
}
button:hover, .btn:hover { background: var(--surface-2); color: var(--text); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(.95); background: var(--accent); color: #fff; }
button.small, .btn.small { padding: 3px 9px; font-size: .8rem; }
button.danger { color: var(--err); }
button.link { border: none; background: none; padding: 0; color: var(--muted); font-weight: 500; }
button.link:hover { color: var(--accent); background: none; }

/* Meldungen */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--err-soft); color: var(--err); }
.flash.info { background: var(--info-soft); color: var(--info); }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: .9rem; color: var(--muted); }

/* Charts */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px; align-items: center; padding: 3px 0; font-size: .9rem; }
.bar-label { position: relative; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 2px 6px; border-radius: 4px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); z-index: 0; border-radius: 4px; }
.bar-label span { position: relative; z-index: 1; }

/* Portal-Verwaltung */
.portal { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: var(--surface); }
.portal.inactive { opacity: .65; }
.portal-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.feed { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-top: 1px dashed var(--border); font-size: .88rem; }
.feed .url { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--muted); font-size: .9rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

@media (max-width: 640px) {
  /* Handy: Navigation in eigener Zeile über die ganze Breite */
  .topbar-inner { gap: 6px 10px; flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 6px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; }
  .user-menu .who { display: none; }
  h1 { font-size: 1.25rem; }
  .kpi .value { font-size: 1.3rem; }
}

/* Titel-Spalten in Tabellen nicht zusammenquetschen (auf dem Handy scrollt die Tabelle seitlich) */
td.title-cell { min-width: 260px; }

/* KI-Vorschlag */
.ki-card { border-color: var(--info); }
.ki-field { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.ki-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.ki-value { font-size: 1.02rem; overflow-wrap: anywhere; }
.ki-alt { margin-top: 6px; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.ki-list { margin: 0; padding-left: 18px; }
.ki-list li { margin: 2px 0; }
.ki-warn { background: var(--warn-soft); }
.count { font-weight: 600; color: var(--ok); text-transform: none; letter-spacing: 0; }
.count.over { color: var(--err); }
.copy { cursor: copy; }
.copy.copied { outline: 2px solid var(--ok); border-radius: 4px; }
a.ki-link { color: var(--info); text-decoration: none; font-weight: 600; }
